From e6721d69ac2f4c673f5276a12c5c3c961929800e Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 26 Sep 2022 11:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=A1=B9=E7=9B=AE=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=AF=B7=E6=B1=82=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/configuration/WebConfig.java | 2 ++ .../project/ProjectInfoController.java | 10 +++++-- .../rtss/entity/project/ProjectView.java | 30 +++++++++++++++++++ .../rtss/services/project/ProjectService.java | 10 +++++-- .../services/project/ProjectServiceImpl.java | 14 +++++---- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/main/java/club/joylink/rtss/configuration/WebConfig.java b/src/main/java/club/joylink/rtss/configuration/WebConfig.java index 75884ddc4..0b7af8003 100644 --- a/src/main/java/club/joylink/rtss/configuration/WebConfig.java +++ b/src/main/java/club/joylink/rtss/configuration/WebConfig.java @@ -60,6 +60,8 @@ public class WebConfig implements WebMvcConfigurer { whiteList.add("/api/projectServer/project/{project}"); whiteList.add("/test/simulation/**"); whiteList.add("/api/test/**"); + whiteList.add("/api/project/viewSetting/simple/all"); + whiteList.add("/api/project/viewSetting/project/{project}"); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); } 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 8b95ea13f..83215ee2d 100644 --- a/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java +++ b/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java @@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Map; /** * 项目设备管理接口(新) @@ -55,7 +54,7 @@ public class ProjectInfoController { public List queryProjectSimpleInfo() { return projectService.getSimpleProjectList(); } - + @GetMapping("/viewSetting/page") public PageVO projectViewPagingQuery(PageQueryVO queryVO) { return projectService.projectViewPagingQuery(queryVO); @@ -87,8 +86,13 @@ public class ProjectInfoController { } @GetMapping("/viewSetting/project/{project}") - public Map queryProjectViewSetting(@PathVariable String project) { + public ProjectView.SimpleProjectView queryProjectViewSetting(@PathVariable String project) { return projectService.getProjectViewSetting(project); } + @GetMapping("/viewSetting/simple/all") + public List queryViewAll() { + return projectService.queryViewAll(); + } + } diff --git a/src/main/java/club/joylink/rtss/entity/project/ProjectView.java b/src/main/java/club/joylink/rtss/entity/project/ProjectView.java index d965c9d46..d32d4c4d7 100644 --- a/src/main/java/club/joylink/rtss/entity/project/ProjectView.java +++ b/src/main/java/club/joylink/rtss/entity/project/ProjectView.java @@ -1,9 +1,13 @@ package club.joylink.rtss.entity.project; +import club.joylink.rtss.util.JsonUtils; import lombok.Getter; import lombok.Setter; +import org.springframework.util.StringUtils; import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; @Setter @Getter @@ -21,4 +25,30 @@ public class ProjectView { private Integer status; private String viewSetting; + + public SimpleProjectView simplifyProjectView() { + return new SimpleProjectView(this); + } + + @Setter + @Getter + + public static class SimpleProjectView { + private String markKey; + + private String project; + + private Map viewSetting; + + public SimpleProjectView(ProjectView projectView) { + this.markKey = projectView.getMarkKey(); + this.project = projectView.getProject(); + if (StringUtils.isEmpty(projectView.getViewSetting())) { + this.viewSetting = new HashMap<>(); + } else { + this.viewSetting = JsonUtils.read(projectView.getViewSetting(), Map.class); + } + + } + } } \ No newline at end of file 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 cc9c88ec1..4962c58a3 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectService.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectService.java @@ -6,7 +6,6 @@ import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; import java.util.List; -import java.util.Map; /** * 项目基本信息管理 @@ -86,10 +85,15 @@ public interface ProjectService { /** * 更新项目的前端设置信息 */ - Map getProjectViewSetting(String project); - + ProjectView.SimpleProjectView getProjectViewSetting(String project); + /** * 获取项目的简要信息,前端关联时使用 */ List getSimpleProjectList(); + + /** + * 前端请求所有设置信息 + */ + List queryViewAll(); } 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 79d53c729..6fa9bc2fe 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java @@ -8,7 +8,6 @@ import club.joylink.rtss.entity.project.ProjectView; 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.util.JsonUtils; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; import com.github.pagehelper.Page; @@ -23,7 +22,6 @@ import org.springframework.util.StringUtils; import java.time.LocalDateTime; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; @Service @@ -68,7 +66,7 @@ public class ProjectServiceImpl implements ProjectService { } @Override - @Cacheable(cacheNames = "project", keyGenerator = "projectKeyGenerator") + @Cacheable(cacheNames = "project", keyGenerator = "projectKeyGenerator", unless = "#result == null") public Project queryLoginProjectByCode(String code) { String codeKey = Project.isDefault(code) ? Project.DEFAULT_PROJECT_CODE : code; ProjectExample projectExample = new ProjectExample(); @@ -170,7 +168,7 @@ public class ProjectServiceImpl implements ProjectService { } @Override - public Map getProjectViewSetting(String project) { + public ProjectView.SimpleProjectView getProjectViewSetting(String project) { String markKey = Project.isDefault(project) ? Project.DEFAULT_PROJECT_MARK_KEY : project; ProjectViewExample projectViewExample = new ProjectViewExample(); projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andMarkKeyEqualTo(markKey); @@ -179,7 +177,7 @@ public class ProjectServiceImpl implements ProjectService { throw new SimulationException(SimulationExceptionType.Illegal_Argument); } ProjectView projectInfo = projectList.get(0); - return JsonUtils.read(projectInfo.getViewSetting(), Map.class); + return projectInfo.simplifyProjectView(); } @@ -190,4 +188,10 @@ public class ProjectServiceImpl implements ProjectService { List projectList = projectDAO.selectWithBLOBsByExample(projectExample); return projectList.stream().map(Project::generateSimpleProject).collect(Collectors.toList()); } + + @Override + public List queryViewAll() { + List projectList = projectViewDAO.selectWithBLOBsByExample(new ProjectViewExample()); + return projectList.stream().map(ProjectView::simplifyProjectView).collect(Collectors.toList()); + } }