Commit 424922b488f1c30b7daac0c51abfdd84e92abd82
1 parent
a677e98d
【代码修复】SYSTEM:角色标识的提示不正确问题
Showing
2 changed files
with
6 additions
and
4 deletions
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.permission; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.permission; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.collection.CollectionUtil; | 4 | import cn.hutool.core.collection.CollectionUtil; |
| 5 | +import cn.hutool.core.util.ObjUtil; | ||
| 5 | import cn.hutool.core.util.ObjectUtil; | 6 | import cn.hutool.core.util.ObjectUtil; |
| 6 | import cn.hutool.extra.spring.SpringUtil; | 7 | import cn.hutool.extra.spring.SpringUtil; |
| 7 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| @@ -61,7 +62,7 @@ public class RoleServiceImpl implements RoleService { | @@ -61,7 +62,7 @@ public class RoleServiceImpl implements RoleService { | ||
| 61 | // 2. 插入到数据库 | 62 | // 2. 插入到数据库 |
| 62 | RoleDO role = BeanUtils.toBean(createReqVO, RoleDO.class) | 63 | RoleDO role = BeanUtils.toBean(createReqVO, RoleDO.class) |
| 63 | .setType(ObjectUtil.defaultIfNull(type, RoleTypeEnum.CUSTOM.getType())) | 64 | .setType(ObjectUtil.defaultIfNull(type, RoleTypeEnum.CUSTOM.getType())) |
| 64 | - .setStatus(CommonStatusEnum.ENABLE.getStatus()) | 65 | + .setStatus(ObjUtil.defaultIfNull(createReqVO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) |
| 65 | .setDataScope(DataScopeEnum.ALL.getScope()); // 默认可查看所有数据。原因是,可能一些项目不需要项目权限 | 66 | .setDataScope(DataScopeEnum.ALL.getScope()); // 默认可查看所有数据。原因是,可能一些项目不需要项目权限 |
| 66 | roleMapper.insert(role); | 67 | roleMapper.insert(role); |
| 67 | 68 |
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java
| @@ -51,7 +51,8 @@ public class RoleServiceImplTest extends BaseDbUnitTest { | @@ -51,7 +51,8 @@ public class RoleServiceImplTest extends BaseDbUnitTest { | ||
| 51 | public void testCreateRole() { | 51 | public void testCreateRole() { |
| 52 | // 准备参数 | 52 | // 准备参数 |
| 53 | RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class) | 53 | RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class) |
| 54 | - .setId(null); // 防止 id 被赋值 | 54 | + .setId(null) // 防止 id 被赋值 |
| 55 | + .setStatus(randomCommonStatus()); | ||
| 55 | 56 | ||
| 56 | // 调用 | 57 | // 调用 |
| 57 | Long roleId = roleService.createRole(reqVO, null); | 58 | Long roleId = roleService.createRole(reqVO, null); |
| @@ -59,7 +60,6 @@ public class RoleServiceImplTest extends BaseDbUnitTest { | @@ -59,7 +60,6 @@ public class RoleServiceImplTest extends BaseDbUnitTest { | ||
| 59 | RoleDO roleDO = roleMapper.selectById(roleId); | 60 | RoleDO roleDO = roleMapper.selectById(roleId); |
| 60 | assertPojoEquals(reqVO, roleDO, "id"); | 61 | assertPojoEquals(reqVO, roleDO, "id"); |
| 61 | assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType()); | 62 | assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType()); |
| 62 | - assertEquals(CommonStatusEnum.ENABLE.getStatus(), roleDO.getStatus()); | ||
| 63 | assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope()); | 63 | assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope()); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| @@ -70,7 +70,8 @@ public class RoleServiceImplTest extends BaseDbUnitTest { | @@ -70,7 +70,8 @@ public class RoleServiceImplTest extends BaseDbUnitTest { | ||
| 70 | roleMapper.insert(roleDO); | 70 | roleMapper.insert(roleDO); |
| 71 | // 准备参数 | 71 | // 准备参数 |
| 72 | Long id = roleDO.getId(); | 72 | Long id = roleDO.getId(); |
| 73 | - RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id)); | 73 | + RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id) |
| 74 | + .setStatus(randomCommonStatus())); | ||
| 74 | 75 | ||
| 75 | // 调用 | 76 | // 调用 |
| 76 | roleService.updateRole(reqVO); | 77 | roleService.updateRole(reqVO); |