package cn.cslg.pas.controller; import cn.cslg.pas.common.core.base.Constants; import cn.cslg.pas.common.dto.business.QueryTreeNodeDTO; import cn.cslg.pas.common.dto.business.TreeNodeDTO; import cn.cslg.pas.common.model.request.StringRequest; import cn.cslg.pas.common.utils.Response; import cn.cslg.pas.exception.ConditionException; import cn.cslg.pas.exception.UnLoginException; import cn.cslg.pas.exception.XiaoShiException; import cn.cslg.pas.factorys.businessFactory.Business; import cn.cslg.pas.factorys.businessFactory.BusinessFactory; import io.swagger.v3.oas.annotations.Operation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import java.util.List; /** * 架构的Controller层 * @Author xiexiang * @Date 2023/10/26 */ @Slf4j @RequestMapping(Constants.API_XiaoSHI + "/treeNode") @RestController public class TreeNodeController { @Autowired private BusinessFactory businessFactory; @Operation(summary = "查询架构") @PostMapping("/queryTreeNode") public String queryTreeNode(QueryTreeNodeDTO queryTreeNodeDTO) throws Exception { Business business = businessFactory.getClass("treeNodeService"); // business.queryMessage(queryTreeNodeDTO); return ""; } @Operation(summary = "新增架构") @PostMapping("/addTreeNode") public Response addTreeNode(String treeNode, List files) throws Exception { if(treeNode != null){ TreeNodeDTO treeNodeDTO = new TreeNodeDTO(); Business business = businessFactory.getClass("treeNodeService"); Integer id = null; try { id = (Integer) business.addMessage(treeNodeDTO, files); } catch (Exception e){ if(e instanceof XiaoShiException) { return Response.error(e.getMessage()); } else if (e instanceof UnLoginException) { return Response.unLogin(e.getMessage()); } else if (e instanceof ConditionException) { return Response.conditionError(e.getMessage()); } } return Response.success(id); } else { return Response.error("网络异常"); } } @Operation(summary = "更新架构") @PostMapping("/updateTreeNode") public Response updateTreeNode(String treeNode, List files) throws Exception { if (treeNode != null) { TreeNodeDTO treeNodeDTO = new TreeNodeDTO(); Business business = businessFactory.getClass("treeNodeService"); business.updateMessage(treeNodeDTO, files); return Response.success(1); } else { return Response.error("网络异常"); } } @Operation(summary = "删除架构") @PostMapping("/deleteTreeNode") public String deleteTreeNode(@RequestBody List ids) throws Exception { Business business = businessFactory.getClass("treeNodeService"); business.deleteMessage(ids); return Response.success(); } }