柯桥增值式服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.2KB

  1. package com.ningdatech.kqapi.zzsfw.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.ningdatech.kqapi.common.exception.BizException;
  4. import com.ningdatech.kqapi.zzsfw.entity.dto.NdKqZzsfwMattersDeduplicateDTO;
  5. import com.ningdatech.kqapi.zzsfw.entity.dto.NdKqZzsfwMenuDTO;
  6. import com.ningdatech.kqapi.zzsfw.entity.vo.MatterTopVO;
  7. import com.ningdatech.kqapi.zzsfw.entity.vo.MattersVO;
  8. import com.ningdatech.kqapi.zzsfw.entity.vo.TreeVO;
  9. import com.ningdatech.kqapi.zzsfw.manage.MatterManage;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.*;
  14. import org.springframework.web.multipart.MultipartFile;
  15. import java.io.IOException;
  16. import java.util.List;
  17. import java.util.Objects;
  18. /**
  19. * <p>
  20. * 前端控制器
  21. * </p>
  22. *
  23. * @author ZPF
  24. * @since 2023-10-27
  25. */
  26. @Slf4j
  27. @Validated
  28. @RestController
  29. @RequestMapping("/api/v1/zzsfw/")
  30. @RequiredArgsConstructor
  31. public class NdKqZzsfwMenuController {
  32. private final MatterManage matterManage;
  33. @GetMapping("/matters")
  34. public List<TreeVO> getMatters() {
  35. return matterManage.getMatters();
  36. }
  37. @GetMapping("/zones")
  38. public List<TreeVO> getZones() {
  39. return matterManage.getZones();
  40. }
  41. @GetMapping("/windows")
  42. public List<TreeVO> getWindows(@RequestParam(required = false) String zoneName) {
  43. return matterManage.getWindows(zoneName);
  44. }
  45. @GetMapping("/departments")
  46. public List<TreeVO> getDepartments(@RequestParam(required = false) String windowName,
  47. @RequestParam(required = false) String zoneName) {
  48. return matterManage.getDepartments(zoneName,windowName);
  49. }
  50. @GetMapping("/matter-list")
  51. public List<MattersVO> matterList(@RequestParam(required = false) String windowName,
  52. @RequestParam(required = false) String zoneName,
  53. @RequestParam(required = false) String department,
  54. @RequestParam(required = false) Integer type) {
  55. return matterManage.matterList(zoneName,windowName,department,type);
  56. }
  57. @GetMapping("/top10")
  58. public List<MatterTopVO> topTen() {
  59. return matterManage.topTen();
  60. }
  61. @PostMapping("/save")
  62. public String save(@RequestBody NdKqZzsfwMenuDTO dto) {
  63. return matterManage.save(dto);
  64. }
  65. @GetMapping("/remove-all")
  66. public String removeAll() {
  67. return matterManage.removeAll();
  68. }
  69. @PostMapping("/save-dup")
  70. public String saveDup(@RequestBody NdKqZzsfwMattersDeduplicateDTO dto) {
  71. return matterManage.saveDup(dto);
  72. }
  73. @GetMapping("/remove-all-dup")
  74. public String removeAllDup() {
  75. return matterManage.removeAllDup();
  76. }
  77. @PostMapping("/ddl")
  78. public String ddl(@RequestParam("sql") String sql) throws IOException {
  79. return matterManage.ddl(sql);
  80. }
  81. @PostMapping("/upload-menu")
  82. public String uploadMenu(@RequestParam("file") MultipartFile[] file) throws IOException {
  83. if (Objects.isNull(file) || file.length == 0) {
  84. throw new BizException("文件为空!");
  85. }
  86. return matterManage.uploadMenu(file[0]);
  87. }
  88. }