mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	infra:完善 config 的单元测试
This commit is contained in:
		@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.controller.admin.user;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileRespVO;
 | 
			
		||||
@@ -31,6 +30,7 @@ import javax.annotation.Resource;
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 | 
			
		||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_IS_EMPTY;
 | 
			
		||||
@@ -99,7 +99,7 @@ public class UserProfileController {
 | 
			
		||||
    @ApiOperation("上传用户个人头像")
 | 
			
		||||
    public CommonResult<String> updateUserAvatar(@RequestParam("avatarFile") MultipartFile file) throws Exception {
 | 
			
		||||
        if (file.isEmpty()) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(FILE_IS_EMPTY);
 | 
			
		||||
            throw exception(FILE_IS_EMPTY);
 | 
			
		||||
        }
 | 
			
		||||
        String avatar = userService.updateUserAvatar(getLoginUserId(), file.getInputStream());
 | 
			
		||||
        return success(avatar);
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.service.permission;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO;
 | 
			
		||||
@@ -31,6 +30,7 @@ import javax.annotation.Resource;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO.ID_ROOT;
 | 
			
		||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
 | 
			
		||||
 | 
			
		||||
@@ -118,7 +118,7 @@ public class MenuServiceImpl implements MenuService {
 | 
			
		||||
    public void updateMenu(MenuUpdateReqVO reqVO) {
 | 
			
		||||
        // 校验更新的菜单是否存在
 | 
			
		||||
        if (menuMapper.selectById(reqVO.getId()) == null) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_NOT_EXISTS);
 | 
			
		||||
            throw exception(MENU_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
        // 校验父菜单存在
 | 
			
		||||
        validateParentMenu(reqVO.getParentId(), reqVO.getId());
 | 
			
		||||
@@ -138,11 +138,11 @@ public class MenuServiceImpl implements MenuService {
 | 
			
		||||
    public void deleteMenu(Long menuId) {
 | 
			
		||||
        // 校验是否还有子菜单
 | 
			
		||||
        if (menuMapper.selectCountByParentId(menuId) > 0) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_EXISTS_CHILDREN);
 | 
			
		||||
            throw exception(MENU_EXISTS_CHILDREN);
 | 
			
		||||
        }
 | 
			
		||||
        // 校验删除的菜单是否存在
 | 
			
		||||
        if (menuMapper.selectById(menuId) == null) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_NOT_EXISTS);
 | 
			
		||||
            throw exception(MENU_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
        // 标记删除
 | 
			
		||||
        menuMapper.deleteById(menuId);
 | 
			
		||||
@@ -229,17 +229,17 @@ public class MenuServiceImpl implements MenuService {
 | 
			
		||||
        }
 | 
			
		||||
        // 不能设置自己为父菜单
 | 
			
		||||
        if (parentId.equals(childId)) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_PARENT_ERROR);
 | 
			
		||||
            throw exception(MENU_PARENT_ERROR);
 | 
			
		||||
        }
 | 
			
		||||
        MenuDO menu = menuMapper.selectById(parentId);
 | 
			
		||||
        // 父菜单不存在
 | 
			
		||||
        if (menu == null) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_PARENT_NOT_EXISTS);
 | 
			
		||||
            throw exception(MENU_PARENT_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
        // 父菜单必须是目录或者菜单类型
 | 
			
		||||
        if (!MenuTypeEnum.DIR.getType().equals(menu.getType())
 | 
			
		||||
            && !MenuTypeEnum.MENU.getType().equals(menu.getType())) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_PARENT_NOT_DIR_OR_MENU);
 | 
			
		||||
            throw exception(MENU_PARENT_NOT_DIR_OR_MENU);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -260,10 +260,10 @@ public class MenuServiceImpl implements MenuService {
 | 
			
		||||
        }
 | 
			
		||||
        // 如果 id 为空,说明不用比较是否为相同 id 的菜单
 | 
			
		||||
        if (id == null) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_NAME_DUPLICATE);
 | 
			
		||||
            throw exception(MENU_NAME_DUPLICATE);
 | 
			
		||||
        }
 | 
			
		||||
        if (!menu.getId().equals(id)) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(MENU_NAME_DUPLICATE);
 | 
			
		||||
            throw exception(MENU_NAME_DUPLICATE);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user