ProjectController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.annotation.Permission;
  3. import cn.cslg.pas.common.core.base.Constants;
  4. import cn.cslg.pas.common.model.PersonnelVO;
  5. import cn.cslg.pas.common.model.vo.ProjectVO;
  6. import cn.cslg.pas.common.utils.CacheUtils;
  7. import cn.cslg.pas.common.utils.Response;
  8. import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
  9. import cn.cslg.pas.common.utils.StringUtils;
  10. import cn.cslg.pas.common.utils.auth.checkAuth;
  11. import cn.cslg.pas.domain.Project;
  12. import cn.cslg.pas.service.ProjectPatentLinkService;
  13. import cn.cslg.pas.service.ProjectService;
  14. import io.swagger.v3.oas.annotations.Operation;
  15. import io.swagger.v3.oas.annotations.tags.Tag;
  16. import lombok.RequiredArgsConstructor;
  17. import org.springframework.context.annotation.Lazy;
  18. import org.springframework.web.bind.annotation.*;
  19. import org.springframework.web.multipart.MultipartFile;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.util.List;
  22. /**
  23. * <p>
  24. * 专题库 前端控制器
  25. * </p>
  26. *
  27. * @author 王岩
  28. * @since 2021-12-24
  29. */
  30. @Tag(name = "专题库")
  31. @RestController
  32. @RequestMapping(Constants.API_VERSION_V2 + "/project")
  33. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  34. public class ProjectController {
  35. private final ProjectService projectService;
  36. private final CacheUtils cacheUtils;
  37. private final ProjectPatentLinkService projectPatentLinkService;
  38. private final LoginUtils loginUtils;
  39. @PostMapping("list")
  40. @checkAuth(FunId = "/workspace/project/check")
  41. @Operation(summary = "专题库列表")
  42. public String getPageList(@RequestBody ProjectVO params) {
  43. return Response.success(projectService.getPageList(params));
  44. }
  45. @checkAuth(FunId = "/workspace/project/add")
  46. @PostMapping("add")
  47. @Operation(summary = "新增专题库")
  48. public String add(@RequestBody Project project) {
  49. PersonnelVO user = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
  50. return projectService.add(project);
  51. }
  52. @Permission()
  53. @checkAuth(FunId = "/workspace/project/modify")
  54. @PostMapping("edit")
  55. @Operation(summary = "编辑专题库")
  56. public String edit(@RequestBody Project project) {
  57. return projectService.edit(project);
  58. }
  59. @Permission()
  60. @PostMapping("delete")
  61. @checkAuth(FunId = "/workspace/project/delete")
  62. @Operation(summary = "删除专题库")
  63. public String delete(Integer id) {
  64. return projectService.delete(id);
  65. }
  66. @checkAuth(FunId = "/workspace/project/delete")
  67. @PostMapping("/patent/delete")
  68. @Operation(summary = "删除专题库专利")
  69. public String deletePatent(Integer projectId, String ids) {
  70. List<Integer> patentIds = StringUtils.changeStringToInteger(ids, ",");
  71. projectPatentLinkService.deleteByProjectIdAndPatentIds(projectId, patentIds);
  72. return Response.success(true);
  73. }
  74. @GetMapping("total")
  75. @Operation(summary = "专题库企业应用场景统计数据")
  76. public String getScenarioAndTypeTotal() {
  77. return Response.success(projectService.getScenarioAndTypeTotal());
  78. }
  79. @GetMapping("/status/total")
  80. @Operation(summary = "专题库状态统计数据")
  81. public String getProjectStatusTotal() {
  82. return Response.success(projectService.getProjectStatusTotal());
  83. }
  84. @checkAuth(FunId = "/project/type/total")
  85. @GetMapping("/type/total")
  86. @Operation(summary = "专题库调查类型统计数据")
  87. public String getProjectTypeTotal(String scenario) {
  88. return Response.success(projectService.getProjectTypeTotal(scenario));
  89. }
  90. @GetMapping("chartData")
  91. @Operation(summary = "专题库图表统计数据")
  92. public String getChartData() {
  93. return Response.success();
  94. }
  95. @Permission()
  96. @PostMapping("share")
  97. @checkAuth(FunId = "/workspace/project/project_share")
  98. @Operation(summary = "分享专题库")
  99. public String share(Integer id, @RequestBody List<Integer> userIds) {
  100. return projectService.share(id, userIds);
  101. }
  102. @checkAuth(FunId ="/workspace/project/import/Excel_template")
  103. @PostMapping("importExcel")
  104. @Operation(summary = "根据模板导入专题库信息")
  105. public String importExcel(MultipartFile file) {
  106. return projectService.importExcel(file);
  107. }
  108. @checkAuth(FunId = "/workspace/project/export_list")
  109. @PostMapping("/export/list")
  110. @Operation(summary = "导出专题库信息列表")
  111. public void exportProjectList(HttpServletResponse response) {
  112. projectService.exportProject(response);
  113. }
  114. }