| | |
| | |
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | |
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysPost post)
|
| | | {
|
| | | if (!postService.checkPostNameUnique(post))
|
| | | {
|
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
| | | }
|
| | | else if (!postService.checkPostCodeUnique(post))
|
| | | {
|
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
| | | }
|
| | | // if (!postService.checkPostNameUnique(post))
|
| | | // {
|
| | | // return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
| | | // }
|
| | | // else if (!postService.checkPostCodeUnique(post))
|
| | | // {
|
| | | // return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
| | | // }
|
| | | post.setCreateBy(getUsername());
|
| | | post.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
| | | return toAjax(postService.insertPost(post));
|
| | | }
|
| | |
|
| | |
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysPost post)
|
| | | {
|
| | | if (!postService.checkPostNameUnique(post))
|
| | | {
|
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
| | | }
|
| | | else if (!postService.checkPostCodeUnique(post))
|
| | | {
|
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
| | | }
|
| | | // if (!postService.checkPostNameUnique(post))
|
| | | // {
|
| | | // return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
| | | // }
|
| | | // else if (!postService.checkPostCodeUnique(post))
|
| | | // {
|
| | | // return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
| | | // }
|
| | | post.setUpdateBy(getUsername());
|
| | | return toAjax(postService.updatePost(post));
|
| | | }
|