Skip to content

Commit

Permalink
chore: remove unused env
Browse files Browse the repository at this point in the history
  • Loading branch information
kuizuo committed Nov 24, 2023
1 parent ab58714 commit c3c6bfc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
3 changes: 0 additions & 3 deletions apps/api/src/config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/modules/system/role/role.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export class RoleDto {
menuIds?: number[]
}

export class RoleUpdateDto extends PartialType(RoleDto) {}
export class RoleUpdateDto extends PartialType(RoleDto) {}
14 changes: 3 additions & 11 deletions apps/api/src/modules/system/role/role.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -45,11 +44,6 @@ export class RoleService {
})
.getOne()

// if (id === this.configService.get<IAppConfig>('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'],
Expand All @@ -59,7 +53,7 @@ export class RoleService {
}

async delete(id: number): Promise<void> {
if (id === this.configService.get<IAppConfig>('app').adminRoleId)
if (id === 1)
throw new Error('不能删除超级管理员')

await this.roleRepository.delete(id)
Expand Down Expand Up @@ -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<IAppConfig>('app').adminRoleId,
)
return rids.includes(1)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/modules/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
}

Expand Down
3 changes: 1 addition & 2 deletions apps/api/src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -254,7 +253,7 @@ export class UserService {
*/
async findRootUserId(): Promise<number> {
const user = await this.userRepository.findOneBy({
roles: { id: this.configService.get<IAppConfig>('app').adminRoleId },
roles: { id: 1 },
})
return user.id
}
Expand Down

0 comments on commit c3c6bfc

Please sign in to comment.