lyh
2025-02-24 3f5737664d799ece89224079860505a009dec32b
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
package org.jeecg.modules.dnc.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.dnc.entity.DeviceGroup;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.QueryListResponseResult;
import org.jeecg.modules.dnc.response.ResponseResult;
import org.jeecg.modules.dnc.service.IDeviceGroupService;
import org.jeecg.modules.dnc.ucenter.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
@Slf4j
@Api(tags = "设备分组表")
@RestController
@RequestMapping("/nc/device/group")
public class DeviceGroupController extends JeecgController<DeviceGroup, IDeviceGroupService> {
 
    @Autowired
    private IDeviceGroupService deviceGroupService;
 
    @AutoLog(value = "设备分组表-新增设备分组")
    @ApiOperation(value = "设备分组表-新增设备分组", notes = "设备分组表-新增设备分组")
    @PostMapping("/add")
    public ResponseResult addDeviceGroup(@RequestBody DeviceGroup deviceGroup) {
        boolean b = deviceGroupService.addDeviceGroup(deviceGroup);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @AutoLog(value = "设备分组表-编辑设备分组")
    @ApiOperation(value = "设备分组表-编辑设备分组", notes = "设备分组表-编辑设备分组")
    @PutMapping("/edit/{id}")
    public ResponseResult editDeviceGroup(@PathVariable("id") String id, @RequestBody DeviceGroup deviceGroup) {
        boolean b = deviceGroupService.editDeviceGroup(id, deviceGroup);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @AutoLog(value = "设备分组表-删除设备分组")
    @ApiOperation(value = "设备分组表-删除设备分组", notes = "设备分组表-删除设备分组")
    @DeleteMapping("/delete")
    public ResponseResult deleteDeviceGroup(@RequestParam("id") String id) {
        boolean b = deviceGroupService.deleteDeviceGroup(id);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
 
    @AutoLog(value = "设备分组表-获取分组已分配的部门")
    @ApiOperation(value = "设备分组表-获取分组已分配的部门", notes = "设备分组表-获取分组已分配的部门")
    @GetMapping("/get/perm/depart/{groupId}")
    public QueryListResponseResult<Department> getDepartPermsList(@PathVariable("groupId") String groupId) {
        List<Department> list = deviceGroupService.getDepartPermsList(groupId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @AutoLog(value = "设备分组表-获取分组未分配的部门")
    @ApiOperation(value = "设备分组表-获取分组未分配的部门", notes = "设备分组表-获取分组未分配的部门")
    @GetMapping("/get/non/perm/depart/{groupId}")
    public QueryListResponseResult<Department> getDepartNonPermsList(@PathVariable("groupId") String groupId) {
        List<Department> list = deviceGroupService.getDepartNonPermsList(groupId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
//    @AutoLog(value = "设备分组表-给分组分配部门权限")
//    @ApiOperation(value = "设备分组表-给分组分配部门权限", notes = "设备分组表-给分组分配部门权限")
//    @PostMapping("/assign/add/depart/{groupId}/{relativeFlag}")
//    public ResponseResult assignAddDepartment(@PathVariable("groupId") String groupId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) {
//        boolean b = deviceGroupService.assignAddDepartment(groupId, relativeFlag, departmentIds);
//        if(b) {
//            return new ResponseResult(CommonCode.SUCCESS);
//        }
//        return new ResponseResult(CommonCode.FAIL);
//    }
//
//    @AutoLog(value = "设备分组表-移除分组分配部门权限")
//    @ApiOperation(value = "设备分组表-移除分组分配部门权限", notes = "设备分组表-移除分组分配部门权限")
//    @PostMapping("/assign/remove/depart/{groupId}/{relativeFlag}")
//    public ResponseResult assignRemoveDepartment(@PathVariable("groupId") String groupId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) {
//        boolean b = deviceGroupService.assignRemoveDepartment(groupId, relativeFlag, departmentIds);
//        if(b) {
//            return new ResponseResult(CommonCode.SUCCESS);
//        }
//        return new ResponseResult(CommonCode.FAIL);
//    }
 
 
}