郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
package com.gk.hotwork.specialWork.controller;
 
import com.gk.hotwork.Controller.Base.BaseController;
import com.gk.hotwork.Domain.co.ContextCacheUser;
import com.gk.hotwork.Domain.Enum.ResultCodes;
import com.gk.hotwork.Domain.Vo.PageQuery;
import com.gk.hotwork.Domain.Utils.PageUtils;
import com.gk.hotwork.Domain.Vo.ResultVO;
import com.gk.hotwork.doublePrevention.utils.CacheUserTransfer;
import com.gk.hotwork.specialWork.model.dto.req.ApprovalRuleItemAddReqDTO;
import com.gk.hotwork.specialWork.model.dto.req.ApprovalRuleItemModReqDTO;
import com.gk.hotwork.specialWork.model.dto.req.DeleteForm;
import com.gk.hotwork.specialWork.model.dto.resp.ApprovalRuleUnitItemListRespDTO;
import com.gk.hotwork.specialWork.model.dto.resp.ApprovalRuleUnitItemPageRespDTO;
import com.gk.hotwork.specialWork.model.query.ApprovalRuleItemPageQuery;
import com.gk.hotwork.specialWork.model.query.ApprovalRuleItemQuery;
import com.gk.hotwork.specialWork.service.RuleItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
@RequestMapping("/work/ruleItem")
public class RuleItemController extends BaseController {
 
    @Autowired
    private RuleItemService ruleItemService;
 
 
    @RequestMapping(value = "/page/list",method = RequestMethod.POST)
    public ResultVO<List<ApprovalRuleUnitItemPageRespDTO>> ruleItemPageList(Authentication authentication, @RequestBody PageQuery<ApprovalRuleItemPageQuery> pageQuery) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        PageUtils.checkCheck(pageQuery);
        return ruleItemService.listRuleItemByPage(currentUser, pageQuery);
    }
 
 
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public ResultVO<List<ApprovalRuleUnitItemListRespDTO>> ruleItemList(Authentication authentication, @RequestBody ApprovalRuleItemQuery query) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        List<ApprovalRuleUnitItemListRespDTO> data = ruleItemService.listRuleItem(currentUser, query);
        return new ResultVO<>(ResultCodes.OK,data);
    }
 
 
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public ResultVO<String> ruleItemSave(Authentication authentication, @RequestBody ApprovalRuleItemAddReqDTO addReqDTO) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        ruleItemService.saveRuleItem(currentUser,addReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultVO<String> ruleItemUpdate(Authentication authentication, @RequestBody ApprovalRuleItemModReqDTO modReqDTO) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        ruleItemService.updateRuleItem(currentUser, modReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public ResultVO<String> ruleItemDelete(Authentication authentication, @RequestBody DeleteForm deleteForm) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        ruleItemService.deleteRuleItem(currentUser, deleteForm);
        return new ResultVO<>(ResultCodes.OK);
    }
 
}