| | |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; |
| | | import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; |
| | | import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; |
| | | import cn.iocoder.yudao.module.system.mq.producer.user.AdminUserProducer; |
| | | import cn.iocoder.yudao.module.system.service.dept.DeptService; |
| | | import cn.iocoder.yudao.module.system.service.dept.PostService; |
| | | import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; |
| | |
| | | |
| | | @Resource |
| | | private ConfigApi configApi; |
| | | |
| | | @Resource |
| | | private AdminUserProducer adminUserProducer; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | userMapper.updateById(updateObj); |
| | | // 2.2 更新岗位 |
| | | updateUserPost(updateReqVO, updateObj); |
| | | // 2.3 昵称 / 头像变化时,发送消息供下游订阅(如 IM 模块推 FRIEND_INFO_UPDATED) |
| | | publishUserProfileUpdatedIfChanged(oldUser, updateReqVO.getNickname(), updateReqVO.getAvatar()); |
| | | |
| | | // 3. 记录操作日志上下文 |
| | | LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class)); |
| | |
| | | |
| | | @Override |
| | | public void updateUserProfile(Long id, UserProfileUpdateReqVO reqVO) { |
| | | // 校验正确性 |
| | | validateUserExists(id); |
| | | // 1. 校验正确性 |
| | | AdminUserDO oldUser = validateUserExists(id); |
| | | validateEmailUnique(id, reqVO.getEmail()); |
| | | validateMobileUnique(id, reqVO.getMobile()); |
| | | // 执行更新 |
| | | |
| | | // 2. 执行更新 |
| | | userMapper.updateById(BeanUtils.toBean(reqVO, AdminUserDO.class).setId(id)); |
| | | |
| | | // 3. 昵称 / 头像变化时,发送消息供下游订阅(如 IM 模块推 FRIEND_INFO_UPDATED) |
| | | publishUserProfileUpdatedIfChanged(oldUser, reqVO.getNickname(), reqVO.getAvatar()); |
| | | } |
| | | |
| | | /** |
| | | * 仅当 nickname 或 avatar 跟旧值不一致时,发送 AdminUserProfileUpdateMessage |
| | | */ |
| | | private void publishUserProfileUpdatedIfChanged(AdminUserDO oldUser, String newNickname, String newAvatar) { |
| | | boolean nicknameChanged = newNickname != null && !ObjUtil.equal(oldUser.getNickname(), newNickname); |
| | | boolean avatarChanged = newAvatar != null && !ObjUtil.equal(oldUser.getAvatar(), newAvatar); |
| | | if (!nicknameChanged && !avatarChanged) { |
| | | return; |
| | | } |
| | | adminUserProducer.sendUserProfileUpdateMessage(oldUser.getId(), |
| | | nicknameChanged ? newNickname : null, |
| | | avatarChanged ? newAvatar : null); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return userMapper.selectByIds(ids); |
| | | } |
| | | |
| | | public List<AdminUserDO> getUserListAll() { |
| | | return userMapper.selectList(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void validateUserList(Collection<Long> ids) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<AdminUserDO> getDeptUsers(Collection<Long> deptIds) { |
| | | return userMapper.selectListByDeptIds(deptIds); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isPasswordMatch(String rawPassword, String encodedPassword) { |
| | | return passwordEncoder.matches(rawPassword, encodedPassword); |
| | | } |