fix: 用户新增添加创建人

This commit is contained in:
Ray.Hao
2025-05-28 23:28:42 +08:00
parent 8934d2da99
commit 7d5b7f0a63
2 changed files with 9 additions and 2 deletions

View File

@@ -17,6 +17,13 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* 用户角色服务实现类
*
* @author Ray.Hao
* @since 0.0.1
*/
@Service
@RequiredArgsConstructor
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
@@ -29,7 +36,6 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
*
* @param userId 用户ID
* @param roleIds 选择的角色ID集合
* @return
*/
@Override
public void saveUserRoles(Long userId, List<Long> roleIds) {
@@ -74,7 +80,6 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
// 当权限变更时清除登录态
if (rolesChanged) {
// 获取用户所有有效token根据实际token存储实现
String accessToken = SecurityUtils.getTokenFromRequest();
tokenManager.invalidateToken(accessToken);
}

View File

@@ -130,6 +130,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
// 设置默认加密密码
String defaultEncryptPwd = passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD);
entity.setPassword(defaultEncryptPwd);
entity.setCreateBy(SecurityUtils.getUserId());
// 新增用户
boolean result = this.save(entity);
@@ -165,6 +166,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
// 修改用户
boolean result = this.updateById(entity);
entity.setUpdateBy(SecurityUtils.getUserId());
if (result) {
// 保存用户角色