【项目前端设置请求修改】

This commit is contained in:
weizhihong 2022-09-26 11:19:30 +08:00
parent f2ab1f945d
commit e6721d69ac
5 changed files with 55 additions and 11 deletions

View File

@ -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);
}

View File

@ -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;
/**
* 项目设备管理接口()
@ -87,8 +86,13 @@ public class ProjectInfoController {
}
@GetMapping("/viewSetting/project/{project}")
public Map<String, Object> queryProjectViewSetting(@PathVariable String project) {
public ProjectView.SimpleProjectView queryProjectViewSetting(@PathVariable String project) {
return projectService.getProjectViewSetting(project);
}
@GetMapping("/viewSetting/simple/all")
public List<ProjectView.SimpleProjectView> queryViewAll() {
return projectService.queryViewAll();
}
}

View File

@ -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<String, Object> 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);
}
}
}
}

View File

@ -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<String, Object> getProjectViewSetting(String project);
ProjectView.SimpleProjectView getProjectViewSetting(String project);
/**
* 获取项目的简要信息前端关联时使用
*/
List<Project.SimpleProject> getSimpleProjectList();
/**
* 前端请求所有设置信息
*/
List<ProjectView.SimpleProjectView> queryViewAll();
}

View File

@ -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<String, Object> 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<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
return projectList.stream().map(Project::generateSimpleProject).collect(Collectors.toList());
}
@Override
public List<ProjectView.SimpleProjectView> queryViewAll() {
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(new ProjectViewExample());
return projectList.stream().map(ProjectView::simplifyProjectView).collect(Collectors.toList());
}
}