EmergencyCommandLiaisonUserController.java
8.0 KB
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
package com.skua.modules.emergency.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.emergency.entity.EmergencyCommandLiaison;
import com.skua.modules.emergency.entity.EmergencyCommandLiaisonUser;
import com.skua.modules.emergency.service.IEmergencyCommandLiaisonService;
import com.skua.modules.emergency.service.IEmergencyCommandLiaisonUserService;
import com.skua.modules.emergency.vo.EmergencyCommandLiaisonUserVO;
import com.skua.modules.system.entity.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 应急联络图关联人员
* @author 11389
*/
@Slf4j
@Api(tags="应急联络图关联人员")
@RestController
@RequestMapping("/emergency/emergencyCommandLiaisonUser")
public class EmergencyCommandLiaisonUserController {
@Autowired
private IEmergencyCommandLiaisonUserService emergencyCommandLiaisonUserService;
@Autowired
private IEmergencyCommandLiaisonService emergencyCommandLiaisonService;
@AutoLog(value = "应急联络图关联人员-指定查询关联用户")
@ApiOperation(value="应急联络图关联人员-指定查询关联用户", notes="应急联络图关联人员-指定查询关联用户")
@GetMapping(value = "/queryUserList")
public Result<IPage<SysUser>> queryUserList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
Result<IPage<SysUser>> result = new Result<>();
Page<SysUser> page = new Page<>(pageNo, pageSize);
String emergencyId = req.getParameter("emergencyCommandLiaisonId");
String username = req.getParameter("username");
IPage<SysUser> pageList = emergencyCommandLiaisonUserService.getUserByEmergencyId(page,emergencyId,username);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
@AutoLog(value = "应急联络图关联人员-指定添加关联用户")
@ApiOperation(value="应急联络图关联人员-指定添加关联用户", notes="应急联络图关联人员-指定添加关联用户")
@PostMapping(value = "/addUser")
public Result<String> addUser(@RequestBody EmergencyCommandLiaisonUserVO emergencyCommandLiaisonUserVO) {
Result<String> result = new Result<>();
try {
String emergencyCommandLiaisonId = emergencyCommandLiaisonUserVO.getEmergencyCommandLiaisonId();
for(String sysUserId: emergencyCommandLiaisonUserVO.getUserIdList()) {
EmergencyCommandLiaisonUser user = new EmergencyCommandLiaisonUser(emergencyCommandLiaisonId,sysUserId);
QueryWrapper<EmergencyCommandLiaisonUser> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("emergency_command_liaison_id", emergencyCommandLiaisonId).eq("user_id",sysUserId);
EmergencyCommandLiaisonUser one = emergencyCommandLiaisonUserService.getOne(queryWrapper);
if(one==null){
emergencyCommandLiaisonUserService.save(user);
}
}
result.setMessage("添加成功!");
result.setSuccess(true);
return result;
}catch(Exception e) {
log.error(e.getMessage(), e);
result.setSuccess(false);
result.setMessage("出错了: " + e.getMessage());
return result;
}
}
@AutoLog(value = "应急联络图关联人员-指定删除关联用户")
@ApiOperation(value="应急联络图关联人员-指定删除关联用户", notes="应急联络图关联人员-指定删除关联用户")
@DeleteMapping(value = "/deleteUser")
public Result<EmergencyCommandLiaisonUser> deleteUser(@RequestParam(name="emergencyId") String emergencyId,
@RequestParam(name="userId",required=true) String userId
) {
Result<EmergencyCommandLiaisonUser> result = new Result<>();
try {
QueryWrapper<EmergencyCommandLiaisonUser> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("emergency_command_liaison_id", emergencyId).eq("user_id",userId);
emergencyCommandLiaisonUserService.remove(queryWrapper);
result.success("删除成功!");
}catch(Exception e) {
log.error(e.getMessage(), e);
result.error500("删除失败!");
}
return result;
}
@AutoLog(value = "应急联络图关联人员-指定批量删除关联用户")
@ApiOperation(value="应急联络图关联人员-指定批量删除关联用户", notes="应急联络图关联人员-指定批量删除关联用户")
@DeleteMapping(value = "/batchDeleteUser")
public Result<EmergencyCommandLiaisonUser> batchDeleteUser(@RequestParam(name="emergencyId") String emergencyId,
@RequestParam(name="userIds",required=true) String userIds) {
Result<EmergencyCommandLiaisonUser> result = new Result<>();
try {
QueryWrapper<EmergencyCommandLiaisonUser> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("emergency_command_liaison_id", emergencyId).in("user_id",Arrays.asList(userIds.split(",")));
emergencyCommandLiaisonUserService.remove(queryWrapper);
result.success("删除成功!");
}catch(Exception e) {
log.error(e.getMessage(), e);
result.error500("删除失败!");
}
return result;
}
@AutoLog(value = "应急联络图关联人员-指定添加关联用户")
@ApiOperation(value="应急联络图关联人员-指定添加关联用户", notes="应急联络图关联人员-指定添加关联用户")
@PostMapping(value = "/addUserNew")
public Result<String> addUserNew(@RequestBody EmergencyCommandLiaisonUserVO emergencyCommandLiaisonUserVO) {
Result<String> result = new Result<>();
try {
EmergencyCommandLiaison emergencyCommandLiaison = emergencyCommandLiaisonUserVO.getEmergencyCommandLiaison();
String parentId = emergencyCommandLiaison.getParentId();
if (StringUtils.isBlank(parentId)){
emergencyCommandLiaison.setParentId("");
}
emergencyCommandLiaisonService.save(emergencyCommandLiaison);
// String emergencyCommandLiaisonId = emergencyCommandLiaisonUserVO.getEmergencyCommandLiaisonId();
String emergencyCommandLiaisonId = emergencyCommandLiaison.getId();
for(String sysUserId: emergencyCommandLiaisonUserVO.getUserIdList()) {
EmergencyCommandLiaisonUser user = new EmergencyCommandLiaisonUser(emergencyCommandLiaisonId,sysUserId);
QueryWrapper<EmergencyCommandLiaisonUser> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("emergency_command_liaison_id", emergencyCommandLiaisonId).eq("user_id",sysUserId);
EmergencyCommandLiaisonUser one = emergencyCommandLiaisonUserService.getOne(queryWrapper);
if(one==null){
emergencyCommandLiaisonUserService.save(user);
}
}
result.setMessage("添加成功!");
result.setSuccess(true);
return result;
}catch(Exception e) {
log.error(e.getMessage(), e);
result.setSuccess(false);
result.setMessage("出错了: " + e.getMessage());
return result;
}
}
@AutoLog(value = "应急联络图关联人员-指定查询关联用户")
@ApiOperation(value="应急联络图关联人员-指定查询关联用户", notes="应急联络图关联人员-指定查询关联用户")
@GetMapping(value = "/queryUserListNew")
public Result<IPage<SysUser >> queryUserListNew(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
Result<IPage<SysUser >> result = new Result<>();
Page<SysUser > page = new Page<>(pageNo, pageSize);
//String emergencyId = req.getParameter("parentId");
String username = req.getParameter("username");
IPage<SysUser > pageList = emergencyCommandLiaisonUserService.userList(page,username);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
}