|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+package api.controller.system;
|
|
|
2
|
+
|
|
|
3
|
+import api.entity.database.system.WorkOrderType;
|
|
|
4
|
+import api.entity.view.system.WorkOrderTypeView;
|
|
|
5
|
+import api.util.annotation.Anonymous;
|
|
|
6
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
7
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
8
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
9
|
+import api.controller.BaseController;
|
|
|
10
|
+import api.entity.database.system.MainProblem;
|
|
|
11
|
+import api.entity.input.PageInput;
|
|
|
12
|
+import api.model.AjaxResult;
|
|
|
13
|
+import api.service.system.IMainProblemService;
|
|
|
14
|
+import api.util.annotation.Log;
|
|
|
15
|
+import api.util.enums.BusinessType;
|
|
|
16
|
+import api.util.helper.StringHelper;
|
|
|
17
|
+import io.swagger.annotations.Api;
|
|
|
18
|
+import io.swagger.annotations.ApiOperation;
|
|
|
19
|
+import lombok.var;
|
|
|
20
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
21
|
+import org.springframework.web.bind.annotation.*;
|
|
|
22
|
+import java.util.Arrays;
|
|
|
23
|
+import java.util.Date;
|
|
|
24
|
+import java.util.List;
|
|
|
25
|
+
|
|
|
26
|
+@Api(value = "main_problem",tags = "main_problem")
|
|
|
27
|
+@RestController
|
|
|
28
|
+@RequestMapping("/system/mainproblem")
|
|
|
29
|
+public class MainProblemController extends BaseController {
|
|
|
30
|
+ @Autowired
|
|
|
31
|
+ private IMainProblemService mainproblemService;
|
|
|
32
|
+
|
|
|
33
|
+ @ApiOperation("列表")
|
|
|
34
|
+ @Log(title = "查询main_problem列表",businessType = BusinessType.QUERY)
|
|
|
35
|
+ @GetMapping
|
|
|
36
|
+ public AjaxResult getList(MainProblem input, PageInput pageInput) {
|
|
|
37
|
+ LambdaQueryWrapper<MainProblem> qw = new LambdaQueryWrapper();
|
|
|
38
|
+ qw.eq(input.getId() != null && input.getId() > 0, MainProblem::getId, input.getId());
|
|
|
39
|
+ qw.eq(input.getParentId() != null && input.getParentId() > 0, MainProblem::getParentId, input.getParentId());
|
|
|
40
|
+ qw.like(!StringHelper.isEmpty(input.getTypeCode()), MainProblem::getTypeCode, input.getTypeCode());
|
|
|
41
|
+ qw.like(!StringHelper.isEmpty(input.getAncestors()), MainProblem::getAncestors, input.getAncestors());
|
|
|
42
|
+ qw.like(!StringHelper.isEmpty(input.getTypeName()), MainProblem::getTypeName, input.getTypeName());
|
|
|
43
|
+ qw.eq(input.getTypeOrder() != null && input.getTypeOrder() > 0, MainProblem::getTypeOrder, input.getTypeOrder());
|
|
|
44
|
+ qw.eq(input.getCreateTime() != null , MainProblem::getCreateTime, input.getCreateTime());
|
|
|
45
|
+ qw.eq(input.getIsDelete() != null && input.getIsDelete() > 0, MainProblem::getIsDelete, input.getIsDelete());
|
|
|
46
|
+ qw.like(!StringHelper.isEmpty(input.getCreateBy()), MainProblem::getCreateBy, input.getCreateBy());
|
|
|
47
|
+ qw.eq(input.getCategory() != null && input.getCategory() > 0, MainProblem::getCategory, input.getCategory());
|
|
|
48
|
+ qw.like(!StringHelper.isEmpty(input.getSetButton()), MainProblem::getSetButton, input.getSetButton());
|
|
|
49
|
+ qw.like(!StringHelper.isEmpty(input.getAllTypeName()), MainProblem::getAllTypeName, input.getAllTypeName());
|
|
|
50
|
+ Page<MainProblem> page = GetPage(pageInput);
|
|
|
51
|
+ if (page != null) {
|
|
|
52
|
+ IPage<MainProblem> iPage = mainproblemService.getListPage(page, qw);
|
|
|
53
|
+ return Success("成功", iPage.getRecords(), iPage.getTotal());
|
|
|
54
|
+ } else {
|
|
|
55
|
+ return Success("成功", mainproblemService.getList(qw));
|
|
|
56
|
+ }
|
|
|
57
|
+ }
|
|
|
58
|
+
|
|
|
59
|
+ @ApiOperation("详情")
|
|
|
60
|
+ @Log(title = "查询main_problem详情",businessType = BusinessType.QUERY)
|
|
|
61
|
+ @GetMapping("/{id}")
|
|
|
62
|
+ public AjaxResult getInfo(@PathVariable long id) {
|
|
|
63
|
+ return Success("成功", mainproblemService.getEntity(id));
|
|
|
64
|
+ }
|
|
|
65
|
+
|
|
|
66
|
+ @ApiOperation("新增")
|
|
|
67
|
+ @Log(title = "新增main_problem",businessType = BusinessType.INSERT)
|
|
|
68
|
+ @PostMapping
|
|
|
69
|
+ public AjaxResult add(@RequestBody MainProblem input) {
|
|
|
70
|
+// boolean result = mainproblemService.insert(input);
|
|
|
71
|
+// if (result) {
|
|
|
72
|
+// return Success("成功");
|
|
|
73
|
+// } else {
|
|
|
74
|
+// return Error("新增失败");
|
|
|
75
|
+// }
|
|
|
76
|
+ Date currentDate = new Date(System.currentTimeMillis());
|
|
|
77
|
+ if (StringHelper.isEmpty(input.getTypeName()))
|
|
|
78
|
+ return Error("请输入名称");
|
|
|
79
|
+ if (StringHelper.isEmpty(input.getTypeCode()))
|
|
|
80
|
+ return Error("请输入类型编码");
|
|
|
81
|
+ if (input.getCategory() == null )
|
|
|
82
|
+ {
|
|
|
83
|
+ input.setCategory(0L);
|
|
|
84
|
+ }
|
|
|
85
|
+ if (input.getParentId()!=null&&input.getParentId()>0)
|
|
|
86
|
+ {
|
|
|
87
|
+ var model=mainproblemService.getEntity(input.getParentId());
|
|
|
88
|
+ if (model!=null)
|
|
|
89
|
+ {
|
|
|
90
|
+ input.setAncestors(model.getAncestors()+","+model.getId());
|
|
|
91
|
+
|
|
|
92
|
+ input.setAllTypeName(model.getAllTypeName()+"/"+input.getTypeName());
|
|
|
93
|
+ }
|
|
|
94
|
+ else
|
|
|
95
|
+ {
|
|
|
96
|
+ return Error("该父级分类不存在");
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+ else
|
|
|
100
|
+ {
|
|
|
101
|
+ input.setAllTypeName(input.getTypeName());
|
|
|
102
|
+ input.setAncestors("0");
|
|
|
103
|
+ input.setParentId(0L);
|
|
|
104
|
+ }
|
|
|
105
|
+
|
|
|
106
|
+ input.setIsDelete(0L);
|
|
|
107
|
+ input.setCreateTime(currentDate);
|
|
|
108
|
+ input.setCreateBy(CurrentUser().getUserId().toString());
|
|
|
109
|
+ boolean result = mainproblemService.insert(input);
|
|
|
110
|
+ if (result) {
|
|
|
111
|
+ return Success("成功");
|
|
|
112
|
+ } else {
|
|
|
113
|
+ return Error("新增失败");
|
|
|
114
|
+ }
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ @ApiOperation("编辑")
|
|
|
118
|
+ @Log(title = "编辑main_problem",businessType = BusinessType.UPDATE)
|
|
|
119
|
+ @PutMapping
|
|
|
120
|
+ public AjaxResult edit(@RequestBody MainProblem input) {
|
|
|
121
|
+ boolean result = mainproblemService.update(input);
|
|
|
122
|
+ if (result) {
|
|
|
123
|
+ return Success("成功");
|
|
|
124
|
+ } else {
|
|
|
125
|
+ return Error("修改失败");
|
|
|
126
|
+ }
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ @ApiOperation("删除")
|
|
|
130
|
+ @Log(title = "删除main_problem",businessType = BusinessType.DELETE)
|
|
|
131
|
+ @DeleteMapping("/{ids}")
|
|
|
132
|
+ public AjaxResult delete(@PathVariable Long[] ids) {
|
|
|
133
|
+ boolean result = mainproblemService.delete(Arrays.asList(ids));
|
|
|
134
|
+ if (result) {
|
|
|
135
|
+ return Success("成功");
|
|
|
136
|
+ } else {
|
|
|
137
|
+ return Error("删除失败");
|
|
|
138
|
+ }
|
|
|
139
|
+ }
|
|
|
140
|
+ @GetMapping("/treeselect")
|
|
|
141
|
+ @Anonymous
|
|
|
142
|
+ public AjaxResult treeselect(MainProblem input) {
|
|
|
143
|
+ LambdaQueryWrapper<MainProblem> qw = new LambdaQueryWrapper<>();
|
|
|
144
|
+ qw.eq(MainProblem::getIsDelete, 0);
|
|
|
145
|
+ if (input.getCategory() != null )
|
|
|
146
|
+ {
|
|
|
147
|
+ qw.eq(MainProblem::getCategory, input.getCategory());
|
|
|
148
|
+ }
|
|
|
149
|
+ else
|
|
|
150
|
+ {
|
|
|
151
|
+ qw.eq(MainProblem::getCategory, 0);
|
|
|
152
|
+ }
|
|
|
153
|
+
|
|
|
154
|
+ qw.orderByDesc(MainProblem::getTypeOrder);
|
|
|
155
|
+ List<MainProblem> menus = mainproblemService.getList(qw);
|
|
|
156
|
+ return Success("获取菜单下拉树列表成功", mainproblemService.buildMenuTreeSelect(menus));
|
|
|
157
|
+ }
|
|
|
158
|
+ @GetMapping("/getTreeselectById")
|
|
|
159
|
+ public AjaxResult getTreeselectById(long id) {
|
|
|
160
|
+
|
|
|
161
|
+ LambdaQueryWrapper<MainProblem> qw = new LambdaQueryWrapper<>();
|
|
|
162
|
+ qw.eq(MainProblem::getIsDelete, 0);
|
|
|
163
|
+ qw.like(MainProblem::getAncestors,','+String.valueOf(id));
|
|
|
164
|
+ qw.orderByDesc(MainProblem::getTypeOrder);
|
|
|
165
|
+ List<MainProblem> menus = mainproblemService.getList(qw);
|
|
|
166
|
+ return Success("获取菜单下拉树列表成功", mainproblemService.buildMenuTreeSelect(menus));
|
|
|
167
|
+ }
|
|
|
168
|
+ @GetMapping("/GetWorkroderTypeView")
|
|
|
169
|
+ public AjaxResult GetWorkroderTypeView(long id) {
|
|
|
170
|
+
|
|
|
171
|
+ List<MainProblem> WorkroderType = mainproblemService.selectMainProblem(id);
|
|
|
172
|
+ return Success("获取菜单下拉树列表成功",WorkroderType);
|
|
|
173
|
+ }
|
|
|
174
|
+
|
|
|
175
|
+}
|