【查询项目关联组织时,过滤多余字段】

This commit is contained in:
weizhihong 2022-10-12 14:24:02 +08:00
parent ee8ad73e87
commit 1973bf3f24
4 changed files with 53 additions and 42 deletions

View File

@ -1,10 +1,10 @@
package club.joylink.rtss.controller.project; package club.joylink.rtss.controller.project;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.project.Project; import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.entity.project.ProjectView; import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.services.project.ProjectService; import club.joylink.rtss.services.project.ProjectService;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.project.*; import club.joylink.rtss.vo.project.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -62,7 +62,7 @@ public class ProjectInfoController {
} }
@GetMapping("/{id}/orgList") @GetMapping("/{id}/orgList")
public List<Org> orgList(@PathVariable Long id) { public List<CompanyVO> orgList(@PathVariable Long id) {
return projectService.projectOrgList(id); return projectService.projectOrgList(id);
} }

View File

@ -1,9 +1,9 @@
package club.joylink.rtss.services.project; package club.joylink.rtss.services.project;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.project.Project; import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.entity.project.ProjectView; import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.project.*; import club.joylink.rtss.vo.project.*;
import java.util.List; import java.util.List;
@ -56,7 +56,7 @@ public interface ProjectService {
/** /**
* 根据项目ID获取与项目关联的所有组织信息 * 根据项目ID获取与项目关联的所有组织信息
*/ */
List<Org> projectOrgList(Long id); List<CompanyVO> projectOrgList(Long id);
/** /**
* 前端设置信息分页 * 前端设置信息分页

View File

@ -15,6 +15,7 @@ import club.joylink.rtss.entity.project.ProjectViewExample;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.project.*; import club.joylink.rtss.vo.project.*;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
@ -142,7 +143,7 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public List<Org> projectOrgList(Long id) { public List<CompanyVO> projectOrgList(Long id) {
Project project = projectDAO.selectByPrimaryKey(id); Project project = projectDAO.selectByPrimaryKey(id);
if (project == null) { if (project == null) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在"); throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在");
@ -150,7 +151,8 @@ public class ProjectServiceImpl implements ProjectService {
List<OrgProject> orgProjectList = getOrgProjectList(List.of(project.getCode())); List<OrgProject> orgProjectList = getOrgProjectList(List.of(project.getCode()));
if (!CollectionUtils.isEmpty(orgProjectList)) { if (!CollectionUtils.isEmpty(orgProjectList)) {
List<Long> orgIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList()); List<Long> orgIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList());
return getOrgList(orgIdList); List<Org> orgList = getOrgList(orgIdList);
return orgList.stream().map(CompanyVO::simpleInfoVO).collect(Collectors.toList());
} }
return List.of(); return List.of();
} }

View File

@ -24,7 +24,9 @@ public class CompanyVO {
private Long id; private Long id;
private String code; private String code;
/**公司名称*/ /**
* 公司名称
*/
@NotBlank(message = "公司名称不能为空") @NotBlank(message = "公司名称不能为空")
private String name; private String name;
@ -39,6 +41,13 @@ public class CompanyVO {
} }
} }
public static CompanyVO simpleInfoVO(Org entity) {
CompanyVO companyVO = new CompanyVO();
companyVO.setId(entity.getId());
companyVO.setName(entity.getName());
return companyVO;
}
public static List<CompanyVO> convert2VOList(List<Org> dataList) { public static List<CompanyVO> convert2VOList(List<Org> dataList) {
List<CompanyVO> voList = new ArrayList<>(); List<CompanyVO> voList = new ArrayList<>();
for (Org entity : dataList) { for (Org entity : dataList) {