|
@@ -0,0 +1,101 @@
|
|
|
+package cn.cslg.pas.controller;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.core.base.Constants;
|
|
|
+import cn.cslg.pas.common.dto.business.EventDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.UpdateEventDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
+import cn.cslg.pas.common.model.request.StringGroupRequest;
|
|
|
+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 com.alibaba.fastjson.JSONObject;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 李仁杰
|
|
|
+ * @date 2023/10/43
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequestMapping(Constants.API_XiaoSHI + "/patentProject")
|
|
|
+@RestController
|
|
|
+public class PatentProjectController {
|
|
|
+ @Autowired
|
|
|
+ private BusinessFactory businessFactory;
|
|
|
+
|
|
|
+ @Operation(summary = "查询专利数据库")
|
|
|
+ @PostMapping("/queryPatentProject")
|
|
|
+ public Response queryEvent(@RequestBody StringRequest stringRequest) throws Exception {
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
+ Records records = (Records) business.queryMessage(stringRequest);
|
|
|
+ return Response.success(records);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Operation(summary = "添加专利数据库")
|
|
|
+ @PostMapping("/addPatentProject")
|
|
|
+ public Response addEvent(String event, List<MultipartFile> files) throws Exception {
|
|
|
+ if (event != null) {
|
|
|
+ EventDTO eventDTO = JSONObject.parseObject(event, EventDTO.class);
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
+ Integer id = null;
|
|
|
+ try {
|
|
|
+ id = (Integer) business.addMessage(eventDTO, 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("/updatePatentProject")
|
|
|
+ public Response updateEvent(String event, List<MultipartFile> files) throws Exception {
|
|
|
+ if (event != null) {
|
|
|
+ UpdateEventDTO updateEventDTO = JSONObject.parseObject(event, UpdateEventDTO.class);
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
+ business.updateMessage(updateEventDTO, files);
|
|
|
+ return Response.success(1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return Response.error("网络异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "删除专利数据库")
|
|
|
+ @PostMapping("/deletePatentProject")
|
|
|
+ public String deleteEvent(@RequestBody List<Integer> ids) throws Exception {
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
+ business.deleteMessage(ids);
|
|
|
+ return Response.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "分组专利数据库")
|
|
|
+ @PostMapping("/groupPatentProject")
|
|
|
+ public Response groupEvent(@RequestBody StringGroupRequest stringGroupRequest) throws Exception {
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
+ Records records = (Records)business.getGroup(stringGroupRequest,"event");
|
|
|
+ return Response.success(records);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|