diff --git a/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java b/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java index da32cb4cb..2564d7260 100644 --- a/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java +++ b/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java @@ -1,10 +1,10 @@ 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.ProjectView; import club.joylink.rtss.services.project.ProjectService; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.org.CompanyVO; import club.joylink.rtss.vo.project.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -62,7 +62,7 @@ public class ProjectInfoController { } @GetMapping("/{id}/orgList") - public List orgList(@PathVariable Long id) { + public List orgList(@PathVariable Long id) { return projectService.projectOrgList(id); } diff --git a/src/main/java/club/joylink/rtss/services/project/ProjectService.java b/src/main/java/club/joylink/rtss/services/project/ProjectService.java index 4f136f7fd..5bb1671fb 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectService.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectService.java @@ -1,9 +1,9 @@ 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.ProjectView; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.org.CompanyVO; import club.joylink.rtss.vo.project.*; import java.util.List; @@ -56,7 +56,7 @@ public interface ProjectService { /** * 根据项目ID获取与项目关联的所有组织信息 */ - List projectOrgList(Long id); + List projectOrgList(Long id); /** * 前端设置信息分页 diff --git a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java index 45b970557..ef545f40d 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java @@ -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.SimulationExceptionType; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.org.CompanyVO; import club.joylink.rtss.vo.project.*; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -142,7 +143,7 @@ public class ProjectServiceImpl implements ProjectService { } @Override - public List projectOrgList(Long id) { + public List projectOrgList(Long id) { Project project = projectDAO.selectByPrimaryKey(id); if (project == null) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在"); @@ -150,7 +151,8 @@ public class ProjectServiceImpl implements ProjectService { List orgProjectList = getOrgProjectList(List.of(project.getCode())); if (!CollectionUtils.isEmpty(orgProjectList)) { List orgIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList()); - return getOrgList(orgIdList); + List orgList = getOrgList(orgIdList); + return orgList.stream().map(CompanyVO::simpleInfoVO).collect(Collectors.toList()); } return List.of(); } diff --git a/src/main/java/club/joylink/rtss/vo/client/org/CompanyVO.java b/src/main/java/club/joylink/rtss/vo/client/org/CompanyVO.java index 47489f5b8..36f68af7d 100644 --- a/src/main/java/club/joylink/rtss/vo/client/org/CompanyVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/org/CompanyVO.java @@ -20,47 +20,56 @@ import java.util.List; @NoArgsConstructor public class CompanyVO { - @JsonSerialize(using = ToStringSerializer.class) - private Long id; + @JsonSerialize(using = ToStringSerializer.class) + private Long id; - private String code; - /**公司名称*/ - @NotBlank(message = "公司名称不能为空") - private String name; + private String code; + /** + * 公司名称 + */ + @NotBlank(message = "公司名称不能为空") + private String name; - private List projectCodes; + private List projectCodes; - public CompanyVO(Org entity) { - this.id = entity.getId(); - this.code = entity.getCode(); - this.name = entity.getName(); - if (StringUtils.hasText(entity.getProjectCode())) { - this.projectCodes = Arrays.asList(entity.getProjectCode().split(",")); - } - } + public CompanyVO(Org entity) { + this.id = entity.getId(); + this.code = entity.getCode(); + this.name = entity.getName(); + if (StringUtils.hasText(entity.getProjectCode())) { + this.projectCodes = Arrays.asList(entity.getProjectCode().split(",")); + } + } - public static List convert2VOList(List dataList) { - List voList = new ArrayList<>(); - for (Org entity : dataList) { - voList.add(new CompanyVO(entity)); - } - return voList; - } + public static CompanyVO simpleInfoVO(Org entity) { + CompanyVO companyVO = new CompanyVO(); + companyVO.setId(entity.getId()); + companyVO.setName(entity.getName()); + return companyVO; + } + + public static List convert2VOList(List dataList) { + List voList = new ArrayList<>(); + for (Org entity : dataList) { + voList.add(new CompanyVO(entity)); + } + return voList; + } public Org toDB() { - Org entity = new Org(); - entity.setId(this.id); - entity.setName(this.name); - entity.setProjectCode(getDBProjectCode()); - return entity; - } + Org entity = new Org(); + entity.setId(this.id); + entity.setName(this.name); + entity.setProjectCode(getDBProjectCode()); + return entity; + } - @JsonIgnore - public String getDBProjectCode() { - if (!CollectionUtils.isEmpty(projectCodes)) { - return String.join(",", projectCodes); - } else { - return null; - } - } + @JsonIgnore + public String getDBProjectCode() { + if (!CollectionUtils.isEmpty(projectCodes)) { + return String.join(",", projectCodes); + } else { + return null; + } + } }