郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
79
80
81
package com.gkhy.safePlatform.account.controller;
 
 
import com.alibaba.fastjson.JSONObject;
import com.gkhy.safePlatform.account.model.annotation.CommonLogEnable;
import com.gkhy.safePlatform.account.model.dto.req.PositionAddReqDTO;
import com.gkhy.safePlatform.account.model.dto.req.PositionModReqDTO;
import com.gkhy.safePlatform.account.model.dto.resp.PositionDetailRespDTO;
import com.gkhy.safePlatform.account.model.dto.resp.PositionRespDTO;
import com.gkhy.safePlatform.account.model.query.PositionQuery;
import com.gkhy.safePlatform.account.service.PositionService;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.Module;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
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;
 
/**
 * @Description: 岗位
 */
@RestController
@RequestMapping("/position")
public class PositionController {
 
    @Autowired
    private PositionService positionService;
 
 
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public ResultVO<List<PositionRespDTO>> positionList(Authentication authentication, @RequestBody PositionQuery query){
       ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        List<PositionRespDTO> positionRespDTOList = positionService.listPositionInfo(currentUser,query);
        return new ResultVO<>(ResultCodes.OK,positionRespDTOList);
    }
 
 
 
    @RequestMapping(value = "/page/list",method = RequestMethod.POST)
    public ResultVO<List<PositionDetailRespDTO>> positionPageList(Authentication authentication, @RequestBody PageQuery<PositionQuery> pageQuery){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        PageUtils.checkCheck(pageQuery);
        return positionService.listPositionInfoByPage(currentUser,pageQuery);
    }
 
 
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @CommonLogEnable(module = Module.ACCOUNT,content = "新增岗位")
    public ResultVO<String> addPosition(Authentication authentication, @RequestBody PositionAddReqDTO positionAddReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        positionService.addPositionInfo(currentUser, positionAddReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
    @RequestMapping(value = "/mod",method = RequestMethod.POST)
    @CommonLogEnable(module = Module.ACCOUNT,content = "修改岗位")
    public ResultVO<String> modPosition(Authentication authentication, @RequestBody PositionModReqDTO positionModReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        positionService.modPositionInfo(currentUser, positionModReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @CommonLogEnable(module = Module.ACCOUNT,content = "删除岗位")
    public ResultVO<String> delPosition(Authentication authentication, @RequestBody JSONObject json){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        Long positionId = json.getLong("positionId");
        positionService.delPositionInfo(currentUser, positionId);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
}