mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
菜单新增/修改重名校验增加归属类型条件筛选
This commit is contained in:
+1
-1
@@ -76,7 +76,7 @@ public class MenuSaveVO {
|
||||
private String description;
|
||||
|
||||
@Schema(description = "菜单归属类型 ,见 MenuSourceTypeValid 枚举",example = "1")
|
||||
@NotNull
|
||||
@NotNull(message = "菜单归属类型不能为空")
|
||||
@MenuSourceTypeValid
|
||||
private Integer sourceType;
|
||||
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface MenuMapper extends BaseMapperX<MenuDO> {
|
||||
|
||||
default MenuDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(MenuDO::getParentId, parentId, MenuDO::getName, name);
|
||||
default MenuDO selectByParentIdAndNameAndSourceType(Long parentId, String name, Integer sourceType) {
|
||||
return selectOne(MenuDO::getParentId, parentId, MenuDO::getName, name, MenuDO::getSourceType, sourceType);
|
||||
}
|
||||
|
||||
default Long selectCountByParentId(Long parentId) {
|
||||
|
||||
+4
-4
@@ -67,7 +67,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
// 校验父菜单存在
|
||||
validateParentMenu(createReqVO.getParentId(), null);
|
||||
// 校验菜单(自己)
|
||||
validateMenu(createReqVO.getParentId(), createReqVO.getName(), null);
|
||||
validateMenu(createReqVO.getParentId(), createReqVO.getName(), null, createReqVO.getSourceType());
|
||||
// 校验管理端菜单增删改必须是晨丰组织下用户
|
||||
validateManageSourceTypeOperatePermission(createReqVO.getSourceType());
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
// 校验父菜单存在
|
||||
validateParentMenu(updateReqVO.getParentId(), updateReqVO.getId());
|
||||
// 校验菜单(自己)
|
||||
validateMenu(updateReqVO.getParentId(), updateReqVO.getName(), updateReqVO.getId());
|
||||
validateMenu(updateReqVO.getParentId(), updateReqVO.getName(), updateReqVO.getId(), updateReqVO.getSourceType());
|
||||
// 校验管理端菜单增删改必须是晨丰组织下用户
|
||||
validateManageSourceTypeOperatePermission(updateReqVO.getSourceType());
|
||||
|
||||
@@ -293,8 +293,8 @@ public class MenuServiceImpl implements MenuService {
|
||||
* @param id 菜单编号
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void validateMenu(Long parentId, String name, Long id) {
|
||||
MenuDO menu = menuMapper.selectByParentIdAndName(parentId, name);
|
||||
void validateMenu(Long parentId, String name, Long id, Integer sourceType) {
|
||||
MenuDO menu = menuMapper.selectByParentIdAndNameAndSourceType(parentId, name, sourceType);
|
||||
if (menu == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@ import com.cf.imes.module.system.controller.admin.permission.vo.menu.MenuListReq
|
||||
import com.cf.imes.module.system.controller.admin.permission.vo.menu.MenuSaveVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.permission.MenuDO;
|
||||
import com.cf.imes.module.system.dal.mysql.permission.MenuMapper;
|
||||
import com.cf.imes.module.system.enums.permission.MenuSourceTypeEnum;
|
||||
import com.cf.imes.module.system.enums.permission.MenuTypeEnum;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -283,7 +284,7 @@ public class MenuServiceImplTest extends BaseDbUnitTest {
|
||||
String otherSonMenuName = randomString();
|
||||
|
||||
// 调用,无需断言
|
||||
menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId);
|
||||
menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId, MenuSourceTypeEnum.PRODUCTION.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -296,7 +297,7 @@ public class MenuServiceImplTest extends BaseDbUnitTest {
|
||||
String otherSonMenuName = sonMenu.getName(); //相同名称
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId),
|
||||
assertServiceException(() -> menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId, MenuSourceTypeEnum.PRODUCTION.getType()),
|
||||
MENU_NAME_DUPLICATE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user