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 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.CollectionUtil; |
| 5 | +import cn.hutool.core.util.ObjUtil; | |
| 5 | 6 | import cn.hutool.core.util.ObjectUtil; |
| 6 | 7 | import cn.hutool.extra.spring.SpringUtil; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| ... | ... | @@ -61,7 +62,7 @@ public class RoleServiceImpl implements RoleService { |
| 61 | 62 | // 2. 插入到数据库 |
| 62 | 63 | RoleDO role = BeanUtils.toBean(createReqVO, RoleDO.class) |
| 63 | 64 | .setType(ObjectUtil.defaultIfNull(type, RoleTypeEnum.CUSTOM.getType())) |
| 64 | - .setStatus(CommonStatusEnum.ENABLE.getStatus()) | |
| 65 | + .setStatus(ObjUtil.defaultIfNull(createReqVO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) | |
| 65 | 66 | .setDataScope(DataScopeEnum.ALL.getScope()); // 默认可查看所有数据。原因是,可能一些项目不需要项目权限 |
| 66 | 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 | 51 | public void testCreateRole() { |
| 52 | 52 | // 准备参数 |
| 53 | 53 | RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class) |
| 54 | - .setId(null); // 防止 id 被赋值 | |
| 54 | + .setId(null) // 防止 id 被赋值 | |
| 55 | + .setStatus(randomCommonStatus()); | |
| 55 | 56 | |
| 56 | 57 | // 调用 |
| 57 | 58 | Long roleId = roleService.createRole(reqVO, null); |
| ... | ... | @@ -59,7 +60,6 @@ public class RoleServiceImplTest extends BaseDbUnitTest { |
| 59 | 60 | RoleDO roleDO = roleMapper.selectById(roleId); |
| 60 | 61 | assertPojoEquals(reqVO, roleDO, "id"); |
| 61 | 62 | assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType()); |
| 62 | - assertEquals(CommonStatusEnum.ENABLE.getStatus(), roleDO.getStatus()); | |
| 63 | 63 | assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope()); |
| 64 | 64 | } |
| 65 | 65 | |
| ... | ... | @@ -70,7 +70,8 @@ public class RoleServiceImplTest extends BaseDbUnitTest { |
| 70 | 70 | roleMapper.insert(roleDO); |
| 71 | 71 | // 准备参数 |
| 72 | 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 | 77 | roleService.updateRole(reqVO); | ... | ... |