|
@@ -1,17 +1,26 @@
|
|
package cn.cslg.pas.controller;
|
|
package cn.cslg.pas.controller;
|
|
|
|
|
|
import cn.cslg.pas.common.core.base.Constants;
|
|
import cn.cslg.pas.common.core.base.Constants;
|
|
|
|
+import cn.cslg.pas.common.dto.business.EventDTO;
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
import cn.cslg.pas.common.model.request.StringRequest;
|
|
import cn.cslg.pas.common.model.request.StringRequest;
|
|
import cn.cslg.pas.common.utils.Response;
|
|
import cn.cslg.pas.common.utils.Response;
|
|
|
|
+import cn.cslg.pas.domain.Event;
|
|
import cn.cslg.pas.service.Business;
|
|
import cn.cslg.pas.service.Business;
|
|
import cn.cslg.pas.service.business.EventService;
|
|
import cn.cslg.pas.service.business.EventService;
|
|
import cn.cslg.pas.service.query.BusinessFactory;
|
|
import cn.cslg.pas.service.query.BusinessFactory;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
+import lombok.experimental.Accessors;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
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.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author chenyu
|
|
* @author chenyu
|
|
@@ -21,12 +30,49 @@ import org.springframework.web.bind.annotation.RestController;
|
|
@RequestMapping(Constants.API_XiaoSHI + "/event")
|
|
@RequestMapping(Constants.API_XiaoSHI + "/event")
|
|
@RestController
|
|
@RestController
|
|
public class EventController {
|
|
public class EventController {
|
|
|
|
+ @Autowired
|
|
|
|
+ private BusinessFactory businessFactory;
|
|
@Operation(summary = "查询事件")
|
|
@Operation(summary = "查询事件")
|
|
@PostMapping("/queryEvent")
|
|
@PostMapping("/queryEvent")
|
|
- public String queryEvent( StringRequest stringRequest){
|
|
|
|
- EventService business = (EventService)BusinessFactory.getClass(EventService.class);
|
|
|
|
- business.queryMessage(stringRequest);
|
|
|
|
|
|
+ public String queryEvent( StringRequest stringRequest) throws Exception {
|
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
|
+ business.queryMessage(stringRequest);
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Operation(summary = "添加事件")
|
|
|
|
+ @PostMapping("/addEvent")
|
|
|
|
+ public String addEvent(String event, List<MultipartFile> files) throws Exception {
|
|
|
|
+ if (event != null) {
|
|
|
|
+ EventDTO eventDTO = JSONObject.parseObject(event, EventDTO.class);
|
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
|
+ business.addMessage(eventDTO,files);
|
|
|
|
+ return Response.success();
|
|
|
|
+ } else {
|
|
|
|
+ return Response.error("网络异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Operation(summary = "更新事件")
|
|
|
|
+ @PostMapping("/updateEvent")
|
|
|
|
+ public String updateEvent(String event, List<MultipartFile> files) throws Exception {
|
|
|
|
+ if (event != null) {
|
|
|
|
+ EventDTO eventDTO = JSONObject.parseObject(event, EventDTO.class);
|
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
|
+ business.updateMessage(eventDTO,files);
|
|
|
|
+ return Response.success();
|
|
|
|
+ } else {
|
|
|
|
+ return Response.error("网络异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @Operation(summary = "删除事件")
|
|
|
|
+ @PostMapping("/deleteEvent")
|
|
|
|
+ public String queryEvent(@RequestBody List<Integer> ids) throws Exception {
|
|
|
|
+ Business business = businessFactory.getClass("eventService");
|
|
|
|
+ business.deleteMessage(ids);
|
|
|
|
+ return Response.success();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|