春风项目四线(合箱线、总装线)
wujian
2024-01-22 aead81c14ebf1e592d66293213b61c945dacf7c1
提交 | 用户 | 时间
fd2207 1 package com.jcdm.web.controller.system;
2
3 import java.util.List;
4 import javax.servlet.http.HttpServletResponse;
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.security.access.prepost.PreAuthorize;
7 import org.springframework.validation.annotation.Validated;
8 import org.springframework.web.bind.annotation.DeleteMapping;
9 import org.springframework.web.bind.annotation.GetMapping;
10 import org.springframework.web.bind.annotation.PathVariable;
11 import org.springframework.web.bind.annotation.PostMapping;
12 import org.springframework.web.bind.annotation.PutMapping;
13 import org.springframework.web.bind.annotation.RequestBody;
14 import org.springframework.web.bind.annotation.RequestMapping;
15 import org.springframework.web.bind.annotation.RestController;
16 import com.jcdm.common.annotation.Log;
17 import com.jcdm.common.core.controller.BaseController;
18 import com.jcdm.common.core.domain.AjaxResult;
19 import com.jcdm.common.core.page.TableDataInfo;
20 import com.jcdm.common.enums.BusinessType;
21 import com.jcdm.common.utils.poi.ExcelUtil;
22 import com.jcdm.system.domain.SysPost;
23 import com.jcdm.system.service.ISysPostService;
24
25 /**
26  * 岗位信息操作处理
27  * 
28  * @author jc
29  */
30 @RestController
31 @RequestMapping("/system/post")
32 public class SysPostController extends BaseController
33 {
34     @Autowired
35     private ISysPostService postService;
36
37     /**
38      * 获取岗位列表
39      */
40     @PreAuthorize("@ss.hasPermi('system:post:list')")
41     @GetMapping("/list")
42     public TableDataInfo list(SysPost post)
43     {
44         startPage();
45         List<SysPost> list = postService.selectPostList(post);
46         return getDataTable(list);
47     }
48     
49     @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
50     @PreAuthorize("@ss.hasPermi('system:post:export')")
51     @PostMapping("/export")
52     public void export(HttpServletResponse response, SysPost post)
53     {
54         List<SysPost> list = postService.selectPostList(post);
55         ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
56         util.exportExcel(response, list, "岗位数据");
57     }
58
59     /**
60      * 根据岗位编号获取详细信息
61      */
62     @PreAuthorize("@ss.hasPermi('system:post:query')")
63     @GetMapping(value = "/{postId}")
64     public AjaxResult getInfo(@PathVariable Long postId)
65     {
66         return success(postService.selectPostById(postId));
67     }
68
69     /**
70      * 新增岗位
71      */
72     @PreAuthorize("@ss.hasPermi('system:post:add')")
73     @Log(title = "岗位管理", businessType = BusinessType.INSERT)
74     @PostMapping
75     public AjaxResult add(@Validated @RequestBody SysPost post)
76     {
77         if (!postService.checkPostNameUnique(post))
78         {
79             return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
80         }
81         else if (!postService.checkPostCodeUnique(post))
82         {
83             return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
84         }
85         post.setCreateBy(getUsername());
86         return toAjax(postService.insertPost(post));
87     }
88
89     /**
90      * 修改岗位
91      */
92     @PreAuthorize("@ss.hasPermi('system:post:edit')")
93     @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
94     @PutMapping
95     public AjaxResult edit(@Validated @RequestBody SysPost post)
96     {
97         if (!postService.checkPostNameUnique(post))
98         {
99             return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
100         }
101         else if (!postService.checkPostCodeUnique(post))
102         {
103             return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
104         }
105         post.setUpdateBy(getUsername());
106         return toAjax(postService.updatePost(post));
107     }
108
109     /**
110      * 删除岗位
111      */
112     @PreAuthorize("@ss.hasPermi('system:post:remove')")
113     @Log(title = "岗位管理", businessType = BusinessType.DELETE)
114     @DeleteMapping("/{postIds}")
115     public AjaxResult remove(@PathVariable Long[] postIds)
116     {
117         return toAjax(postService.deletePostByIds(postIds));
118     }
119
120     /**
121      * 获取岗位选择框列表
122      */
123     @GetMapping("/optionselect")
124     public AjaxResult optionselect()
125     {
126         List<SysPost> posts = postService.selectPostAll();
127         return success(posts);
128     }
129 }