TreeNodeController.java 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.base.Constants;
  3. import cn.cslg.pas.common.dto.business.QueryTreeNodeDTO;
  4. import cn.cslg.pas.common.dto.business.TreeNodeDTO;
  5. import cn.cslg.pas.common.model.request.StringRequest;
  6. import cn.cslg.pas.common.utils.Response;
  7. import cn.cslg.pas.exception.ConditionException;
  8. import cn.cslg.pas.exception.UnLoginException;
  9. import cn.cslg.pas.exception.XiaoShiException;
  10. import cn.cslg.pas.factorys.businessFactory.Business;
  11. import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
  12. import io.swagger.v3.oas.annotations.Operation;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import org.springframework.web.multipart.MultipartFile;
  20. import java.util.List;
  21. /**
  22. * 架构的Controller层
  23. * @Author xiexiang
  24. * @Date 2023/10/26
  25. */
  26. @Slf4j
  27. @RequestMapping(Constants.API_XiaoSHI + "/treeNode")
  28. @RestController
  29. public class TreeNodeController {
  30. @Autowired
  31. private BusinessFactory businessFactory;
  32. @Operation(summary = "查询架构")
  33. @PostMapping("/queryTreeNode")
  34. public String queryTreeNode(QueryTreeNodeDTO queryTreeNodeDTO) throws Exception {
  35. Business business = businessFactory.getClass("treeNodeService");
  36. // business.queryMessage(queryTreeNodeDTO);
  37. return "";
  38. }
  39. @Operation(summary = "新增架构")
  40. @PostMapping("/addTreeNode")
  41. public Response addTreeNode(String treeNode, List<MultipartFile> files) throws Exception {
  42. if(treeNode != null){
  43. TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
  44. Business business = businessFactory.getClass("treeNodeService");
  45. Integer id = null;
  46. try {
  47. id = (Integer) business.addMessage(treeNodeDTO, files);
  48. } catch (Exception e){
  49. if(e instanceof XiaoShiException) {
  50. return Response.error(e.getMessage());
  51. } else if (e instanceof UnLoginException) {
  52. return Response.unLogin(e.getMessage());
  53. } else if (e instanceof ConditionException) {
  54. return Response.conditionError(e.getMessage());
  55. }
  56. }
  57. return Response.success(id);
  58. } else {
  59. return Response.error("网络异常");
  60. }
  61. }
  62. @Operation(summary = "更新架构")
  63. @PostMapping("/updateTreeNode")
  64. public Response updateTreeNode(String treeNode, List<MultipartFile> files) throws Exception {
  65. if (treeNode != null) {
  66. TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
  67. Business business = businessFactory.getClass("treeNodeService");
  68. business.updateMessage(treeNodeDTO, files);
  69. return Response.success(1);
  70. } else {
  71. return Response.error("网络异常");
  72. }
  73. }
  74. @Operation(summary = "删除架构")
  75. @PostMapping("/deleteTreeNode")
  76. public String deleteTreeNode(@RequestBody List<Integer> ids) throws Exception {
  77. Business business = businessFactory.getClass("treeNodeService");
  78. business.deleteMessage(ids);
  79. return Response.success();
  80. }
  81. }