diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java index f4a8d4f4c..d848bcb71 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java @@ -48,7 +48,7 @@ public interface NotifySendService { String templateCode, Map templateParams); default void sendBatchNotify(List mobiles, List userIds, Integer userType, - String templateCode, Map templateParams) { + String templateCode, Map templateParams) { throw new UnsupportedOperationException("暂时不支持该操作,感兴趣可以实现该功能哟!"); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java index aa170d36e..f29a76a65 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; @@ -27,7 +28,6 @@ import javax.annotation.Resource; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; @@ -198,7 +198,7 @@ public class RoleServiceImpl implements RoleService { } // 这里采用 for 循环从缓存中获取,主要考虑 Spring CacheManager 无法批量操作的问题 RoleServiceImpl self = getSelf(); - return convertList(ids, self::getRoleFromCache); + return CollectionUtils.convertList(ids, self::getRoleFromCache); } @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/bo/RoleCreateReqBO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/bo/RoleCreateReqBO.java deleted file mode 100644 index d570436d1..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/bo/RoleCreateReqBO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission.bo; - -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -/** - * 角色创建 Request BO - * - * @author 芋道源码 - */ -@Data -public class RoleCreateReqBO { - - /** - * 租户编号 - */ - @NotNull(message = "租户编号不能为空") - private Long tenantId; - - /** - * 角色名称 - */ - @NotBlank(message = "角色名称不能为空") - @Size(max = 30, message = "角色名称长度不能超过30个字符") - private String name; - - /** - * 角色标志 - */ - @NotBlank(message = "角色标志不能为空") - @Size(max = 100, message = "角色标志长度不能超过100个字符") - private String code; - - /** - * 显示顺序 - */ - @NotNull(message = "显示顺序不能为空") - private Integer sort; - - /** - * 角色类型 - */ - @NotNull(message = "角色类型不能为空") - private Integer type; - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java index 7c5078330..9dbdac431 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; import org.assertj.core.util.Lists; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -172,5 +173,18 @@ class NotifySendServiceImplTest extends BaseMockitoUnitTest { NOTIFY_SEND_TEMPLATE_PARAM_MISS, "code"); } + @Test + public void testSendBatchNotify() { + // 准备参数 + // mock 方法 + + // 调用 + UnsupportedOperationException exception = Assertions.assertThrows( + UnsupportedOperationException.class, + () -> notifySendService.sendBatchNotify(null, null, null, null, null) + ); + // 断言 + assertEquals("暂时不支持该操作,感兴趣可以实现该功能哟!", exception.getMessage()); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java index 3a95fd30f..4a1c87386 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java @@ -13,6 +13,8 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -185,6 +187,40 @@ public class MenuServiceImplTest extends BaseDbUnitTest { assertPojoEquals(menu100, result.get(0)); } + @Test + public void testGetMenuIdListByPermissionFromCache() { + // mock 数据 + MenuDO menu100 = randomPojo(MenuDO.class); + menuMapper.insert(menu100); + MenuDO menu101 = randomPojo(MenuDO.class); + menuMapper.insert(menu101); + // 准备参数 + String permission = menu100.getPermission(); + + // 调用 + List ids = menuService.getMenuIdListByPermissionFromCache(permission); + // 断言 + assertEquals(1, ids.size()); + assertEquals(menu100.getId(), ids.get(0)); + } + + @Test + public void testGetMenuList_ids() { + // mock 数据 + MenuDO menu100 = randomPojo(MenuDO.class); + menuMapper.insert(menu100); + MenuDO menu101 = randomPojo(MenuDO.class); + menuMapper.insert(menu101); + // 准备参数 + Collection ids = Collections.singleton(menu100.getId()); + + // 调用 + List list = menuService.getMenuList(ids); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(menu100, list.get(0)); + } + @Test public void testGetMenu() { // mock 数据 diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java index 6b590e161..472968436 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java @@ -233,6 +233,39 @@ public class RoleServiceImplTest extends BaseDbUnitTest { assertPojoEquals(dbRole01, list.get(0)); } + @Test + public void testGetRoleList() { + // mock 数据 + RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); + roleMapper.insert(dbRole01); + RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); + roleMapper.insert(dbRole02); + + // 调用 + List list = roleService.getRoleList(); + // 断言 + assertEquals(2, list.size()); + assertPojoEquals(dbRole01, list.get(0)); + assertPojoEquals(dbRole02, list.get(1)); + } + + @Test + public void testGetRoleList_ids() { + // mock 数据 + RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); + roleMapper.insert(dbRole01); + RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); + roleMapper.insert(dbRole02); + // 准备参数 + Collection ids = singleton(dbRole01.getId()); + + // 调用 + List list = roleService.getRoleList(ids); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbRole01, list.get(0)); + } + @Test public void testGetRoleListFromCache() { try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) {