|
@@ -1,17 +1,19 @@
|
|
|
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.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.IProjectService;
|
|
|
import cn.com.ty.lift.system.user.service.IUserInfoService;
|
|
|
import cn.com.ty.lift.system.user.service.IUserRoleService;
|
|
|
-import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -35,10 +37,10 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
private IUserRoleService userRoleService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IUserAccountService userAccountService;
|
|
|
+ private IUserInfoService userInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IUserInfoService userInfoService;
|
|
|
+ private IProjectService projectService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
@@ -78,19 +80,19 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
List<UserResponse> userResponseList = new ArrayList<>();
|
|
|
List<MtCompanyUser> mtCompanyUserList = this.list(new QueryWrapper<MtCompanyUser>()
|
|
|
.eq("mt_company_id", mtCompanyUserRequest.getCompanyId()));
|
|
|
- if(mtCompanyUserList != null && mtCompanyUserList.size() > 0){
|
|
|
+ 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){
|
|
|
+ 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){
|
|
|
+ if (userInfo != null) {
|
|
|
userResponse.setName(userInfo.getName());
|
|
|
}
|
|
|
userResponseList.add(userResponse);
|
|
@@ -100,4 +102,20 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
|
|
|
return RestResponse.ok(userResponseList, ApiConstants.RESULT_SUCCESS, "获取团队用户成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RestResponse kickOutTeam(MtCompanyUserRequest mtCompanyUserRequest) {
|
|
|
+ //判断用户是否可以踢出团队
|
|
|
+ ProjectUser projectUser = new ProjectUser(mtCompanyUserRequest.getUserId(), mtCompanyUserRequest.getCompanyId());
|
|
|
+ Map<String, String> judgeMsg = projectService.judgeKickOutTeam(projectUser);
|
|
|
+ //获取判断返回的状态码
|
|
|
+ String code = judgeMsg.get(CommonConstants.RETURN_CODE_FIELD);
|
|
|
+ if(ApiConstants.RESULT_ERROR.equals(code)){
|
|
|
+ return RestResponse.error(ApiConstants.RESULT_ERROR, judgeMsg.get(CommonConstants.RETURN_MSG_FIELD));
|
|
|
+ }
|
|
|
+ MtCompanyUser mtCompanyUser = this.getById(mtCompanyUserRequest.getId());
|
|
|
+ mtCompanyUser.setStatus(ApiConstants.ApplicationConstants.COMPANY_USER_FAIL);
|
|
|
+ this.updateById(mtCompanyUser);
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "踢出用户成功");
|
|
|
+ }
|
|
|
+
|
|
|
}
|