From f8ea1591957972c7a86c2c935b63d9121001b0ed Mon Sep 17 00:00:00 2001 From: Kuizuo Date: Fri, 1 Dec 2023 20:57:41 +0800 Subject: [PATCH] fix: getMenus without roleIds --- apps/api/src/modules/system/menu/menu.service.ts | 3 +++ apps/api/src/modules/user/dto/user.dto.ts | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/api/src/modules/system/menu/menu.service.ts b/apps/api/src/modules/system/menu/menu.service.ts index 57be777..ef31b69 100644 --- a/apps/api/src/modules/system/menu/menu.service.ts +++ b/apps/api/src/modules/system/menu/menu.service.ts @@ -70,6 +70,9 @@ export class MenuService { const roleIds = await this.roleService.getRoleIdsByUser(uid) let menus: MenuEntity[] = [] + if (isEmpty(roleIds)) + return generatorRouters([]) + if (this.roleService.hasAdminRole(roleIds)) { menus = await this.menuRepository.find({ order: { orderNo: 'ASC' } }) } diff --git a/apps/api/src/modules/user/dto/user.dto.ts b/apps/api/src/modules/user/dto/user.dto.ts index 6bd7701..a31d945 100644 --- a/apps/api/src/modules/user/dto/user.dto.ts +++ b/apps/api/src/modules/user/dto/user.dto.ts @@ -18,9 +18,6 @@ import { isEmpty } from 'lodash' import { PagerDto } from '~/common/dto/pager.dto' -import { UserEntity } from '~/modules/user/entities/user.entity' -import { IsUnique } from '~/shared/database/constraints/unique.constraint' - export class UserDto { @ApiProperty({ description: '登录账号', example: 'kz-admin' }) @IsString() @@ -54,7 +51,6 @@ export class UserDto { nickname: string @ApiProperty({ description: '邮箱', example: 'hi@kuizuo.cn' }) - @IsUnique(UserEntity, { message: '邮箱已被注册' }) @IsEmail() @ValidateIf(o => !isEmpty(o.email)) email: string