|
@@ -3,19 +3,14 @@ package cn.com.ty.lift.system.user.service.impl;
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
import cn.com.ty.lift.system.constants.CommonConstants;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.MtCompanyUser;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.UserInfo;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.UserRole;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.model.MtCompanyUserRequest;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.model.ProjectUser;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.model.UserResponse;
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.*;
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.model.*;
|
|
|
import cn.com.ty.lift.system.user.dao.mapper.MtCompanyUserMapper;
|
|
|
-import cn.com.ty.lift.system.user.service.IMtCompanyUserService;
|
|
|
-import cn.com.ty.lift.system.user.service.IProjectService;
|
|
|
-import cn.com.ty.lift.system.user.service.IUserInfoService;
|
|
|
-import cn.com.ty.lift.system.user.service.IUserRoleService;
|
|
|
+import cn.com.ty.lift.system.user.service.*;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -42,6 +37,12 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
@Autowired
|
|
|
private IProjectService projectService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserAccountService userAccountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRoleService roleService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public RestResponse assignRole(MtCompanyUserRequest mtCompanyUserRequest) {
|
|
@@ -109,7 +110,7 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
Map<String, String> judgeMsg = projectService.judgeKickOutTeam(projectUser);
|
|
|
//获取判断返回的状态码
|
|
|
String code = judgeMsg.get(CommonConstants.RETURN_CODE_FIELD);
|
|
|
- if(ApiConstants.RESULT_ERROR.equals(code)){
|
|
|
+ if (ApiConstants.RESULT_ERROR.equals(code)) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, judgeMsg.get(CommonConstants.RETURN_MSG_FIELD));
|
|
|
}
|
|
|
MtCompanyUser mtCompanyUser = this.getById(mtCompanyUserRequest.getId());
|
|
@@ -118,4 +119,82 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "踢出用户成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RestResponse getCompanyUserList(MtCompanyUserRequest mtCompanyUserRequest) {
|
|
|
+
|
|
|
+ List<MtCompanyUserResponse> mtCompanyUserResponseList = new ArrayList<>();
|
|
|
+ IPage<MtCompanyUser> mtCompanyUserPage = new Page<>(mtCompanyUserRequest.getPageNum(), mtCompanyUserRequest.getPageSize());
|
|
|
+ mtCompanyUserPage = this.page(mtCompanyUserPage, new QueryWrapper<MtCompanyUser>()
|
|
|
+ .eq("mt_company_id", mtCompanyUserRequest.getCompanyId())
|
|
|
+ .eq("delete_flag", ApiConstants.DELETE_NO)
|
|
|
+ );
|
|
|
+ List<MtCompanyUser> mtCompanyUserList = mtCompanyUserPage.getRecords();
|
|
|
+ if (mtCompanyUserList != null && mtCompanyUserList.size() > 0) {
|
|
|
+
|
|
|
+ /** 用户信息区域 **/
|
|
|
+ //获取用户id集合
|
|
|
+ List<Long> userIdList = ProjectUtils.getAttrList(mtCompanyUserList, "userId", null);
|
|
|
+ //获取用户账号信息
|
|
|
+ List<UserAccount> userAccountList = (List<UserAccount>) userAccountService.listByIds(userIdList);
|
|
|
+ //获取用户基本信息
|
|
|
+ List<UserInfo> userInfoList = (List<UserInfo>) userInfoService.listByIds(userIdList);
|
|
|
+ //将数据转化为userId -> 用户信息的map
|
|
|
+ Map<Long, UserAccount> userIdToUserAccount = ProjectUtils.attrToObjMap(userAccountList, "userId", null);
|
|
|
+ Map<Long, UserInfo> userIdToUserInfo = ProjectUtils.attrToObjMap(userInfoList, "userId", null);
|
|
|
+
|
|
|
+ /** 角色信息区域 **/
|
|
|
+ //获取用户角色关联关系
|
|
|
+ List<UserRole> userRoleList = userRoleService.list(new QueryWrapper<UserRole>()
|
|
|
+ .in("user_id", userIdList)
|
|
|
+ .eq("company_id", mtCompanyUserRequest.getCompanyId())
|
|
|
+ );
|
|
|
+ //转化用户id对应用户角色关联关系
|
|
|
+ Map<Long, UserRole> userIdToUserRole = ProjectUtils.attrToObjMap(userRoleList, "userId", null);
|
|
|
+ //获取角色列表
|
|
|
+ List<Long> roleIdList = ProjectUtils.getAttrList(userRoleList, "roleId", null);
|
|
|
+ List<Role> roleList = (List<Role>) roleService.listByIds(roleIdList);
|
|
|
+ Map<Long, Role> idToRole = ProjectUtils.attrToObjMap(roleList, "id", null);
|
|
|
+
|
|
|
+ /** 操作证信息区域 **/
|
|
|
+ //获取用户操作证信息
|
|
|
+ List<LiftCertificate> liftCertificateList = projectService.getLiftCertificateList(new ProjectUser(mtCompanyUserRequest.getCompanyId(), userIdList));
|
|
|
+ Map<Long, LiftCertificate> userIdToLiftCertificate = ProjectUtils.attrToObjMap(liftCertificateList, "userId", null);
|
|
|
+
|
|
|
+ /** 公司用户信息组装区域 **/
|
|
|
+ //组装公司用户信息
|
|
|
+ for (MtCompanyUser mtCompanyUser : mtCompanyUserList) {
|
|
|
+ MtCompanyUserResponse mtCompanyUserResponse = new MtCompanyUserResponse();
|
|
|
+ UserAccount userAccount = userIdToUserAccount.get(mtCompanyUser.getUserId());
|
|
|
+ UserInfo userInfo = userIdToUserInfo.get(mtCompanyUser.getUserId());
|
|
|
+ //设置用户角色信息
|
|
|
+ mtCompanyUserResponse.setJob(mtCompanyUser.getJob());
|
|
|
+ //设置公司用户基础信息
|
|
|
+ if (userAccount != null && userInfo != null) {
|
|
|
+ mtCompanyUserResponse.setUserId(mtCompanyUser.getUserId());
|
|
|
+ mtCompanyUserResponse.setUserMobile(userAccount.getMobile());
|
|
|
+ mtCompanyUserResponse.setUserName(userInfo.getName());
|
|
|
+ }
|
|
|
+ //设置公司用户角色名称
|
|
|
+ UserRole userRole = userIdToUserRole.get(mtCompanyUser.getUserId());
|
|
|
+ if(userRole != null) {
|
|
|
+ Role role = idToRole.get(userRole.getRoleId());
|
|
|
+ if(role != null){
|
|
|
+ mtCompanyUserResponse.setRoleName(role.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置用户操作证状态 0:无证,1:待审核,2:审核未通过,3:审核通过,4:超期
|
|
|
+ LiftCertificate liftCertificate = userIdToLiftCertificate.get(mtCompanyUser.getUserId());
|
|
|
+ if(liftCertificate != null){
|
|
|
+ mtCompanyUserResponse.setCertificateStatus(liftCertificate.getStatus());
|
|
|
+ }
|
|
|
+ mtCompanyUserResponseList.add(mtCompanyUserResponse);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置分页数据
|
|
|
+ IPage<MtCompanyUserResponse> mtCompanyUserResponsePage = new Page<>();
|
|
|
+ mtCompanyUserResponsePage.setRecords(mtCompanyUserResponseList);
|
|
|
+ mtCompanyUserResponsePage.setTotal(mtCompanyUserPage.getTotal());
|
|
|
+ return RestResponse.ok(mtCompanyUserResponseList, ApiConstants.RESULT_SUCCESS, "获取公司成员列表成功");
|
|
|
+ }
|
|
|
+
|
|
|
}
|