From c3c6bfc3823199d0731455a98d9f9bdd2885f4e0 Mon Sep 17 00:00:00 2001 From: Kuizuo Date: Sat, 25 Nov 2023 02:07:33 +0800 Subject: [PATCH] chore: remove unused env --- apps/api/src/config/app.config.ts | 3 --- apps/api/src/modules/system/role/role.dto.ts | 2 +- apps/api/src/modules/system/role/role.service.ts | 14 +++----------- apps/api/src/modules/user/user.controller.ts | 4 ++-- apps/api/src/modules/user/user.service.ts | 3 +-- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/apps/api/src/config/app.config.ts b/apps/api/src/config/app.config.ts index 8a8c912..7ce751f 100644 --- a/apps/api/src/config/app.config.ts +++ b/apps/api/src/config/app.config.ts @@ -6,9 +6,6 @@ export const AppConfig = registerAs('app', () => ({ name: env('APP_NAME'), port: envNumber('APP_PORT', 3000), globalPrefix: env('GLOBAL_PREFIX'), - adminRoleId: envNumber('ADMIN_ROLE_ID', 1), - userPwdSalt: env('USER_PWD_SALT', ''), - userDefaultPwd: env('USER_DEFAULT_PWD', 'a123456'), locale: env('APP_LOCALE', 'zh-CN'), logger: { diff --git a/apps/api/src/modules/system/role/role.dto.ts b/apps/api/src/modules/system/role/role.dto.ts index b39de2b..66d2178 100644 --- a/apps/api/src/modules/system/role/role.dto.ts +++ b/apps/api/src/modules/system/role/role.dto.ts @@ -35,4 +35,4 @@ export class RoleDto { menuIds?: number[] } -export class RoleUpdateDto extends PartialType(RoleDto) {} \ No newline at end of file +export class RoleUpdateDto extends PartialType(RoleDto) {} diff --git a/apps/api/src/modules/system/role/role.service.ts b/apps/api/src/modules/system/role/role.service.ts index aa3f9d6..f7236d2 100644 --- a/apps/api/src/modules/system/role/role.service.ts +++ b/apps/api/src/modules/system/role/role.service.ts @@ -7,7 +7,6 @@ import { EntityManager, In, Repository } from 'typeorm' import { RoleDto, RoleUpdateDto } from './role.dto' import { RoleInfo } from './role.model' import { PageOptionsDto } from '@/common/dto/page-options.dto' -import { IAppConfig } from '@/config' import { paginate } from '@/helper/paginate' import { Pagination } from '@/helper/paginate/pagination' import { MenuEntity } from '@/modules/system/menu/menu.entity' @@ -45,11 +44,6 @@ export class RoleService { }) .getOne() - // if (id === this.configService.get('app').adminRoleId) { - // const menus = await this.menuRepository.find({ select: ['id'] }); - // return { ...info, menuIds: menus.map((m) => m.id) }; - // } - const menus = await this.menuRepository.find({ where: { roles: { id } }, select: ['id'], @@ -59,7 +53,7 @@ export class RoleService { } async delete(id: number): Promise { - if (id === this.configService.get('app').adminRoleId) + if (id === 1) throw new Error('不能删除超级管理员') await this.roleRepository.delete(id) @@ -132,16 +126,14 @@ export class RoleService { if (!isEmpty(roles)) { return roles.some( - r => r.id === this.configService.get('app').adminRoleId, + r => r.id === 1, ) } return false } hasAdminRole(rids: number[]): boolean { - return rids.some( - r => r === this.configService.get('app').adminRoleId, - ) + return rids.includes(1) } /** diff --git a/apps/api/src/modules/user/user.controller.ts b/apps/api/src/modules/user/user.controller.ts index 90e9ae4..b666ded 100644 --- a/apps/api/src/modules/user/user.controller.ts +++ b/apps/api/src/modules/user/user.controller.ts @@ -2,7 +2,7 @@ import { Body, Controller, Delete, Get, Post, Put, Query } from '@nestjs/common' import { ApiOperation, ApiTags } from '@nestjs/swagger' import { UserPasswordDto } from './dto/password.dto' -import { UserDto, UserQueryDto , UserUpdateDto } from './dto/user.dto' +import { UserDto, UserQueryDto, UserUpdateDto } from './dto/user.dto' import { UserService } from './user.service' import { IdParam } from '@/common/decorators/id-param.decorator' import { ApiSecurityAuth } from '@/common/decorators/swagger.decorator' @@ -32,7 +32,7 @@ export class UserController { @Get() @ApiOperation({ summary: '获取用户列表' }) @Permission(Permissions.LIST) - async list(@Query() dto: UserQueryDto ) { + async list(@Query() dto: UserQueryDto) { return this.userService.list(dto) } diff --git a/apps/api/src/modules/user/user.service.ts b/apps/api/src/modules/user/user.service.ts index 4fce196..c7ceed4 100644 --- a/apps/api/src/modules/user/user.service.ts +++ b/apps/api/src/modules/user/user.service.ts @@ -15,7 +15,6 @@ import { UserDto, UserQueryDto, UserUpdateDto } from './dto/user.dto' import { UserEntity } from './entities/user.entity' import { AccountInfo } from './user.model' import { BusinessException } from '@/common/exceptions/biz.exception' -import { IAppConfig } from '@/config' import { ErrorEnum } from '@/constants/error-code.constant' import { SYS_USER_INITPASSWORD } from '@/constants/system.constant' @@ -254,7 +253,7 @@ export class UserService { */ async findRootUserId(): Promise { const user = await this.userRepository.findOneBy({ - roles: { id: this.configService.get('app').adminRoleId }, + roles: { id: 1 }, }) return user.id }