package com.gk.hotwork.Service.ServiceImpl; import com.gk.hotwork.Domain.CompanyInfo; import com.gk.hotwork.Domain.DepartmentInfo; import com.gk.hotwork.Domain.Enum.ResultCodes; import com.gk.hotwork.Domain.Exception.BusinessException; import com.gk.hotwork.Domain.UserInfo; import com.gk.hotwork.Domain.Vo.ResultVO; import com.gk.hotwork.Domain.dto.UserDepRPCRespDTO; import com.gk.hotwork.Domain.dto.UserEnterpriseRPCRespDTO; import com.gk.hotwork.Domain.dto.UserInfoRPCRespDTO; import com.gk.hotwork.Domain.dto.UserRPCRespDTO; import com.gk.hotwork.Service.CompanyService; import com.gk.hotwork.Service.DepartmentService; import com.gk.hotwork.Service.Middle.AccountAuthService; import com.gk.hotwork.Service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; @Service("userTransferService") public class AccountAuthServiceImpl implements AccountAuthService { @Autowired private UserService userService; @Autowired private DepartmentService departmentService; @Autowired private CompanyService companyService; @Override public ResultVO getUserById(Long uid) { UserRPCRespDTO result = new UserRPCRespDTO(); if (uid == null) { throw new BusinessException("用户id为空"); } UserInfo userInfo = userService.getById(uid); if (userInfo != null) { result.setRealName(userInfo.getRealname()); result.setUsername(userInfo.getRealname()); result.setPhone(userInfo.getUsername()); result.setUid(userInfo.getId() + ""); UserDepRPCRespDTO userDepRPCRespDTO = new UserDepRPCRespDTO(); if (userInfo.getDepartment() != null) { DepartmentInfo dep = departmentService.getById(userInfo.getDepartment()); if (dep != null) { userDepRPCRespDTO.setDepId(dep.getId()); userDepRPCRespDTO.setDepName(dep.getDepartment()); result.setDepartment(userDepRPCRespDTO); } } UserEnterpriseRPCRespDTO userEnterpriseRPCRespDTO = new UserEnterpriseRPCRespDTO(); if (userInfo.getCompanyid() != null) { CompanyInfo companyInfo = companyService.getById(userInfo.getCompanyid()); userEnterpriseRPCRespDTO.setId(companyInfo.getId()); userEnterpriseRPCRespDTO.setName(companyInfo.getCompany()); result.setEnterprise(userEnterpriseRPCRespDTO); } } return new ResultVO<>(ResultCodes.OK,result); } @Override public ResultVO> listUserInfoByUids(List uids) { List userInfos = userService.listByIds(uids); List result = new ArrayList<>(userInfos.size()); UserInfoRPCRespDTO respDTO; for (UserInfo userInfo : userInfos) { respDTO = new UserInfoRPCRespDTO(); respDTO.setUid(userInfo.getId()); respDTO.setUsername(userInfo.getRealname()); respDTO.setRealName(userInfo.getRealname()); respDTO.setStatus(userInfo.getStatus()); respDTO.setPhone(userInfo.getUsername()); respDTO.setIdentify(userInfo.getIdcard()); respDTO.setEmail(userInfo.getEmail()); respDTO.setDepId(userInfo.getDepartment()); result.add(respDTO); } return new ResultVO<>(ResultCodes.OK,result); } }