|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+package api.controller.system;
|
|
|
2
|
+
|
|
|
3
|
+import api.controller.BaseController;
|
|
|
4
|
+import api.entity.database.system.User;
|
|
|
5
|
+import api.entity.database.system.UserExtension;
|
|
|
6
|
+import api.entity.input.PageInput;
|
|
|
7
|
+import api.model.AjaxResult;
|
|
|
8
|
+import api.service.system.IUserExtensionService;
|
|
|
9
|
+import api.service.system.IUserService;
|
|
|
10
|
+import api.util.annotation.Log;
|
|
|
11
|
+import api.util.enums.BusinessType;
|
|
|
12
|
+import api.util.helper.StringHelper;
|
|
|
13
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
14
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
15
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
16
|
+import io.swagger.annotations.Api;
|
|
|
17
|
+import io.swagger.annotations.ApiOperation;
|
|
|
18
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
19
|
+import org.springframework.web.bind.annotation.*;
|
|
|
20
|
+
|
|
|
21
|
+import java.util.Arrays;
|
|
|
22
|
+
|
|
|
23
|
+@Api(value = "分机管理表",tags = "分机管理表")
|
|
|
24
|
+@RestController
|
|
|
25
|
+@RequestMapping("/UserExtension/userextension")
|
|
|
26
|
+public class UserExtensionController extends BaseController {
|
|
|
27
|
+ @Autowired
|
|
|
28
|
+ private IUserExtensionService userextensionService;
|
|
|
29
|
+ @Autowired
|
|
|
30
|
+ private IUserService userService;
|
|
|
31
|
+
|
|
|
32
|
+ @ApiOperation("列表")
|
|
|
33
|
+ @Log(title = "查询sys_user_extension列表",businessType = BusinessType.QUERY)
|
|
|
34
|
+ @GetMapping
|
|
|
35
|
+ public AjaxResult getList(UserExtension input, PageInput pageInput) {
|
|
|
36
|
+ LambdaQueryWrapper<UserExtension> qw = new LambdaQueryWrapper<>();
|
|
|
37
|
+ qw.like(!StringHelper.isEmpty(input.getUsercode()), UserExtension::getUsercode, input.getUsercode());
|
|
|
38
|
+ qw.like(!StringHelper.isEmpty(input.getExtension()), UserExtension::getExtension, input.getExtension());
|
|
|
39
|
+ Page<UserExtension> page = GetPage(pageInput);
|
|
|
40
|
+ if (page != null) {
|
|
|
41
|
+ IPage<UserExtension> iPage = userextensionService.getListPage(page, qw);
|
|
|
42
|
+ return Success("成功", iPage.getRecords(), iPage.getTotal());
|
|
|
43
|
+ } else {
|
|
|
44
|
+ return Success("成功", userextensionService.getList(qw));
|
|
|
45
|
+ }
|
|
|
46
|
+ }
|
|
|
47
|
+
|
|
|
48
|
+ @ApiOperation("详情")
|
|
|
49
|
+ @Log(title = "查询sys_user_extension详情",businessType = BusinessType.QUERY)
|
|
|
50
|
+ @GetMapping("/{id}")
|
|
|
51
|
+ public AjaxResult getInfo(@PathVariable long id) {
|
|
|
52
|
+ return Success("成功", userextensionService.getEntity(id));
|
|
|
53
|
+ }
|
|
|
54
|
+
|
|
|
55
|
+ @ApiOperation("新增")
|
|
|
56
|
+ @Log(title = "新增sys_user_extension",businessType = BusinessType.INSERT)
|
|
|
57
|
+ @PostMapping
|
|
|
58
|
+ public AjaxResult add(@RequestBody UserExtension input) {
|
|
|
59
|
+ if( input.getUsercode().isEmpty())
|
|
|
60
|
+ {
|
|
|
61
|
+ return Error("请输入工号");
|
|
|
62
|
+ }
|
|
|
63
|
+ if( input.getExtension().isEmpty())
|
|
|
64
|
+ {
|
|
|
65
|
+ return Error("请输入分机号");
|
|
|
66
|
+ }
|
|
|
67
|
+ if (!userextensionService.checkAddExtensionUnique(input))
|
|
|
68
|
+ {
|
|
|
69
|
+ return Error("该用户或已分配分级号该分机号已分配用户");
|
|
|
70
|
+ }
|
|
|
71
|
+ LambdaQueryWrapper<User> qw = new LambdaQueryWrapper<>();
|
|
|
72
|
+ qw.eq(User::getUserName, input.getUsercode()).eq(User::getDelFlag, "0");
|
|
|
73
|
+ User entity = userService.getEntity(qw);
|
|
|
74
|
+ if(entity==null)
|
|
|
75
|
+ {
|
|
|
76
|
+ return Error("该用户不存在");
|
|
|
77
|
+ }
|
|
|
78
|
+ boolean result = userextensionService.insert(input);
|
|
|
79
|
+ if (result) {
|
|
|
80
|
+ return Success("成功");
|
|
|
81
|
+ } else {
|
|
|
82
|
+ return Error("新增失败");
|
|
|
83
|
+ }
|
|
|
84
|
+ }
|
|
|
85
|
+
|
|
|
86
|
+ @ApiOperation("编辑")
|
|
|
87
|
+ @Log(title = "编辑sys_user_extension",businessType = BusinessType.UPDATE)
|
|
|
88
|
+ @PutMapping
|
|
|
89
|
+ public AjaxResult edit(@RequestBody UserExtension input) {
|
|
|
90
|
+ if( input.getUsercode().isEmpty())
|
|
|
91
|
+ {
|
|
|
92
|
+ return Error("请输入工号");
|
|
|
93
|
+ }
|
|
|
94
|
+ if( input.getExtension().isEmpty())
|
|
|
95
|
+ {
|
|
|
96
|
+ return Error("请输入分机号");
|
|
|
97
|
+ }
|
|
|
98
|
+ if (!userextensionService.checkUpdateExtensionUnique(input))
|
|
|
99
|
+ {
|
|
|
100
|
+ return Error("该分级号已分配用户");
|
|
|
101
|
+ }
|
|
|
102
|
+ LambdaQueryWrapper<User> qw = new LambdaQueryWrapper<>();
|
|
|
103
|
+ qw.eq(User::getUserName, input.getUsercode()).eq(User::getDelFlag, "0");
|
|
|
104
|
+ User entity = userService.getEntity(qw);
|
|
|
105
|
+ if(entity==null)
|
|
|
106
|
+ {
|
|
|
107
|
+ return Error("该用户不存在");
|
|
|
108
|
+ }
|
|
|
109
|
+
|
|
|
110
|
+ boolean result = userextensionService.update(input);
|
|
|
111
|
+ if (result) {
|
|
|
112
|
+ return Success("成功");
|
|
|
113
|
+ } else {
|
|
|
114
|
+ return Error("修改失败");
|
|
|
115
|
+ }
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+ @ApiOperation("删除")
|
|
|
119
|
+ @Log(title = "删除sys_user_extension",businessType = BusinessType.DELETE)
|
|
|
120
|
+ @DeleteMapping("/{ids}")
|
|
|
121
|
+ public AjaxResult delete(@PathVariable Long[] ids) {
|
|
|
122
|
+ boolean result = userextensionService.delete(Arrays.asList(ids));
|
|
|
123
|
+ if (result) {
|
|
|
124
|
+ return Success("成功");
|
|
|
125
|
+ } else {
|
|
|
126
|
+ return Error("删除失败");
|
|
|
127
|
+ }
|
|
|
128
|
+ }
|
|
|
129
|
+
|
|
|
130
|
+}
|