| | |
| | | package com.ruoyi.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.web.core.BaseController; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.excel.utils.ExcelUtil; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.web.core.BaseController; |
| | | import com.ruoyi.system.domain.bo.SysPostBo; |
| | | import com.ruoyi.system.domain.vo.SysPostVo; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @SaCheckPermission("system:post:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) { |
| | | public TableDataInfo<SysPostVo> list(SysPostBo post, PageQuery pageQuery) { |
| | | return postService.selectPagePostList(post, pageQuery); |
| | | } |
| | | |
| | |
| | | @Log(title = "岗位管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:post:export") |
| | | @PostMapping("/export") |
| | | public void export(SysPost post, HttpServletResponse response) { |
| | | List<SysPost> list = postService.selectPostList(post); |
| | | ExcelUtil.exportExcel(list, "岗位数据", SysPost.class, response); |
| | | public void export(SysPostBo post, HttpServletResponse response) { |
| | | List<SysPostVo> list = postService.selectPostList(post); |
| | | ExcelUtil.exportExcel(list, "岗位数据", SysPostVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @SaCheckPermission("system:post:query") |
| | | @GetMapping(value = "/{postId}") |
| | | public R<SysPost> getInfo(@PathVariable Long postId) { |
| | | public R<SysPostVo> getInfo(@PathVariable Long postId) { |
| | | return R.ok(postService.selectPostById(postId)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:post:add") |
| | | @Log(title = "岗位管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysPost post) { |
| | | if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { |
| | | public R<Void> add(@Validated @RequestBody SysPostBo post) { |
| | | if (!postService.checkPostNameUnique(post)) { |
| | | return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { |
| | | } else if (!postService.checkPostCodeUnique(post)) { |
| | | return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | return toAjax(postService.insertPost(post)); |
| | |
| | | @SaCheckPermission("system:post:edit") |
| | | @Log(title = "岗位管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysPost post) { |
| | | if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { |
| | | public R<Void> edit(@Validated @RequestBody SysPostBo post) { |
| | | if (!postService.checkPostNameUnique(post)) { |
| | | return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { |
| | | } else if (!postService.checkPostCodeUnique(post)) { |
| | | return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | return toAjax(postService.updatePost(post)); |
| | |
| | | * 获取岗位选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public R<List<SysPost>> optionselect() { |
| | | List<SysPost> posts = postService.selectPostAll(); |
| | | public R<List<SysPostVo>> optionselect() { |
| | | List<SysPostVo> posts = postService.selectPostAll(); |
| | | return R.ok(posts); |
| | | } |
| | | } |