fix:删除代理商时同时删除用户角色关系和用户信息。

This commit is contained in:
嘉多宝宝 2026-01-13 11:02:22 +08:00
parent fadc42f2c2
commit 677748bebf
3 changed files with 25 additions and 3 deletions

View File

@ -148,9 +148,11 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
public boolean deleteEmployee(Integer id) {
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getById(id);
AssertUtils.notNull(existing, ResultCodeEnum.DATA_NOT_EXIST);
Integer userId = existing.getEmployeeUserId();
boolean result = mpAgentEmployeeRelationService.removeById(id);
log.info("删除员工结果:{}", result);
return result;
boolean deleteUserResult = userInfoServiceApi.deleteUserRoleByUserId(userId);
return result && deleteUserResult;
}
@Override

View File

@ -198,4 +198,7 @@ public interface UserInfoServiceApi {
@DeleteMapping("/deleteUserRoleByUserIds")
boolean deleteUserRoleByUserId(@RequestParam("userIds") List<Integer> userIds);
@DeleteMapping("/deleteUserRoleByUserId")
boolean deleteUserRoleByUserId(@RequestParam("userId") Integer userId);
}

View File

@ -298,6 +298,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
log.info("注册默认Children User:{}", userEntity);
return userEntity.getId();
}
@Override
public Integer checkUserInfo(Integer userId) {
UserExtendEntity byUserId = userExtendService.getByUserId(userId);
@ -335,7 +336,23 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
log.info("准备删除角色记录ID列表: {}", ids);
boolean result = userRoleService.removeByIds(ids);
log.info("删除角色结果: {}", result);
return result;
// 删除用户信息
boolean userResult = userService.removeByIds(userIds);
log.info("删除用户信息结果: {}", userResult);
return result && userResult;
}
@Override
public boolean deleteUserRoleByUserId(Integer userId) {
UserRoleEntity one = userRoleService.lambdaQuery().eq(UserRoleEntity::getUserId, userId).one();
if (one != null) {
// 删除用户信息
userService.removeById(userId);
// 删除用户角色
return userRoleService.removeById(one);
}
log.info("用户角色不存在");
return false;
}
/**