diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index b561693d69df1ba98367d8bb9fa805eca20e2ecd..9f8364e4eca0a7023e8ab8729c7c397eb0196010 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -12,7 +12,7 @@ import me.zhyd.oauth.model.AuthResponse; import me.zhyd.oauth.model.AuthUser; import me.zhyd.oauth.request.AuthRequest; import me.zhyd.oauth.utils.AuthStateUtils; -import org.dromara.common.core.constant.UserConstants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.model.LoginBody; import org.dromara.common.core.domain.model.RegisterBody; @@ -92,7 +92,7 @@ public class AuthController { if (ObjectUtil.isNull(client) || !StringUtils.contains(client.getGrantType(), grantType)) { log.info("客户端id: {} 认证类型:{} 异常!.", clientId, grantType); return R.fail(MessageUtils.message("auth.grant.type.error")); - } else if (!UserConstants.NORMAL.equals(client.getStatus())) { + } else if (!StatusConstants.ENABLED_STATUS.equals(client.getStatus())) { return R.fail(MessageUtils.message("auth.grant.type.blocked")); } // 校验租户 diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/StatusConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/StatusConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..e746c0935a5516c0d43c42a06bab32b45946dde2 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/StatusConstants.java @@ -0,0 +1,50 @@ +package org.dromara.common.core.constant; + +/** + * 全局状态常量 + * + * @author 秋辞未寒 + */ +public interface StatusConstants { + + /** + * 启用/正常状态 + */ + String ENABLED_STATUS = "0"; + + /** + * 禁用/停用状态 + */ + String DISABLED_STATUS = "1"; + + /** + * 是 (代码Y) + */ + String YES_CODE = "Y"; + + /** + * 否 (代码N) + */ + String NO_CODE = "N"; + + /** + * 是 (数字0) + */ + String YES_NUMBER = "0"; + + /** + * 否 (数字1) + */ + String NO_NUMBER = "1"; + + /** + * 未删除 + */ + String DELETED_FALSE = "0"; + + /** + * 已删除 + */ + String DELETED_TRUE = "2"; + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/TenantConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/TenantConstants.java index 86b63c97acaf5f83a5cbbbfe6c1e4f8874e1667f..33ce0cf6ca87f977487b3db1d6a1b68b8daf4e04 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/TenantConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/TenantConstants.java @@ -7,16 +7,6 @@ package org.dromara.common.core.constant; */ public interface TenantConstants { - /** - * 租户正常状态 - */ - String NORMAL = "0"; - - /** - * 租户封禁状态 - */ - String DISABLE = "1"; - /** * 超级管理员ID */ 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 76f6dd4addd9261d6963f2553f3621c543d3a829..70915f8191d3d1f470b30013a3589aa713151a54 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 @@ -12,95 +12,15 @@ public interface UserConstants { */ String SYS_USER = "SYS_USER"; - /** - * 正常状态 - */ - String NORMAL = "0"; - - /** - * 异常状态 - */ - String EXCEPTION = "1"; - - /** - * 用户正常状态 - */ - String USER_NORMAL = "0"; - - /** - * 用户封禁状态 - */ - String USER_DISABLE = "1"; - - /** - * 角色正常状态 - */ - String ROLE_NORMAL = "0"; - - /** - * 角色封禁状态 - */ - String ROLE_DISABLE = "1"; - - /** - * 部门正常状态 - */ - String DEPT_NORMAL = "0"; - - /** - * 部门停用状态 - */ - String DEPT_DISABLE = "1"; - - /** - * 岗位正常状态 - */ - String POST_NORMAL = "0"; - - /** - * 岗位停用状态 - */ - String POST_DISABLE = "1"; - - /** - * 字典正常状态 - */ - String DICT_NORMAL = "0"; - - /** - * 通用存在标志 - */ - String DEL_FLAG_NORMAL = "0"; - - /** - * 通用删除标志 - */ - String DEL_FLAG_REMOVED = "2"; - - /** - * 是否为系统默认(是) - */ - String YES = "Y"; - /** * 是否菜单外链(是) */ - String YES_FRAME = "0"; + String YES_FRAME = StatusConstants.YES_NUMBER; /** * 是否菜单外链(否) */ - String NO_FRAME = "1"; - - /** - * 菜单正常状态 - */ - String MENU_NORMAL = "0"; - - /** - * 菜单停用状态 - */ - String MENU_DISABLE = "1"; + String NO_FRAME = StatusConstants.NO_NUMBER; /** * 菜单类型(目录) @@ -149,4 +69,9 @@ public interface UserConstants { */ Long SUPER_ADMIN_ID = 1L; + /** + * 部门祖级根ID + */ + String DEPT_ANCESTORS_ROOT_ID = "0"; + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java index 968bbe906b51b416b0b2e128b80302c3fc043f91..c5fd3b53ee76677d07116de7a34a23d434c9868f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java @@ -3,7 +3,7 @@ package org.dromara.system.controller.system; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.hutool.core.convert.Convert; import lombok.RequiredArgsConstructor; -import org.dromara.common.core.constant.UserConstants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.log.annotation.Log; @@ -94,7 +94,7 @@ public class SysDeptController extends BaseController { return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(deptId)) { return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); - } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())) { + } else if (StringUtils.equals(StatusConstants.DISABLED_STATUS, dept.getStatus())) { if (deptService.selectNormalChildrenDeptById(deptId) > 0) { return R.fail("该部门包含未停用的子部门!"); } else if (deptService.checkDeptExistUser(deptId)) { 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 782bcfc55d00e20e1c12c8bbf5368ff7adf63a8d..b7ebc87a9d8e4786692cce62f157a543404241d1 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 @@ -4,7 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission; import cn.hutool.core.util.ObjectUtil; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import org.dromara.common.core.constant.UserConstants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.domain.R; import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.common.log.annotation.Log; @@ -91,7 +91,7 @@ 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()) + } else if (StatusConstants.DISABLED_STATUS.equals(post.getStatus()) && postService.countUserPostById(post.getPostId()) > 0) { return R.fail("该岗位下存在已分配用户,不能禁用!"); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java index 025800de9ac4e95c32f9fd37c8703b1b33c7d887..1d9149f2cd9445500fafd8e8b09c683ad7b85183 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java @@ -8,7 +8,7 @@ import cn.hutool.core.util.ObjectUtil; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; -import org.dromara.common.core.constant.UserConstants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.model.LoginUser; import org.dromara.common.core.utils.StreamUtils; @@ -143,7 +143,7 @@ public class SysUserController extends BaseController { } } SysRoleBo roleBo = new SysRoleBo(); - roleBo.setStatus(UserConstants.ROLE_NORMAL); + roleBo.setStatus(StatusConstants.ENABLED_STATUS); List roles = roleService.selectRoleList(roleBo); userInfoVo.setRoles(LoginHelper.isSuperAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isSuperAdmin())); return R.ok(userInfoVo); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDictData.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDictData.java index 6884fc2dbc69d1b4594372a63d2c8cbddef72b6c..a9ab101c6afd54b6f9bde22f5ceb2f89716040f2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDictData.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDictData.java @@ -2,10 +2,10 @@ package org.dromara.system.domain; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import org.dromara.common.core.constant.UserConstants; -import org.dromara.common.tenant.core.TenantEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import org.dromara.common.core.constant.StatusConstants; +import org.dromara.common.tenant.core.TenantEntity; /** * 字典数据表 sys_dict_data @@ -65,7 +65,7 @@ public class SysDictData extends TenantEntity { private String remark; public boolean getDefault() { - return UserConstants.YES.equals(this.isDefault); + return StatusConstants.YES_CODE.equals(this.isDefault); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysMenuMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysMenuMapper.java index ac646c0968031cfbba8fb55a621bc6fd7a9eb62f..eb6647c299c3cea5a96f1b93d77bd51987e49587 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysMenuMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysMenuMapper.java @@ -3,6 +3,7 @@ package org.dromara.system.mapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Constants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.constant.UserConstants; import org.dromara.system.domain.SysMenu; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; @@ -50,7 +51,7 @@ public interface SysMenuMapper extends BaseMapperPlus { default List selectMenuTreeAll() { LambdaQueryWrapper lqw = new LambdaQueryWrapper() .in(SysMenu::getMenuType, UserConstants.TYPE_DIR, UserConstants.TYPE_MENU) - .eq(SysMenu::getStatus, UserConstants.MENU_NORMAL) + .eq(SysMenu::getStatus, StatusConstants.ENABLED_STATUS) .orderByAsc(SysMenu::getParentId) .orderByAsc(SysMenu::getOrderNum); return this.selectList(lqw); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysConfigServiceImpl.java index 46526bd9850a6c35ab95f875e828992bf8c48fb8..439fb179c6385858de238dc23bd97fc07ccc48a4 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysConfigServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.dromara.common.core.constant.CacheNames; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.service.ConfigService; @@ -173,7 +174,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { public void deleteConfigByIds(Long[] configIds) { for (Long configId : configIds) { SysConfig config = baseMapper.selectById(configId); - if (StringUtils.equals(UserConstants.YES, config.getConfigType())) { + if (StringUtils.equals(StatusConstants.YES_CODE, config.getConfigType())) { throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); } CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey()); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java index c17391674cad63b571a4f4cf0b31a73d8df860a1..0466b5fee2133ef6975c325f228c646b4890cb10 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java @@ -9,14 +9,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import org.dromara.common.core.constant.CacheNames; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.service.DeptService; -import org.dromara.common.core.utils.MapstructUtils; -import org.dromara.common.core.utils.SpringUtils; -import org.dromara.common.core.utils.StringUtils; -import org.dromara.common.core.utils.StreamUtils; -import org.dromara.common.core.utils.TreeBuildUtils; +import org.dromara.common.core.utils.*; import org.dromara.common.mybatis.helper.DataBaseHelper; import org.dromara.common.redis.utils.CacheUtils; import org.dromara.common.satoken.utils.LoginHelper; @@ -71,7 +68,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { @Override public List> selectDeptTreeList(SysDeptBo bo) { // 只查询未禁用部门 - bo.setStatus(UserConstants.DEPT_NORMAL); + bo.setStatus(StatusConstants.ENABLED_STATUS); LambdaQueryWrapper lqw = buildQueryWrapper(bo); List depts = baseMapper.selectDeptList(lqw); return buildDeptTreeSelect(depts); @@ -79,7 +76,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { private LambdaQueryWrapper buildQueryWrapper(SysDeptBo bo) { LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); - lqw.eq(SysDept::getDelFlag, UserConstants.DEL_FLAG_NORMAL); + lqw.eq(SysDept::getDelFlag, StatusConstants.DELETED_FALSE); lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId()); lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId()); lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName()); @@ -156,7 +153,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { public List selectDeptByIds(List deptIds) { return baseMapper.selectDeptList(new LambdaQueryWrapper() .select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getLeader) - .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL) + .eq(SysDept::getStatus, StatusConstants.ENABLED_STATUS) .in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds)); } @@ -187,7 +184,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { @Override public long selectNormalChildrenDeptById(Long deptId) { return baseMapper.selectCount(new LambdaQueryWrapper() - .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL) + .eq(SysDept::getStatus, StatusConstants.ENABLED_STATUS) .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); } @@ -258,7 +255,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { public int insertDept(SysDeptBo bo) { SysDept info = baseMapper.selectById(bo.getParentId()); // 如果父节点不为正常状态,则不允许新增子节点 - if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { + if (!StatusConstants.ENABLED_STATUS.equals(info.getStatus())) { throw new ServiceException("部门停用,不允许新增"); } SysDept dept = MapstructUtils.convert(bo, SysDept.class); @@ -294,8 +291,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { dept.setAncestors(oldDept.getAncestors()); } int result = baseMapper.updateById(dept); - if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) - && !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) { + if (StatusConstants.ENABLED_STATUS.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) + // 部门祖级id为0则不再处理 + && !StringUtils.equals(UserConstants.DEPT_ANCESTORS_ROOT_ID, dept.getAncestors())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatusNormal(dept); } @@ -311,7 +309,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService { String ancestors = dept.getAncestors(); Long[] deptIds = Convert.toLongArray(ancestors); baseMapper.update(null, new LambdaUpdateWrapper() - .set(SysDept::getStatus, UserConstants.DEPT_NORMAL) + .set(SysDept::getStatus, StatusConstants.ENABLED_STATUS) .in(SysDept::getDeptId, Arrays.asList(deptIds))); } 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 e3f4145b4464506f52659aedd1b8287dd88a740e..6f948d2f4727fa76690597634af1711e4d0bbe9d 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 @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; -import org.dromara.common.core.constant.UserConstants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StreamUtils; @@ -128,7 +128,7 @@ public class SysPostServiceImpl implements ISysPostService { public List selectPostByIds(List postIds) { return baseMapper.selectVoList(new LambdaQueryWrapper() .select(SysPost::getPostId, SysPost::getPostName, SysPost::getPostCode) - .eq(SysPost::getStatus, UserConstants.POST_NORMAL) + .eq(SysPost::getStatus, StatusConstants.ENABLED_STATUS) .in(CollUtil.isNotEmpty(postIds), SysPost::getPostId, postIds)); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java index fee0a5b77c1daffcd73c1ab3e22c3cd3a711018f..098e0948dfcf7fa288e768c3c9e21e62cd7c5310 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java @@ -12,8 +12,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.constant.TenantConstants; -import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.domain.model.LoginUser; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; @@ -72,7 +72,7 @@ public class SysRoleServiceImpl implements ISysRoleService { private Wrapper buildQueryWrapper(SysRoleBo bo) { Map params = bo.getParams(); QueryWrapper wrapper = Wrappers.query(); - wrapper.eq("r.del_flag", UserConstants.ROLE_NORMAL) + wrapper.eq("r.del_flag", StatusConstants.DELETED_FALSE) .eq(ObjectUtil.isNotNull(bo.getRoleId()), "r.role_id", bo.getRoleId()) .like(StringUtils.isNotBlank(bo.getRoleName()), "r.role_name", bo.getRoleName()) .eq(StringUtils.isNotBlank(bo.getStatus()), "r.status", bo.getStatus()) @@ -174,7 +174,7 @@ public class SysRoleServiceImpl implements ISysRoleService { @Override public List selectRoleByIds(List roleIds) { return baseMapper.selectRoleList(new QueryWrapper() - .eq("r.status", UserConstants.ROLE_NORMAL) + .eq("r.status", StatusConstants.ENABLED_STATUS) .in(CollUtil.isNotEmpty(roleIds), "r.role_id", roleIds)); } @@ -294,7 +294,7 @@ public class SysRoleServiceImpl implements ISysRoleService { public int updateRole(SysRoleBo bo) { SysRole role = MapstructUtils.convert(bo, SysRole.class); - if (UserConstants.ROLE_DISABLE.equals(role.getStatus()) && this.countUserRoleByRoleId(role.getRoleId()) > 0) { + if (StatusConstants.DISABLED_STATUS.equals(role.getStatus()) && this.countUserRoleByRoleId(role.getRoleId()) > 0) { throw new ServiceException("角色已分配,不能禁用!"); } // 修改角色信息 @@ -313,7 +313,7 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override public int updateRoleStatus(Long roleId, String status) { - if (UserConstants.ROLE_DISABLE.equals(status) && this.countUserRoleByRoleId(roleId) > 0) { + if (StatusConstants.DISABLED_STATUS.equals(status) && this.countUserRoleByRoleId(roleId) > 0) { throw new ServiceException("角色已分配,不能禁用!"); } return baseMapper.update(null, diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantPackageServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantPackageServiceImpl.java index d2a72f611d887be130558fb1b95822bc85e4d842..752fd2da98d008c5275f9454d0ab1a938f7d753c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantPackageServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantPackageServiceImpl.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; -import org.dromara.common.core.constant.TenantConstants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; @@ -59,7 +59,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService { @Override public List selectList() { return baseMapper.selectVoList(new LambdaQueryWrapper() - .eq(SysTenantPackage::getStatus, TenantConstants.NORMAL)); + .eq(SysTenantPackage::getStatus, StatusConstants.ENABLED_STATUS)); } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java index 747654982746b6ccb745c098e3d76d79eabf9cb4..64c985048f88c9a001de0f941b6d04edf838fcd0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import org.dromara.common.core.constant.CacheNames; import org.dromara.common.core.constant.Constants; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; @@ -231,7 +232,7 @@ public class SysTenantServiceImpl implements ISysTenantService { role.setRoleName(TenantConstants.TENANT_ADMIN_ROLE_NAME); role.setRoleKey(TenantConstants.TENANT_ADMIN_ROLE_KEY); role.setRoleSort(1); - role.setStatus(TenantConstants.NORMAL); + role.setStatus(StatusConstants.ENABLED_STATUS); roleMapper.insert(role); Long roleId = role.getRoleId(); @@ -398,7 +399,7 @@ public class SysTenantServiceImpl implements ISysTenantService { // 获取所有租户编号 List tenantIds = baseMapper.selectObjs( new LambdaQueryWrapper().select(SysTenant::getTenantId) - .eq(SysTenant::getStatus, TenantConstants.NORMAL), x -> {return Convert.toStr(x);}); + .eq(SysTenant::getStatus, StatusConstants.ENABLED_STATUS), x -> {return Convert.toStr(x);}); List saveTypeList = new ArrayList<>(); List saveDataList = new ArrayList<>(); Set set = new HashSet<>(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java index cd69767cc4a490020542b1131b9281dfd47b10be..e78a79470c18dcf2f5902ece1f3aade76dfd5368 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.constant.CacheNames; +import org.dromara.common.core.constant.StatusConstants; import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.domain.dto.UserDTO; import org.dromara.common.core.exception.ServiceException; @@ -80,7 +81,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { private Wrapper buildQueryWrapper(SysUserBo user) { Map params = user.getParams(); QueryWrapper wrapper = Wrappers.query(); - wrapper.eq("u.del_flag", UserConstants.USER_NORMAL) + wrapper.eq("u.del_flag", StatusConstants.DELETED_FALSE) .eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId()) .like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName()) .eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus()) @@ -108,7 +109,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { @Override public TableDataInfo selectAllocatedList(SysUserBo user, PageQuery pageQuery) { QueryWrapper wrapper = Wrappers.query(); - wrapper.eq("u.del_flag", UserConstants.USER_NORMAL) + wrapper.eq("u.del_flag", StatusConstants.DELETED_FALSE) .eq(ObjectUtil.isNotNull(user.getRoleId()), "r.role_id", user.getRoleId()) .like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName()) .eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus()) @@ -128,7 +129,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { public TableDataInfo selectUnallocatedList(SysUserBo user, PageQuery pageQuery) { List userIds = userRoleMapper.selectUserIdsByRoleId(user.getRoleId()); QueryWrapper wrapper = Wrappers.query(); - wrapper.eq("u.del_flag", UserConstants.USER_NORMAL) + wrapper.eq("u.del_flag", StatusConstants.DELETED_FALSE) .and(w -> w.ne("r.role_id", user.getRoleId()).or().isNull("r.role_id")) .notIn(CollUtil.isNotEmpty(userIds), "u.user_id", userIds) .like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName()) @@ -187,7 +188,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { public List selectUserByIds(List userIds, Long deptId) { return baseMapper.selectUserList(new LambdaQueryWrapper() .select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName) - .eq(SysUser::getStatus, UserConstants.USER_NORMAL) + .eq(SysUser::getStatus, StatusConstants.ENABLED_STATUS) .eq(ObjectUtil.isNotNull(deptId), SysUser::getDeptId, deptId) .in(CollUtil.isNotEmpty(userIds), SysUser::getUserId, userIds)); } @@ -639,7 +640,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { } List list = baseMapper.selectVoList(new LambdaQueryWrapper() .select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName, SysUser::getEmail, SysUser::getPhonenumber) - .eq(SysUser::getStatus, UserConstants.USER_NORMAL) + .eq(SysUser::getStatus, StatusConstants.ENABLED_STATUS) .in(SysUser::getUserId, userIds)); return BeanUtil.copyToList(list, UserDTO.class); } @@ -695,7 +696,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { } List list = baseMapper.selectVoList(new LambdaQueryWrapper() .select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName, SysUser::getEmail, SysUser::getPhonenumber) - .eq(SysUser::getStatus, UserConstants.USER_NORMAL) + .eq(SysUser::getStatus, StatusConstants.ENABLED_STATUS) .in(SysUser::getDeptId, deptIds)); return BeanUtil.copyToList(list, UserDTO.class); }