fix:删除代理商时同时删除用户角色关系和用户信息。
This commit is contained in:
parent
fadc42f2c2
commit
677748bebf
@ -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
|
||||
|
||||
@ -198,4 +198,7 @@ public interface UserInfoServiceApi {
|
||||
@DeleteMapping("/deleteUserRoleByUserIds")
|
||||
boolean deleteUserRoleByUserId(@RequestParam("userIds") List<Integer> userIds);
|
||||
|
||||
@DeleteMapping("/deleteUserRoleByUserId")
|
||||
boolean deleteUserRoleByUserId(@RequestParam("userId") Integer userId);
|
||||
|
||||
}
|
||||
@ -240,7 +240,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
userEntity.setPassword(CommonUtils.encryptPassword(userInfoDTO.getPassword()));
|
||||
boolean saved = userService.save(userEntity);
|
||||
log.info("保存用户信息:{}", saved);
|
||||
if(saved){
|
||||
if (saved) {
|
||||
userRoleService.assignUserRoleByRoleCode(userEntity.getId(), userInfoDTO.getRoleCode().getCode());
|
||||
return userEntity.getId();
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user