|
@@ -78,7 +78,7 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
userRole.setRoleId(roleId);
|
|
|
userRole.setUserId(userId);
|
|
|
boolean saveUserRoleFlag = userRoleService.save(userRole);
|
|
|
- if(!saveUserRoleFlag){
|
|
|
+ if (!saveUserRoleFlag) {
|
|
|
//事务强制回滚
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "保存角色信息失败");
|
|
@@ -111,6 +111,14 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
);
|
|
|
//获取角色关联的用户信息
|
|
|
List<Long> userIdList = ProjectUtils.getAttrList(userRoleList, "userId", null);
|
|
|
+ if(userIdList.size() > 0){
|
|
|
+ List<MtCompanyUser> mtCompanyUserList = this.list(new QueryWrapper<MtCompanyUser>()
|
|
|
+ .in(userIdList != null && userIdList.size() > 0, "user_id", userIdList)
|
|
|
+ .eq("mt_company_id", mtCompanyUserRequest.getCompanyId())
|
|
|
+ .eq("status", ApiConstants.ApplicationConstants.APPLY_PASS)
|
|
|
+ );
|
|
|
+ userIdList = ProjectUtils.getAttrList(mtCompanyUserList, "userId", null);
|
|
|
+ }
|
|
|
Map<Long, Role> userIdToRole = roleService.getUserIdToRoleByUserIdsAndCompanyId(userIdList, mtCompanyUserRequest.getCompanyId());
|
|
|
//获取用户信息集合
|
|
|
if (userIdList != null && userIdList.size() > 0) {
|
|
@@ -125,7 +133,7 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
//用户id->角色
|
|
|
Role role = userIdToRole.get(userId);
|
|
|
//设置角色编码
|
|
|
- if(role != null){
|
|
|
+ if (role != null) {
|
|
|
userResponse.setRoleCode(role.getCode());
|
|
|
}
|
|
|
if (userInfo != null) {
|
|
@@ -151,8 +159,20 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
}
|
|
|
//设置用户为踢出团队状态
|
|
|
mtCompanyUser.setStatus(ApiConstants.ApplicationConstants.APPLY_FAIL);
|
|
|
- this.updateById(mtCompanyUser);
|
|
|
- return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "踢出用户成功");
|
|
|
+ //将用户原来关联的角色信息删除掉
|
|
|
+ boolean deleteUserRoleFlag = userRoleService.remove(new QueryWrapper<UserRole>()
|
|
|
+ .eq("user_id", mtCompanyUser.getUserId())
|
|
|
+ .eq("company_id", mtCompanyUser.getMtCompanyId())
|
|
|
+ );
|
|
|
+ if (deleteUserRoleFlag) {
|
|
|
+ if (this.updateById(mtCompanyUser)) {
|
|
|
+ return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "踢出用户成功");
|
|
|
+ } else {
|
|
|
+ //如果删除不成功,强制事务回滚
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "踢出用户失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -292,7 +312,7 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
.eq("delete_flag", ApiConstants.DELETE_NO)
|
|
|
);
|
|
|
//获取用户信息
|
|
|
- List<Long> userIdList = ProjectUtils.getAttrList(mtCompanyUserList,"userId", null);
|
|
|
+ List<Long> userIdList = ProjectUtils.getAttrList(mtCompanyUserList, "userId", null);
|
|
|
Map<Long, UserResponse> userIdToUserResponse = userService.getUserResponseByUserIdList(userIdList);
|
|
|
return RestResponse.success(userIdToUserResponse.values(), ApiConstants.RESULT_SUCCESS, "获取急修工成功");
|
|
|
}
|