管道基础大数据平台系统开发-【后端】-Server
Surpriseplus
2022-10-08 0e0a6258ce04c9b89fdf1b5507675f35f8a09124
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package com.lf.server.controller.data;
 
import com.lf.server.aspect.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.data.DirEntity;
import com.lf.server.service.data.DirService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 目录管理
 * @author sws
 * @date   2022-09-22
 */
@Api(tags = "数据管理\\目录管理")
@RestController
@RequestMapping("/dir")
public class DirController extends BaseController {
    @Autowired
    DirService dirService;
 
    @SysLog()
    @ApiOperation(value = "插入数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "DirEntity", value = "目录实体类", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "")
    })
    @PostMapping(value = "/insertDir", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insertDir(@RequestBody DirEntity dirEntity) {
        try {
            int count = dirService.insertDir(dirEntity);
 
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "插入多条数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "DirEntity", value = "目录实体类", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "")
    })
    @PostMapping(value = "/insertDirs", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insertDirs(@RequestBody List<DirEntity> dirEntity) {
        try {
            int count = dirService.insertDirs(dirEntity);
 
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "删除一条数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/deleteDir")
    public ResponseMsg<Integer> deleteDir(int id) {
        try {
            int count = dirService.deleteDir(id);
 
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "删除多条数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "DirEntity", value = "目录实体类", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "")
    })
    @GetMapping(value = "/deleteDirs")
    public ResponseMsg<Integer> deleteDirs(@RequestParam List<Integer> ids) {
        try {
            if (ids == null || ids.isEmpty()) {
                return fail("id数组不能为空", -1);
            }
 
            int count = dirService.deleteDirs(ids);
 
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "更新一条数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dirEntity", value = "主键ID集合", dataType = "DictEntity", paramType = "body", example = "")
    })
    @ResponseBody
    @PostMapping(value = "/updateDir", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updateDir(@RequestBody DirEntity dirEntity) {
        try {
            int count = dirService.updateDir(dirEntity);
 
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "更新多条数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "DirEntity", value = "主键ID集合", dataType = "DirEntity", paramType = "body", example = "")
    })
    @ResponseBody
    @PostMapping(value = "/updateDirs", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updateDirs(@RequestBody List<DirEntity> dirEntity) {
        try {
            int count = dirService.updateDirs(dirEntity);
 
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
 
 
 
 
    @SysLog()
    @ApiOperation(value = "根据ID查询数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectDir")
    public ResponseMsg<DirEntity> selectDir(int id) {
        try {
            DirEntity dirEntity = dirService.selectDir(id);
 
            return success(dirEntity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询所有数据")
    @GetMapping(value = "/selectDirAll")
    public ResponseMsg<List<DirEntity>> selectDirAll() {
        try {
            List<DirEntity> list = dirService.selectDirAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "递归查询数据")
    @GetMapping(value = "/selectDirRecursive")
    public ResponseMsg<List<DirEntity>> selectDirRecursive() {
        try {
            List<DirEntity> list = dirService.selectDirRecursive();
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
}