懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 package cn.stylefeng.guns.sys.modular.rest.controller;
2
3 import cn.stylefeng.guns.base.enums.CommonStatus;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
5 import cn.stylefeng.guns.sys.modular.rest.entity.RestPosition;
6 import cn.stylefeng.guns.sys.modular.rest.service.RestPositionService;
7 import cn.stylefeng.guns.sys.modular.system.model.params.PositionParam;
8 import cn.stylefeng.roses.core.base.controller.BaseController;
9 import cn.stylefeng.roses.core.util.ToolUtil;
10 import cn.stylefeng.roses.kernel.model.exception.RequestEmptyException;
11 import cn.stylefeng.roses.kernel.model.response.ResponseData;
12 import cn.stylefeng.roses.kernel.model.response.SuccessResponseData;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.web.bind.annotation.RequestBody;
15 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RequestParam;
17 import org.springframework.web.bind.annotation.RestController;
18
19
20 /**
21  * 职位表控制器
22  *
23  * @author stylefeng
24  * @Date 2019-06-27 2:47
25  */
26 @RestController
27 @RequestMapping("/rest/position")
28 public class RestPositionController extends BaseController {
29
30     @Autowired
31     private RestPositionService restPositionService;
32
33     /**
34      * 新增接口
35      *
36      * @author stylefeng
37      * @Date 2019-06-27
38      */
39     @RequestMapping("/addItem")
40     public ResponseData addItem(@RequestBody PositionParam positionParam) {
41         this.restPositionService.add(positionParam);
42         return ResponseData.success();
43     }
44
45     /**
46      * 编辑接口
47      *
48      * @author stylefeng
49      * @Date 2019-06-27
50      */
51     @RequestMapping("/editItem")
52     public ResponseData editItem(@RequestBody PositionParam positionParam) {
53         this.restPositionService.update(positionParam);
54         return ResponseData.success();
55     }
56
57     /**
58      * 删除接口
59      *
60      * @author stylefeng
61      * @Date 2019-06-27
62      */
63     @RequestMapping("/delete")
64     public ResponseData delete(@RequestBody PositionParam positionParam) {
65         this.restPositionService.delete(positionParam);
66         return ResponseData.success();
67     }
68
69     /**
70      * 查看详情接口
71      *
72      * @author stylefeng
73      * @Date 2019-06-27
74      */
75     @RequestMapping("/detail")
76     public ResponseData detail(@RequestBody PositionParam positionParam) {
77         RestPosition detail = this.restPositionService.getById(positionParam.getPositionId());
78         return ResponseData.success(detail);
79     }
80
81     /**
82      * 查询列表
83      *
84      * @author stylefeng
85      * @Date 2019-06-27
86      */
87     @RequestMapping("/list")
88     public LayuiPageInfo list(@RequestParam(value = "condition", required = false) String condition) {
89
90         PositionParam positionParam = new PositionParam();
91         if (ToolUtil.isNotEmpty(condition)) {
92             positionParam.setCode(condition);
93             positionParam.setName(condition);
94         }
95
96         return this.restPositionService.findPageBySpec(positionParam);
97     }
98
99     /**
100      * 修改状态
101      *
102      * @author stylefeng
103      * @Date 2019-06-27
104      */
105     @RequestMapping("/changeStatus")
106     public ResponseData changeStatus(@RequestParam("positionId") String positionId,
107                                      @RequestParam("status") Boolean status) {
108
109         RestPosition position = this.restPositionService.getById(positionId);
110         if (position == null) {
111             throw new RequestEmptyException();
112         }
113
114         if (status) {
115             position.setStatus(CommonStatus.ENABLE.getCode());
116         } else {
117             position.setStatus(CommonStatus.DISABLE.getCode());
118         }
119
120         this.restPositionService.updateById(position);
121
122         return new SuccessResponseData();
123     }
124
125     /**
126      * 查询所有职位
127      *
128      * @author stylefeng
129      * @Date 2019-03-13
130      */
131     @RequestMapping("/listPositions")
132     public LayuiPageInfo listlistPositionsTypes(@RequestParam(value = "userId", required = false) Long userId) {
133         return this.restPositionService.listPositions(userId);
134     }
135
136
137 }
138
139