|
@@ -23,6 +23,7 @@ import com.community.commom.utils.AccountValidatorUtil;
|
23
|
23
|
import com.community.huiju.common.code.cache.AppkeyCache;
|
24
|
24
|
import com.community.huiju.service.IUserService;
|
25
|
25
|
import com.community.huiju.vo.UserVO;
|
|
26
|
+import com.google.common.collect.Lists;
|
26
|
27
|
import lombok.extern.slf4j.Slf4j;
|
27
|
28
|
import com.google.common.collect.Maps;
|
28
|
29
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -184,20 +185,24 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
184
|
185
|
|
185
|
186
|
IPage<User> pageInfo = userMapper.userList(page,loginName,userName,communityId);
|
186
|
187
|
List<User> userList = pageInfo.getRecords();
|
|
188
|
+ List<UserVO> userVOList = Lists.newArrayList();
|
187
|
189
|
for (User user:userList){
|
188
|
|
-// //查询当前所有角色
|
189
|
|
-// user.setRoleName(selectRole(user.getId()));
|
190
|
|
-// // 创建人
|
191
|
|
-// String createNmae=userMapper.selectByIdUserName(user.getCreateUser());
|
192
|
|
-// // 修改人
|
193
|
|
-// String updateNmae=userMapper.selectByIdUserName(user.getUpdateUser());
|
194
|
|
-//
|
195
|
|
-// user.setCreateNmae(createNmae);
|
196
|
|
-// user.setUpdateNmae(updateNmae);
|
|
190
|
+ UserVO userVO = new UserVO();
|
|
191
|
+ BeanUtils.copyProperties(user, userVO);
|
|
192
|
+ //查询当前所有角色
|
|
193
|
+ userVO.setRoleName(selectRole(user.getId()));
|
|
194
|
+ // 创建人
|
|
195
|
+ String createNmae=userMapper.selectByIdUserName(user.getCreateUser());
|
|
196
|
+ // 修改人
|
|
197
|
+ String updateNmae=userMapper.selectByIdUserName(user.getUpdateUser());
|
|
198
|
+
|
|
199
|
+ userVO.setCreateNmae(createNmae);
|
|
200
|
+ userVO.setUpdateNmae(updateNmae);
|
|
201
|
+ userVOList.add(userVO);
|
197
|
202
|
}
|
198
|
203
|
|
199
|
204
|
Map<String, Object> map = Maps.newHashMap();
|
200
|
|
- map.put("list", userList);
|
|
205
|
+ map.put("list", userVOList);
|
201
|
206
|
map.put("total", pageInfo.getTotal());
|
202
|
207
|
map.put("pageNum", pageInfo.getCurrent());
|
203
|
208
|
map.put("pageSize", pageInfo.getSize());
|
|
@@ -212,6 +217,21 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
212
|
217
|
User user= new User();
|
213
|
218
|
|
214
|
219
|
String loginName= object.getString("loginName");
|
|
220
|
+ if (!AccountValidatorUtil.isPhone(loginName)){
|
|
221
|
+ response.addError("请输入正确的手机号!");
|
|
222
|
+ return response;
|
|
223
|
+ }
|
|
224
|
+
|
|
225
|
+ QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
|
226
|
+ queryWrapper.lambda().eq(User::getLoginName,loginName);
|
|
227
|
+ queryWrapper.lambda().eq(User::getCommunityId,communityId);
|
|
228
|
+ List<User> userLoginName= userMapper.selectList(queryWrapper);
|
|
229
|
+ for (User us:userLoginName) {
|
|
230
|
+ if (null != us.getLoginName()) {
|
|
231
|
+ response.addError("您输入的手机号已存在");
|
|
232
|
+ return response;
|
|
233
|
+ }
|
|
234
|
+ }
|
215
|
235
|
String userName = object.getString("userName");
|
216
|
236
|
JSONArray List = object.getJSONArray("menuArray");
|
217
|
237
|
Integer[] roleIdArray = List.toArray(new Integer[]{});
|
|
@@ -223,12 +243,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
223
|
243
|
user.setStatus("1");;
|
224
|
244
|
user.setCreateUser(userID);
|
225
|
245
|
user.setCreateDate(LocalDateTime.now());
|
|
246
|
+ user.setCommunityId(communityId);
|
226
|
247
|
userMapper.insert(user);
|
227
|
248
|
//维护小区
|
228
|
|
- TpUserCommunity tpUserCommunity= new TpUserCommunity();
|
229
|
|
- tpUserCommunity.setCommunityId(communityId);
|
230
|
|
- tpUserCommunity.setId(user.getId());
|
231
|
|
- tpUserCommunityMapper.insert(tpUserCommunity);
|
|
249
|
+// TpUserCommunity tpUserCommunity= new TpUserCommunity();
|
|
250
|
+// tpUserCommunity.setCommunityId(communityId);
|
|
251
|
+// tpUserCommunity.setTpUserId(user.getId());
|
|
252
|
+// tpUserCommunityMapper.insert(tpUserCommunity);
|
232
|
253
|
//会对应多个角色
|
233
|
254
|
for (Integer roleID:roleIdArray ){
|
234
|
255
|
SysUserRole toSysUserRole= new SysUserRole();
|
|
@@ -241,12 +262,31 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
241
|
262
|
}
|
242
|
263
|
|
243
|
264
|
@Override
|
244
|
|
- public ResponseBean upDate(String parameter, Integer userID) {
|
|
265
|
+ public ResponseBean upDate(String parameter, Integer userID,Integer communityId) {
|
245
|
266
|
ResponseBean response = new ResponseBean<>();
|
246
|
267
|
JSONObject object = JSONObject.parseObject(parameter);
|
247
|
268
|
User user = new User();
|
248
|
269
|
|
249
|
270
|
String loginName = object.getString("loginName");
|
|
271
|
+ if (!AccountValidatorUtil.isPhone(loginName)){
|
|
272
|
+ response.addError("请输入正确的手机号!");
|
|
273
|
+ return response;
|
|
274
|
+ }
|
|
275
|
+
|
|
276
|
+ QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
|
277
|
+ queryWrapper.lambda().eq(User::getLoginName,loginName);
|
|
278
|
+ queryWrapper.lambda().eq(User::getCommunityId,communityId);
|
|
279
|
+ List<User> userLoginName= userMapper.selectList(queryWrapper);
|
|
280
|
+ for (User us:userLoginName) {
|
|
281
|
+ // 修改手机号码时排除自身
|
|
282
|
+ if (null != us.getLoginName()&&loginName.equals(us.getLoginName())){
|
|
283
|
+ break;
|
|
284
|
+ }
|
|
285
|
+ if (null != us.getLoginName()) {
|
|
286
|
+ response.addError("您输入的手机号已存在");
|
|
287
|
+ return response;
|
|
288
|
+ }
|
|
289
|
+ }
|
250
|
290
|
Integer ID= object.getInteger("id");
|
251
|
291
|
String userName = object.getString("userName");
|
252
|
292
|
JSONArray List = object.getJSONArray("menuArray");
|
|
@@ -264,7 +304,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
264
|
304
|
|
265
|
305
|
//会对应多个角色
|
266
|
306
|
if (null!=List) {
|
267
|
|
- sysUserRoleMapper.deleteById(ID);
|
|
307
|
+ QueryWrapper<SysUserRole> queryWrapperRole = new QueryWrapper<>();
|
|
308
|
+ queryWrapperRole.lambda().eq(SysUserRole::getUserId,ID);
|
|
309
|
+ sysUserRoleMapper.delete(queryWrapperRole);
|
268
|
310
|
for (Integer roleID : roleIDArray) {
|
269
|
311
|
SysUserRole sysUserRole = new SysUserRole();
|
270
|
312
|
sysUserRole.setUserId(user.getId());
|
|
@@ -282,9 +324,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
282
|
324
|
JSONObject object= JSONObject.parseObject(parameter);
|
283
|
325
|
Integer ID= object.getInteger("id");
|
284
|
326
|
List<String> list=new ArrayList<String>();
|
285
|
|
- List<User> userList=userMapper.selectUser(ID);
|
286
|
|
- for (User user:userList){
|
287
|
|
- // list.add(user.getRoleId());
|
|
327
|
+ List<UserVO> userList=userMapper.selectUser(ID);
|
|
328
|
+ for (UserVO userVO:userList){
|
|
329
|
+ list.add(userVO.getRoleId());
|
288
|
330
|
}
|
289
|
331
|
HashMap map= new HashMap<>();
|
290
|
332
|
map.put("userList",userList);
|
|
@@ -313,6 +355,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
313
|
355
|
response.addSuccess("成功");
|
314
|
356
|
return response;
|
315
|
357
|
}
|
|
358
|
+
|
316
|
359
|
|
317
|
360
|
/**
|
318
|
361
|
* 获取当前用户的权限列表
|
|
@@ -329,15 +372,31 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
329
|
372
|
return responseBean;
|
330
|
373
|
}
|
331
|
374
|
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+ @Override
|
|
378
|
+ public ResponseBean allUserRole(String parameter, Integer id, Integer communityId) {
|
|
379
|
+ ResponseBean response = new ResponseBean<>();
|
|
380
|
+ List<TpSysRole> tpSysRole=tpSysRoleMapper.allUserRole(communityId);
|
|
381
|
+ response.addSuccess(tpSysRole);
|
|
382
|
+ return response;
|
|
383
|
+ }
|
|
384
|
+
|
|
385
|
+
|
332
|
386
|
//查询多个角色转换为字符串
|
333
|
387
|
public String selectRole(Integer id) {
|
334
|
|
- List<User> toUser= userMapper.selectRole(id);
|
|
388
|
+ List<UserVO> toUser= userMapper.selectRole(id);
|
|
389
|
+
|
335
|
390
|
List<String> list=new ArrayList<String>();
|
336
|
|
- for (User user:toUser){
|
337
|
|
- // list.add(user.getRoleName());
|
338
|
|
- }
|
|
391
|
+
|
|
392
|
+ for (UserVO userVo : toUser) {
|
|
393
|
+ if (userVo !=null &&userVo.getRoleName() != null && !userVo.getRoleName().equals("")) {
|
|
394
|
+ list.add(userVo.getRoleName());
|
|
395
|
+ }
|
|
396
|
+ }
|
|
397
|
+
|
339
|
398
|
String result = "";
|
340
|
|
- if (list != null && list.size() > 0) {
|
|
399
|
+ if ( null!=list && list.size() > 0) {
|
341
|
400
|
for (String item : list) {
|
342
|
401
|
// 把列表中的每条数据用逗号分割开来,然后拼接成字符串
|
343
|
402
|
result += item + ",";
|