@Test public void updateUserInfo() { UpdateInfoDTO dto = new UpdateInfoDTO(); dto.setNickname("pedro-gao"); dto.setUsername("pedro-gao"); dto.setEmail("1312342604@qq.com"); userService.updateUserInfo(dto); UserDO userDO = userService.getUserByUsername("pedro-gao"); assertEquals(userDO.getEmail(), "1312342604@qq.com"); boolean b = userIdentityService.verifyUsernamePassword(userDO.getId(), "pedro-gao", "123456"); assertTrue(b); }
@Transactional @Override public UserDO updateUserInfo(UpdateInfoDTO dto) { UserDO user = LocalUser.getLocalUser(); if (StrUtil.isNotBlank(dto.getUsername())) { boolean exist = this.checkUserExistByUsername(dto.getUsername()); if (exist) { throw new ForbiddenException("username already exist, please choose a new one", 10071); } user.setUsername(dto.getUsername()); userIdentityService.changeUsername(user.getId(), dto.getUsername()); } BeanUtil.copyProperties(dto, user); this.baseMapper.updateById(user); return user; }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Transactional @Override public UserDO updateUserInfo(UpdateInfoDTO dto) { UserDO user = LocalUser.getLocalUser(); if (StrUtil.isNotBlank(dto.getUsername())) { boolean exist = this.checkUserExistByUsername(dto.getUsername()); if (exist) { throw new ForbiddenException("username already exist, please choose a new one", 10071); } user.setUsername(dto.getUsername()); userIdentityService.changeUsername(user.getId(), dto.getUsername()); } BeanUtil.copyProperties(dto, user); this.baseMapper.updateById(user); return user; } }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Transactional @Override public UserDO updateUserInfo(UpdateInfoDTO dto) { UserDO user = LocalUser.getLocalUser(); if (StrUtil.isNotBlank(dto.getUsername())) { boolean exist = this.checkUserExistByUsername(dto.getUsername()); if (exist) { throw new ForbiddenException("username already exist, please choose a new one", 10071); } user.setUsername(dto.getUsername()); userIdentityService.changeUsername(user.getId(), dto.getUsername()); } BeanUtil.copyProperties(dto, user); this.baseMapper.updateById(user); return user; }  }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Transactional @Override public UserDO updateUserInfo(UpdateInfoDTO dto) { UserDO user = LocalUser.getLocalUser(); if (StrUtil.isNotBlank(dto.getUsername())) { boolean exist = this.checkUserExistByUsername(dto.getUsername()); if (exist) { throw new ForbiddenException("username already exist, please choose a new one", 10071); } user.setUsername(dto.getUsername()); userIdentityService.changeUsername(user.getId(), dto.getUsername()); } BeanUtil.copyProperties(dto, user); this.baseMapper.updateById(user); return user; }  @Transactional @Override UserDO createUser(RegisterDTO dto); @Transactional @Override UserDO updateUserInfo(UpdateInfoDTO dto); @Override UserDO changeUserPassword(ChangePasswordDTO dto); @Override List<GroupDO> getUserGroups(Long userId); @Override List<Map<String, List<Map<String, String>>>> getStructualUserPermissions(Long userId); @Override List<PermissionDO> getUserPermissions(Long userId); @Override UserDO getUserByUsername(String username); @Override boolean checkUserExistByUsername(String username); @Override boolean checkUserExistByEmail(String email); @Override boolean checkUserExistById(Long id); @Override IPage<UserDO> getUserPageByGroupId(Page pager, Long groupId); }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Transactional @Override public UserDO updateUserInfo(UpdateInfoDTO dto) { UserDO user = LocalUser.getLocalUser(); if (StrUtil.isNotBlank(dto.getUsername())) { boolean exist = this.checkUserExistByUsername(dto.getUsername()); if (exist) { throw new ForbiddenException("username already exist, please choose a new one", 10071); } user.setUsername(dto.getUsername()); userIdentityService.changeUsername(user.getId(), dto.getUsername()); } BeanUtil.copyProperties(dto, user); this.baseMapper.updateById(user); return user; }  @Transactional @Override UserDO createUser(RegisterDTO dto); @Transactional @Override UserDO updateUserInfo(UpdateInfoDTO dto); @Override UserDO changeUserPassword(ChangePasswordDTO dto); @Override List<GroupDO> getUserGroups(Long userId); @Override List<Map<String, List<Map<String, String>>>> getStructualUserPermissions(Long userId); @Override List<PermissionDO> getUserPermissions(Long userId); @Override UserDO getUserByUsername(String username); @Override boolean checkUserExistByUsername(String username); @Override boolean checkUserExistByEmail(String email); @Override boolean checkUserExistById(Long id); @Override IPage<UserDO> getUserPageByGroupId(Page pager, Long groupId);  }