songhuangfeng123
2022-09-19 aaef9e1eac918cf0cc2d6aa788016ac594de9e6b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.gkhy.safePlatform.emergency.controller;
 
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.emergency.model.dto.req.EmergencyPlanReqDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyPlanDetailRespDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyPlanPageRespDTO;
import com.gkhy.safePlatform.emergency.query.EmergencyPlanQuery;
import com.gkhy.safePlatform.emergency.service.EmergencyPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
 
import java.security.Principal;
import java.util.List;
 
@RestController
@RequestMapping("/emergencyPlan")
public class EmergencyPlanController {
 
    @Autowired
    private EmergencyPlanService emergencyPlanService;
 
    /**
     * 应急预案列表
     */
    @RequestMapping(value = "/page/list" ,method = RequestMethod.POST)
    private ResultVO<List<EmergencyPlanPageRespDTO>> list (Authentication authentication,@RequestBody PageQuery<EmergencyPlanQuery> pageQuery){
        PageUtils.checkCheck(pageQuery);
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return  emergencyPlanService.selectEmergencyPlanList(currentUser.getUid(),pageQuery);
    }
 
    /**
     * 应急预案新增
     */
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultVO addEmergencyPlan(Authentication authentication, @RequestBody EmergencyPlanReqDTO emergencyPlanReqDTO) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return emergencyPlanService.addEmergencyPlan(currentUser.getUid(), emergencyPlanReqDTO);
    }
 
    /**
     * 应急预案详情
     */
    @RequestMapping(value = "/info/{id}",method = RequestMethod.GET)
    public ResultVO<EmergencyPlanDetailRespDTO> getEmergencyPlanById(@PathVariable("id")Long id){
        return emergencyPlanService.getEmergencyPlanById(id);
    }
 
    /**
     * 应急预案修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultVO updateEmergencyPlan(Authentication authentication, @RequestBody EmergencyPlanReqDTO emergencyPlanReqDTO) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return emergencyPlanService.updateEmergencyPlan(currentUser.getUid(), emergencyPlanReqDTO);
    }
 
    /**
     * 应急预案删除/批量删除
     */
    @RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
    public ResultVO batchDeleteEmergencyPlan(@RequestBody Long[] ids){
        return emergencyPlanService.batchDeleteEmergencyPlan(ids);
    }
 
    /**
     * 应急预案废止/还原
     */
    @RequestMapping(value = "/updateAbolish",method = RequestMethod.GET)
    public ResultVO updateAbolish(Long id ,Boolean abolishStatus){
        return emergencyPlanService.updateAbolish(id,abolishStatus);
    }
 
}