|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+package api.controller.system;
|
|
|
2
|
+
|
|
|
3
|
+import api.entity.database.system.Menu;
|
|
|
4
|
+import api.entity.database.system.WorkroderType;
|
|
|
5
|
+import api.service.system.IWorkroderTypeService;
|
|
|
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
|
+
|
|
|
11
|
+import api.entity.input.PageInput;
|
|
|
12
|
+import api.model.AjaxResult;
|
|
|
13
|
+
|
|
|
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 = "工单类型表",tags = "工单类型表")
|
|
|
27
|
+@RestController
|
|
|
28
|
+@RequestMapping("/worker/type")
|
|
|
29
|
+public class WorkroderTypeController extends BaseController {
|
|
|
30
|
+ @Autowired
|
|
|
31
|
+ private IWorkroderTypeService workrodertypeService;
|
|
|
32
|
+
|
|
|
33
|
+ @ApiOperation("列表")
|
|
|
34
|
+ @Log(title = "查询工单类型表列表",businessType = BusinessType.QUERY)
|
|
|
35
|
+ @GetMapping
|
|
|
36
|
+ public AjaxResult getList(WorkroderType input, PageInput pageInput) {
|
|
|
37
|
+ LambdaQueryWrapper<WorkroderType> qw = new LambdaQueryWrapper<>();
|
|
|
38
|
+ qw.eq(input.getParentId() != null && input.getParentId() > 0, WorkroderType::getParentId, input.getParentId());
|
|
|
39
|
+ qw.like(!StringHelper.isEmpty(input.getTypeCode()), WorkroderType::getTypeCode, input.getTypeCode());
|
|
|
40
|
+ qw.like(!StringHelper.isEmpty(input.getAncestors()), WorkroderType::getAncestors, input.getAncestors());
|
|
|
41
|
+ qw.like(!StringHelper.isEmpty(input.getTypeName()), WorkroderType::getTypeName, input.getTypeName());
|
|
|
42
|
+ qw.eq(input.getTypeOrder() != null && input.getTypeOrder() > 0, WorkroderType::getTypeOrder, input.getTypeOrder());
|
|
|
43
|
+ qw.eq(input.getCrateTime() != null , WorkroderType::getCrateTime, input.getCrateTime());
|
|
|
44
|
+ qw.eq(WorkroderType::getIsDelete, 0);
|
|
|
45
|
+ qw.like(!StringHelper.isEmpty(input.getCreateBy()), WorkroderType::getCreateBy, input.getCreateBy());
|
|
|
46
|
+ if (pageInput.getPageNum() == null) {
|
|
|
47
|
+ pageInput.setPageNum(1);
|
|
|
48
|
+ }
|
|
|
49
|
+ if (pageInput.getPageSize() == null) {
|
|
|
50
|
+ pageInput.setPageNum(10);
|
|
|
51
|
+ }
|
|
|
52
|
+ Page<WorkroderType> page = GetPage(pageInput);
|
|
|
53
|
+ if (page != null) {
|
|
|
54
|
+ IPage<WorkroderType> iPage = workrodertypeService.getListPage(page, qw);
|
|
|
55
|
+ return Success("成功", iPage.getRecords(), iPage.getTotal());
|
|
|
56
|
+ } else {
|
|
|
57
|
+ return Success("成功", workrodertypeService.getList(qw));
|
|
|
58
|
+ }
|
|
|
59
|
+ }
|
|
|
60
|
+
|
|
|
61
|
+ @ApiOperation("详情")
|
|
|
62
|
+ @Log(title = "查询工单类型详情",businessType = BusinessType.QUERY)
|
|
|
63
|
+ @GetMapping("/{id}")
|
|
|
64
|
+ public AjaxResult getInfo(@PathVariable long id) {
|
|
|
65
|
+ return Success("成功", workrodertypeService.getEntity(id));
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
|
68
|
+ @ApiOperation("新增")
|
|
|
69
|
+ @Log(title = "新增工单类型",businessType = BusinessType.INSERT)
|
|
|
70
|
+ @PostMapping
|
|
|
71
|
+ public AjaxResult add(@RequestBody WorkroderType input) {
|
|
|
72
|
+ Date currentDate = new Date(System.currentTimeMillis());
|
|
|
73
|
+ if (input.getParentId()>0)
|
|
|
74
|
+ {
|
|
|
75
|
+ var model=workrodertypeService.getEntity(input.getParentId());
|
|
|
76
|
+ if (model!=null)
|
|
|
77
|
+ {
|
|
|
78
|
+ input.setAncestors(model.getAncestors()+","+model.getId());
|
|
|
79
|
+ }
|
|
|
80
|
+ else
|
|
|
81
|
+ {
|
|
|
82
|
+ return Error("该父级分类不存在");
|
|
|
83
|
+ }
|
|
|
84
|
+ }
|
|
|
85
|
+ else
|
|
|
86
|
+ {
|
|
|
87
|
+ input.setAncestors("0");
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ input.setIsDelete(0L);
|
|
|
91
|
+ input.setCrateTime(currentDate);
|
|
|
92
|
+ input.setCreateBy(CurrentUser().getUserId().toString());
|
|
|
93
|
+ boolean result = workrodertypeService.insert(input);
|
|
|
94
|
+ if (result) {
|
|
|
95
|
+ return Success("成功");
|
|
|
96
|
+ } else {
|
|
|
97
|
+ return Error("新增失败");
|
|
|
98
|
+ }
|
|
|
99
|
+ }
|
|
|
100
|
+
|
|
|
101
|
+ @ApiOperation("编辑")
|
|
|
102
|
+ @Log(title = "编辑工单类型",businessType = BusinessType.UPDATE)
|
|
|
103
|
+ @PutMapping
|
|
|
104
|
+ public AjaxResult edit(@RequestBody WorkroderType input) {
|
|
|
105
|
+ boolean result = workrodertypeService.update(input);
|
|
|
106
|
+ if (result) {
|
|
|
107
|
+ return Success("成功");
|
|
|
108
|
+ } else {
|
|
|
109
|
+ return Error("修改失败");
|
|
|
110
|
+ }
|
|
|
111
|
+ }
|
|
|
112
|
+
|
|
|
113
|
+ @ApiOperation("删除")
|
|
|
114
|
+ @Log(title = "删除工单类型",businessType = BusinessType.DELETE)
|
|
|
115
|
+ @DeleteMapping("/{ids}")
|
|
|
116
|
+ public AjaxResult delete(@PathVariable Long[] ids) {
|
|
|
117
|
+ StringBuilder error= new StringBuilder();
|
|
|
118
|
+ for (int i=0;i<ids .length;i++)
|
|
|
119
|
+ {
|
|
|
120
|
+ var Type=workrodertypeService.getEntity(ids[i] );
|
|
|
121
|
+ if (Type!=null)
|
|
|
122
|
+ {
|
|
|
123
|
+ Type.setIsDelete(1L);
|
|
|
124
|
+ boolean result = workrodertypeService.update(Type);
|
|
|
125
|
+ if (!result)
|
|
|
126
|
+ {
|
|
|
127
|
+ error.append(Type.getTypeName()).append("删除失败;");
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+ else
|
|
|
131
|
+ {
|
|
|
132
|
+ error.append("第").append(i).append("行删除失败;");
|
|
|
133
|
+ }
|
|
|
134
|
+ }
|
|
|
135
|
+ if (error.toString().equals("")) {
|
|
|
136
|
+ return Success("成功");
|
|
|
137
|
+ } else {
|
|
|
138
|
+ return Error(error.toString());
|
|
|
139
|
+ }
|
|
|
140
|
+ }
|
|
|
141
|
+ @GetMapping("/treeselect")
|
|
|
142
|
+ public AjaxResult treeselect(Menu menu) {
|
|
|
143
|
+ LambdaQueryWrapper<WorkroderType> qw = new LambdaQueryWrapper<>();
|
|
|
144
|
+ qw.eq(WorkroderType::getIsDelete, 0);
|
|
|
145
|
+ List<WorkroderType> menus = workrodertypeService.getList(qw);
|
|
|
146
|
+ return Success("获取菜单下拉树列表成功", workrodertypeService.buildMenuTreeSelect(menus));
|
|
|
147
|
+ }
|
|
|
148
|
+
|
|
|
149
|
+
|
|
|
150
|
+
|
|
|
151
|
+
|
|
|
152
|
+}
|
|
|
153
|
+
|