Browse Source

Merge branch 'huangyuan-user' of lift-manager/lift-server into develop

huangyuan 5 năm trước cách đây
mục cha
commit
3ce861c82c

+ 24 - 7
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/MtCompanyUserService.java

@@ -71,18 +71,35 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
     public RestResponse assignRole(MtCompanyUserRequest mtCompanyUserRequest) {
         //获取用户是否已有mtCompanyUser信息。
         MtCompanyUser mtCompanyUser = this.getById(mtCompanyUserRequest.getId());
-        //保存职业信息
-        mtCompanyUser.setJob(mtCompanyUserRequest.getJob());
-        this.updateById(mtCompanyUser);
         //保存用户角色关联信息
         Long roleId = mtCompanyUserRequest.getRoleId();
         Long userId = mtCompanyUser.getUserId();
         Long companyId = mtCompanyUser.getMtCompanyId();
+        //获取用户原来关联的角色信息
+        UserRole userRole = userRoleService.getOne(new QueryWrapper<UserRole>()
+                .eq("company_id", companyId)
+                .eq("user_id", userId)
+        );
+        if (userRole != null) {
+            //获取用户的角色信息
+            Role role = roleService.getById(userRole.getId());
+            if (role != null) {
+                //若角色为区域主管,判断角色是否有关联的信息
+                if (CommonEnum.DefaultRole.REGION_DIRECTOR.getCode().equals(role.getCode())) {
+                    Map<String, String> judgeMsg = projectService.judgeKickOutTeam(new ProjectUser(userId, companyId));
+                    if (ApiConstants.RESULT_ERROR.equals(judgeMsg.get(CommonConstants.RETURN_CODE_FIELD))) {
+                        return RestResponse.fail(ApiConstants.RESULT_ERROR, "区域主管存在关联项目无法更改角色信息");
+                    }
+                }
+            }
+        }
+        //保存职业信息
+        mtCompanyUser.setJob(mtCompanyUserRequest.getJob());
+        if (!this.updateById(mtCompanyUser)) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return RestResponse.fail(ApiConstants.RESULT_ERROR, "更新职业信息失败");
+        }
         if (roleId != null) {
-            UserRole userRole = userRoleService.getOne(new QueryWrapper<UserRole>()
-                    .eq("company_id", companyId)
-                    .eq("user_id", userId)
-            );
             if (userRole != null) {
                 //删除原有的关联关系
                 boolean deleteUserRoleFlag = userRoleService.removeById(userRole.getId());

+ 4 - 4
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/PropertyUserService.java

@@ -16,6 +16,7 @@ import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author huangyuan
@@ -47,11 +48,10 @@ public class PropertyUserService implements IPropertyUserService {
         IPage propertyUserPage = new Page(propertyUserRequest.getPageNum(), propertyUserRequest.getPageSize());
         if (projectUserList != null && projectUserList.size() > 0) {
             //获取用户信息
-            List<Long> userIdList = ProjectUtils.getAttrList(projectUserList, "userId", null);
+            List<Long> userIdList = projectUserList.stream().map(ProjectUser::getUserId).collect(Collectors.toList());
             Map<Long, UserResponse> userIdToUserResponse = userService.getUserResponseByUserIdList(userIdList);
             //获取项目信息
-            List<Long> projectIdList = ProjectUtils.getAttrList(projectUserList,
-                    "projectId", null);
+            List<Long> projectIdList = projectUserList.stream().map(ProjectUser::getProjectId).collect(Collectors.toList());
             Map<Long, ProjectInfo> projectIdToProjectInfo = projectService.getProjectIdToProjectByProjectIdList(projectIdList);
             List<PropertyUserResponse> propertyUserResponseList = new ArrayList<>();
             for (ProjectUser projectUser : projectUserList) {
@@ -84,7 +84,7 @@ public class PropertyUserService implements IPropertyUserService {
     @Override
     public RestResponse cancelPermission(PropertyUserRequest propertyUserRequest) {
         Long deleteCount = projectService.deleteProjectUser(propertyUserRequest);
-        if(deleteCount == 0){
+        if (deleteCount == 0) {
             return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
         }
         return RestResponse.success(ApiConstants.RESULT_SUCCESS, "操作成功");

+ 20 - 16
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/UserService.java

@@ -293,23 +293,27 @@ public class UserService implements IUserService {
 
     @Override
     public List<Long> getIdListByQueryCondition(String queryCondition) {
-        List<UserAccount> userAccountList = userAccountService.list(new QueryWrapper<UserAccount>()
-                .select("user_id")
-                //通过手机号模糊查找
-                .like("mobile", queryCondition));
-        List<UserInfo> userInfoList = userInfoService.list(new QueryWrapper<UserInfo>()
-                .select("user_id")
-                //通过用户名模糊查找
-                .like("name", queryCondition)
+        //通过手机号模糊查找
+        List<UserAccount> userAccountList = userAccountService.list(new QueryWrapper<UserAccount>().
+                select("user_id").like("mobile", queryCondition)
         );
-        //获取通过手机号模糊查询出来的用户id
-        List<Long> accountUserIdList = ProjectUtils.getAttrList(userAccountList, "userId", null);
-        //获取通过用户名模糊查询出来的用户id
-        List<Long> infoUserIdList = ProjectUtils.getAttrList(userInfoList, "userId", null);
-        //合并去重
-        accountUserIdList.addAll(infoUserIdList);
-        ProjectUtils.removeDuplicateWithOrder(accountUserIdList);
-        return accountUserIdList;
+        //通过用户名称模糊查找用户信息
+        List<UserInfo> userInfoList = userInfoService.list(new QueryWrapper<UserInfo>().
+                select("user_id").like("name", queryCondition)
+        );
+        List<Long> userIdList = new ArrayList<>();
+        //将用户id封装到集合中
+        if (userAccountList != null && userAccountList.size() > 0) {
+            userIdList.addAll(userAccountList.stream().map(UserAccount::getUserId)
+                    .collect(Collectors.toList()));
+        }
+        if (userInfoList != null && userInfoList.size() > 0) {
+            userIdList.addAll(userInfoList.stream().map(UserInfo::getUserId)
+                    .collect(Collectors.toList()));
+        }
+        //列表去重
+        ProjectUtils.removeDuplicateWithOrder(userIdList);
+        return userIdList;
     }
 
     @Override