|
@@ -174,9 +174,12 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
|
|
|
//删除时需要同时删除用户部门关联表和用户角色关联表和用户岗位关系表数据。
|
|
|
this.removeBatchByIds(ids);
|
|
|
//根据用户ids去缓存中查询到对应的三个表的数据
|
|
|
- List<UserDeptRelation> userDeptRelationList = redisUtil.get(GlobalConstant.USER_DEPT_RELATION_CACHE_KEY, new TypeReference<List<UserDeptRelation>>() {});
|
|
|
- List<UserPostRelation> userPostRelationList = redisUtil.get(GlobalConstant.USER_POST_RELATION_CACHE_KEY, new TypeReference<List<UserPostRelation>>() {});
|
|
|
- List<UserRoleRelation> userRoleRelationList = redisUtil.get(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, new TypeReference<List<UserRoleRelation>>() {});
|
|
|
+ List<UserDeptRelation> userDeptRelationList = redisUtil.get(GlobalConstant.USER_DEPT_RELATION_CACHE_KEY, new TypeReference<List<UserDeptRelation>>() {
|
|
|
+ });
|
|
|
+ List<UserPostRelation> userPostRelationList = redisUtil.get(GlobalConstant.USER_POST_RELATION_CACHE_KEY, new TypeReference<List<UserPostRelation>>() {
|
|
|
+ });
|
|
|
+ List<UserRoleRelation> userRoleRelationList = redisUtil.get(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, new TypeReference<List<UserRoleRelation>>() {
|
|
|
+ });
|
|
|
//拿用户ids进行过滤,如果存在,就删除
|
|
|
List<Long> deptRelationIds = userDeptRelationList.stream().filter(u -> ids.contains(u.getUserId())).map(UserDeptRelation::getId).collect(Collectors.toList());
|
|
|
List<Long> postRelationIds = userPostRelationList.stream().filter(u -> ids.contains(u.getUserId())).map(UserPostRelation::getId).collect(Collectors.toList());
|
|
@@ -235,6 +238,38 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
|
|
|
return updateById(user);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean bindOpenid(BindOpenidDto dto) {
|
|
|
+ User user = this.getOne(Wrappers.<User>query().lambda().select(User::getId, User::getOpenId, User::getUnionId).eq(User::getId, dto.getId()), false);
|
|
|
+ if (user != null) {
|
|
|
+ if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
|
+ throw new MyException("该用户已经绑定微信");
|
|
|
+ }
|
|
|
+ long count = this.count(Wrappers.<User>query().lambda().eq(User::getOpenId, dto.getOpenid()));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new MyException("该用户已经绑定微信!");
|
|
|
+ }
|
|
|
+ User updateUser = new User();
|
|
|
+ updateUser.setId(dto.getId());
|
|
|
+ updateUser.setOpenId(dto.getOpenid());
|
|
|
+ boolean result = this.updateById(updateUser);
|
|
|
+ // 用户绑定微信后,更新缓存
|
|
|
+ if (result) {
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ List<User> list = list();
|
|
|
+ redisUtil.set(GlobalConstant.USER_CACHE_KEY, list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ } else {
|
|
|
+ long count = this.count(Wrappers.<User>query().lambda().eq(User::getOpenId, dto.getOpenid()));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new MyException("该用户已经绑定微信!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new MyException("该用户不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<UserInfoVo> getUsersInfo(String ids) {
|
|
|
|