liusuyi
2026-05-06 99ab0d46d30b095d0e1c9d31349f42e0cefc9881
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
package com.ard.qs.controller;
 
import com.ard.common.core.web.controller.BaseController;
import com.ard.common.core.web.domain.AjaxResult;
import com.ard.common.core.web.page.TableDataInfo;
import com.ard.qs.api.domain.QsGroup;
import com.ard.qs.domain.QsGroupTree;
import com.ard.qs.service.IQsGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 分组管理
 *
 * @FileName QsGroupController
 * @Description
 * @Author fengcheng
 * @date 2026-04-14
 **/
@Slf4j
@RestController
@RequestMapping("/group")
public class QsGroupController extends BaseController {
    @Autowired
    private IQsGroupService qsGroupService;
 
    /**
     * 添加分组
     *
     * @param group 分组信息
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody QsGroup group) {
        qsGroupService.add(group);
        return success();
    }
 
    /**
     * 更新分组
     *
     * @param group 分组信息
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody QsGroup group) {
        qsGroupService.update(group);
        return success();
    }
 
    /**
     * 删除分组
     *
     * @param id 分组id
     */
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id) {
        Assert.notNull(id, "分组id(deviceId)不需要存在");
        boolean result = qsGroupService.delete(id);
        if (!result) {
            throw new RuntimeException("移除失败");
        }
        return success();
    }
 
    /**
     * 查询分组节点
     *
     * @param query     要搜索的内容
     * @param parent    所属分组编号
     * @param hasDevice 是否查询设备
     * @return
     */
    @GetMapping("/tree/list")
    public AjaxResult queryForTree(@RequestParam(required = false) String query, @RequestParam(required = false) Integer parent, @RequestParam(required = false) Boolean hasDevice) {
        if (ObjectUtils.isEmpty(query)) {
            query = null;
        }
        List<QsGroupTree> list = qsGroupService.queryForTree(query, parent, hasDevice);
        return success(list);
    }
 
    /**
     * 查询分组节点设备
     *
     * @return
     */
    @GetMapping("/device/list")
    public AjaxResult queryForDevice() {
        List<QsGroupTree> list = qsGroupService.queryForDevice();
        return success(list);
    }
 
    /**
     * 查询分组
     *
     * @param query 要搜索的内容
     * @return
     */
    @GetMapping("/tree/query")
    public TableDataInfo queryTree(String query) {
        startPage();
        List<QsGroup> list = qsGroupService.queryList(query);
        return getDataTable(list);
    }
}