Skip to content

Commit

Permalink
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-…
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Aug 31, 2024
2 parents 8829abe + 424922b commit 80c8311
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
Expand Down Expand Up @@ -61,7 +62,7 @@ public Long createRole(RoleSaveReqVO createReqVO, Integer type) {
// 2. 插入到数据库
RoleDO role = BeanUtils.toBean(createReqVO, RoleDO.class)
.setType(ObjectUtil.defaultIfNull(type, RoleTypeEnum.CUSTOM.getType()))
.setStatus(CommonStatusEnum.ENABLE.getStatus())
.setStatus(ObjUtil.defaultIfNull(createReqVO.getStatus(), CommonStatusEnum.ENABLE.getStatus()))
.setDataScope(DataScopeEnum.ALL.getScope()); // 默认可查看所有数据。原因是,可能一些项目不需要项目权限
roleMapper.insert(role);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public class RoleServiceImplTest extends BaseDbUnitTest {
public void testCreateRole() {
// 准备参数
RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class)
.setId(null); // 防止 id 被赋值
.setId(null) // 防止 id 被赋值
.setStatus(randomCommonStatus());

// 调用
Long roleId = roleService.createRole(reqVO, null);
// 断言
RoleDO roleDO = roleMapper.selectById(roleId);
assertPojoEquals(reqVO, roleDO, "id");
assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType());
assertEquals(CommonStatusEnum.ENABLE.getStatus(), roleDO.getStatus());
assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope());
}

Expand All @@ -70,7 +70,8 @@ public void testUpdateRole() {
roleMapper.insert(roleDO);
// 准备参数
Long id = roleDO.getId();
RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id));
RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id)
.setStatus(randomCommonStatus()));

// 调用
roleService.updateRole(reqVO);
Expand Down

0 comments on commit 80c8311

Please sign in to comment.