| | |
| | | import java.util.List;
|
| | | import jakarta.servlet.http.HttpServletResponse;
|
| | | import lombok.AllArgsConstructor;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.project.system.service.ISysPostService;
|
| | |
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:post:query')")
|
| | | @GetMapping(value = "/{postId}")
|
| | | public AjaxResult getInfo(@PathVariable Long postId)
|
| | | public R<?> getInfo(@PathVariable Long postId) |
| | | {
|
| | | return success(postService.selectPostById(postId));
|
| | | return R.ok(postService.selectPostById(postId)); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('system:post:add')")
|
| | | @Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysPost post)
|
| | | public R<?> add(@Validated @RequestBody SysPost post) |
| | | {
|
| | | if (!postService.checkPostNameUnique(post))
|
| | | {
|
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
| | | return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | }
|
| | | else if (!postService.checkPostCodeUnique(post))
|
| | | {
|
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
| | | return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | }
|
| | | post.setCreateBy(getUsername());
|
| | | return toAjax(postService.insertPost(post));
|
| | | postService.insertPost(post); |
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('system:post:edit')")
|
| | | @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysPost post)
|
| | | public R<?> edit(@Validated @RequestBody SysPost post) |
| | | {
|
| | | if (!postService.checkPostNameUnique(post))
|
| | | {
|
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
| | | return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | }
|
| | | else if (!postService.checkPostCodeUnique(post))
|
| | | {
|
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
| | | return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | }
|
| | | post.setUpdateBy(getUsername());
|
| | | return toAjax(postService.updatePost(post));
|
| | | postService.updatePost(post); |
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('system:post:remove')")
|
| | | @Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{postIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] postIds)
|
| | | public R<?> remove(@PathVariable Long[] postIds) |
| | | {
|
| | | return toAjax(postService.deletePostByIds(postIds));
|
| | | postService.deletePostByIds(postIds); |
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | | * 获取岗位选择框列表
|
| | | */
|
| | | @GetMapping("/optionselect")
|
| | | public AjaxResult optionselect()
|
| | | public R<?> optionselect() |
| | | {
|
| | | List<SysPost> posts = postService.selectPostAll();
|
| | | return success(posts);
|
| | | return R.ok(posts); |
| | | }
|
| | | }
|