From ae0d4dd6e574367b5b89a06be90b00f2eb1e40ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Mon, 7 Aug 2023 18:01:22 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=B2=97?= =?UTF-8?q?=E4=BD=8D=E5=A6=82=E6=9E=9C=E7=BB=91=E5=AE=9A=E4=BA=86=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=88=99=E4=B8=8D=E5=85=81=E8=AE=B8=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/common/core/constant/UserConstants.java | 10 ++++++++++ .../system/controller/system/SysPostController.java | 8 +++++++- .../system/service/impl/SysPostServiceImpl.java | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/UserConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/UserConstants.java index c78adc2a..6f3b0b96 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/UserConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/UserConstants.java @@ -52,6 +52,16 @@ public interface UserConstants { */ String DEPT_DISABLE = "1"; + /** + * 岗位正常状态 + */ + String POST_NORMAL = "0"; + + /** + * 岗位停用状态 + */ + String POST_DISABLE = "1"; + /** * 字典正常状态 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysPostController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysPostController.java index 28e56a2f..fe62fdbb 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysPostController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysPostController.java @@ -1,6 +1,7 @@ package org.dromara.system.controller.system; import cn.dev33.satoken.annotation.SaCheckPermission; +import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.domain.R; import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.common.log.annotation.Log; @@ -88,6 +89,9 @@ public class SysPostController extends BaseController { return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (!postService.checkPostCodeUnique(post)) { return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } else if (UserConstants.POST_DISABLE.equals(post.getStatus()) + && postService.countUserPostById(post.getPostId()) > 0) { + return R.fail("该岗位下存在已分配用户,不能禁用!"); } return toAjax(postService.updatePost(post)); } @@ -109,7 +113,9 @@ public class SysPostController extends BaseController { */ @GetMapping("/optionselect") public R> optionselect() { - List posts = postService.selectPostAll(); + SysPostBo postBo = new SysPostBo(); + postBo.setStatus(UserConstants.POST_NORMAL); + List posts = postService.selectPostList(postBo); return R.ok(posts); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java index d9529e70..b69a06c5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysPostServiceImpl.java @@ -156,7 +156,7 @@ public class SysPostServiceImpl implements ISysPostService { for (Long postId : postIds) { SysPost post = baseMapper.selectById(postId); if (countUserPostById(postId) > 0) { - throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName())); + throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName())); } } return baseMapper.deleteBatchIds(Arrays.asList(postIds));