|
@@ -2,12 +2,14 @@ package cn.com.ty.lift.system.user.service.impl;
|
|
|
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.MtCompanyUser;
|
|
|
-import cn.com.ty.lift.system.user.dao.entity.UserAccount;
|
|
|
+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.MtCompanyRequest;
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.model.UserResponse;
|
|
|
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.IUserAccountService;
|
|
|
+import cn.com.ty.lift.system.user.service.IUserInfoService;
|
|
|
import cn.com.ty.lift.system.user.service.IUserRoleService;
|
|
|
import cn.com.ty.lift.system.utils.ProjectUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
@@ -17,7 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author huangyuan
|
|
@@ -33,6 +37,9 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
@Autowired
|
|
|
private IUserAccountService userAccountService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserInfoService userInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public RestResponse assignRole(MtCompanyRequest mtCompanyRequest) {
|
|
@@ -68,10 +75,28 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
|
|
|
@Override
|
|
|
public RestResponse getCompanyMembers(MtCompanyRequest mtCompanyRequest) {
|
|
|
+ List<UserResponse> userResponseList = new ArrayList<>();
|
|
|
List<MtCompanyUser> mtCompanyUserList = this.list(new QueryWrapper<MtCompanyUser>()
|
|
|
.eq("mt_company_id", mtCompanyRequest.getCompanyId()));
|
|
|
- List<String> userIdList = ProjectUtils.getAttrList(mtCompanyUserList, "userId", null);
|
|
|
- List<UserAccount> userAccountList = (List<UserAccount>) userAccountService.listByIds(userIdList);
|
|
|
- return RestResponse.ok(userAccountList, ApiConstants.RESULT_SUCCESS, "获取团队用户成功");
|
|
|
+ if(mtCompanyUserList != null && mtCompanyUserList.size() > 0){
|
|
|
+ //获取用户id集合
|
|
|
+ List<Long> userIdList = ProjectUtils.getAttrList(mtCompanyUserList, "userId", null);
|
|
|
+ //获取用户信息集合
|
|
|
+ List<UserInfo> userInfoList = (List<UserInfo>) userInfoService.listByIds(userIdList);
|
|
|
+ Map<Long, UserInfo> userIdToUserInfo = ProjectUtils.attrToObjMap(userInfoList, "userId", null);
|
|
|
+ if(userIdToUserInfo != null && userIdToUserInfo.size() > 0){
|
|
|
+ for(Long userId: userIdList){
|
|
|
+ //封装用户信息
|
|
|
+ UserResponse userResponse = new UserResponse();
|
|
|
+ userResponse.setUserId(userId);
|
|
|
+ UserInfo userInfo = userIdToUserInfo.get(userId);
|
|
|
+ if(userInfo != null){
|
|
|
+ userResponse.setName(userInfo.getName());
|
|
|
+ }
|
|
|
+ userResponseList.add(userResponse);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RestResponse.ok(userResponseList, ApiConstants.RESULT_SUCCESS, "获取团队用户成功");
|
|
|
}
|
|
|
}
|