车间能级提升-智能设备管理系统
朱桂飞
2025-01-09 3e8f7f239bedae0b4f04a1ac6bd443ba6298f73c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package org.dromara.eims.controller;
 
import java.util.List;
 
import cn.hutool.core.lang.tree.Tree;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.eims.domain.vo.SysEquTypeVo;
import org.dromara.eims.domain.bo.SysEquTypeBo;
import org.dromara.eims.service.ISysEquTypeService;
 
/**
 * 设备类型
 *
 * @author zhuguifei
 * @date 2025-01-06
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/eims/equType")
public class SysEquTypeController extends BaseController {
 
    private final ISysEquTypeService sysEquTypeService;
 
    /**
     * 查询设备类型列表
     */
    @SaCheckPermission("eims:equType:list")
    @GetMapping("/list")
    public R<List<SysEquTypeVo>> list(SysEquTypeBo bo) {
        List<SysEquTypeVo> list = sysEquTypeService.queryList(bo);
        return R.ok(list);
    }
 
    /**
     * 获取设备类型树列表
     */
    @SaCheckPermission("eims:equType:list")
    @GetMapping("/tree")
    public R<List<Tree<Long>>> equTypeTree(SysEquTypeBo bo) {
        return R.ok(sysEquTypeService.selectEquTypeTreeList(bo));
    }
 
    /**
     * 导出设备类型列表
     */
    @SaCheckPermission("eims:equType:export")
    @Log(title = "设备类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(SysEquTypeBo bo, HttpServletResponse response) {
        List<SysEquTypeVo> list = sysEquTypeService.queryList(bo);
        ExcelUtil.exportExcel(list, "设备类型", SysEquTypeVo.class, response);
    }
 
    /**
     * 获取设备类型详细信息
     *
     * @param equTypeId 主键
     */
    @SaCheckPermission("eims:equType:query")
    @GetMapping("/{equTypeId}")
    public R<SysEquTypeVo> getInfo(@NotNull(message = "主键不能为空")
                                   @PathVariable Long equTypeId) {
        return R.ok(sysEquTypeService.queryById(equTypeId));
    }
 
    /**
     * 新增设备类型
     */
    @SaCheckPermission("eims:equType:add")
    @Log(title = "设备类型", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody SysEquTypeBo bo) {
        return toAjax(sysEquTypeService.insertByBo(bo));
    }
 
    /**
     * 修改设备类型
     */
    @SaCheckPermission("eims:equType:edit")
    @Log(title = "设备类型", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysEquTypeBo bo) {
        return toAjax(sysEquTypeService.updateByBo(bo));
    }
 
    /**
     * 删除设备类型
     *
     * @param equTypeIds 主键串
     */
    @SaCheckPermission("eims:equType:remove")
    @Log(title = "设备类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{equTypeIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] equTypeIds) {
        if (equTypeIds == null || equTypeIds.length == 0) {
            return R.warn("请选择需要删除的数据");
        }
        for (int i = 0; i < equTypeIds.length; i++) {
            if (sysEquTypeService.hasChildByEquTypeId(equTypeIds[i])) {
                return R.warn("存在子菜单,不允许删除");
            }
        }
 
        return toAjax(sysEquTypeService.deleteWithValidByIds(List.of(equTypeIds), true));
    }
}