From 88a97ee1621acc6c2469c1aa4f275522b2b5ecb4 Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Thu, 29 Feb 2024 09:29:03 +0800 Subject: [PATCH] refactor: --- src/app.module.ts | 8 ++-- src/common/adapters/fastify.adapter.ts | 8 ++-- src/common/adapters/socket.adapter.ts | 2 +- src/common/decorators/api-result.decorator.ts | 24 +++++------ src/common/decorators/field.decorator.ts | 4 +- src/common/decorators/id-param.decorator.ts | 2 +- src/common/dto/cursor.dto.ts | 4 +- src/common/dto/pager.dto.ts | 6 +-- src/common/entity/common.entity.ts | 2 +- src/common/exceptions/biz.exception.ts | 4 +- src/common/exceptions/socket.exception.ts | 4 +- src/common/filters/any-exception.filter.ts | 4 +- .../interceptors/idempotence.interceptor.ts | 6 +-- .../interceptors/timeout.interceptor.ts | 2 +- .../interceptors/transform.interceptor.ts | 2 +- src/config/app.config.ts | 4 +- src/config/database.config.ts | 2 +- src/config/index.ts | 2 +- src/config/mailer.config.ts | 4 +- src/config/oss.config.ts | 2 +- src/config/redis.config.ts | 2 +- src/config/security.config.ts | 2 +- src/config/swagger.config.ts | 2 +- src/constants/cache.constant.ts | 2 +- src/constants/error-code.constant.ts | 2 +- src/constants/event-bus.constant.ts | 2 +- src/constants/response.constant.ts | 2 +- src/helper/crud/crud.factory.ts | 4 +- src/helper/paginate/create-pagination.ts | 4 +- src/helper/paginate/index.ts | 22 +++++----- src/helper/paginate/interface.ts | 2 +- src/main.ts | 4 +- src/modules/auth/auth.constant.ts | 4 +- src/modules/auth/auth.module.ts | 8 ++-- .../auth/controllers/captcha.controller.ts | 4 +- src/modules/auth/dto/account.dto.ts | 4 +- src/modules/auth/dto/captcha.dto.ts | 4 +- .../auth/entities/access-token.entity.ts | 6 +-- .../auth/entities/refresh-token.entity.ts | 4 +- src/modules/auth/guards/jwt-auth.guard.ts | 2 +- src/modules/auth/guards/rbac.guard.ts | 4 +- src/modules/auth/guards/resource.guard.ts | 6 +-- src/modules/auth/services/token.service.ts | 14 +++---- src/modules/auth/strategies/jwt.strategy.ts | 2 +- src/modules/auth/strategies/local.strategy.ts | 2 +- src/modules/contract/contract.controller.ts | 2 +- src/modules/contract/contract.module.ts | 2 +- src/modules/health/health.controller.ts | 6 +-- src/modules/health/health.module.ts | 2 +- src/modules/netdisk/manager/manage.class.ts | 2 +- .../netdisk/manager/manage.controller.ts | 8 ++-- src/modules/netdisk/manager/manage.dto.ts | 2 +- src/modules/netdisk/manager/manage.service.ts | 40 +++++++++---------- src/modules/netdisk/netdisk.module.ts | 8 ++-- .../netdisk/overview/overview.controller.ts | 4 +- .../netdisk/overview/overview.service.ts | 18 ++++----- src/modules/sse/sse.controller.ts | 4 +- src/modules/sse/sse.module.ts | 2 +- src/modules/sse/sse.service.ts | 12 +++--- src/modules/system/dept/dept.controller.ts | 2 +- src/modules/system/dept/dept.dto.ts | 2 +- src/modules/system/dept/dept.module.ts | 2 +- src/modules/system/dept/dept.service.ts | 6 +-- .../system/dict-item/dict-item.controller.ts | 2 +- .../system/dict-item/dict-item.module.ts | 2 +- .../system/dict-item/dict-item.service.ts | 14 +++---- .../system/dict-type/dict-type.controller.ts | 2 +- .../system/dict-type/dict-type.module.ts | 2 +- .../system/dict-type/dict-type.service.ts | 4 +- src/modules/system/log/log.controller.ts | 2 +- src/modules/system/log/log.module.ts | 4 +- .../log/services/captcha-log.service.ts | 4 +- .../system/log/services/login-log.service.ts | 14 +++---- .../system/log/services/task-log.service.ts | 4 +- src/modules/system/menu/menu.controller.ts | 6 +-- src/modules/system/menu/menu.dto.ts | 2 +- src/modules/system/menu/menu.entity.ts | 2 +- src/modules/system/menu/menu.module.ts | 2 +- src/modules/system/menu/menu.service.ts | 12 +++--- .../system/online/online.controller.ts | 2 +- src/modules/system/online/online.module.ts | 4 +- src/modules/system/online/online.service.ts | 2 +- .../param-config/param-config.controller.ts | 2 +- .../param-config/param-config.module.ts | 2 +- .../param-config/param-config.service.ts | 6 +-- src/modules/system/role/role.controller.ts | 4 +- src/modules/system/role/role.entity.ts | 2 +- src/modules/system/role/role.module.ts | 2 +- src/modules/system/role/role.service.ts | 30 +++++++------- src/modules/system/serve/serve.module.ts | 2 +- src/modules/system/serve/serve.service.ts | 12 +++--- src/modules/system/system.module.ts | 10 ++--- src/modules/system/task/constant.ts | 4 +- src/modules/system/task/task.controller.ts | 2 +- src/modules/system/task/task.dto.ts | 4 +- src/modules/system/task/task.module.ts | 8 ++-- src/modules/system/task/task.service.ts | 22 +++++----- src/modules/tasks/tasks.module.ts | 4 +- src/modules/todo/todo.controller.ts | 2 +- src/modules/todo/todo.module.ts | 2 +- src/modules/tools/email/email.module.ts | 2 +- .../tools/storage/storage.controller.ts | 2 +- src/modules/tools/storage/storage.entity.ts | 2 +- src/modules/tools/storage/storage.module.ts | 2 +- src/modules/tools/storage/storage.service.ts | 14 +++---- src/modules/tools/tools.module.ts | 8 ++-- src/modules/tools/upload/file.constraint.ts | 4 +- src/modules/tools/upload/upload.controller.ts | 6 +-- src/modules/tools/upload/upload.dto.ts | 4 +- src/modules/tools/upload/upload.module.ts | 2 +- src/modules/tools/upload/upload.service.ts | 4 +- src/modules/user/constant.ts | 2 +- src/modules/user/dto/password.dto.ts | 4 +- src/modules/user/dto/user.dto.ts | 4 +- src/modules/user/user.controller.ts | 6 +-- src/modules/user/user.entity.ts | 6 +-- src/modules/user/user.module.ts | 2 +- src/modules/user/user.service.ts | 24 +++++------ src/setup-swagger.ts | 4 +- .../constraints/entity-exist.constraint.ts | 4 +- .../database/constraints/unique.constraint.ts | 10 ++--- src/shared/database/database.module.ts | 8 ++-- src/shared/helper/cron.service.ts | 4 +- src/shared/helper/helper.module.ts | 2 +- src/shared/logger/logger.module.ts | 2 +- src/shared/logger/logger.service.ts | 12 +++--- src/shared/mailer/mailer.module.ts | 16 ++++---- src/shared/mailer/mailer.service.ts | 10 ++--- src/shared/redis/cache.service.ts | 2 +- src/shared/redis/redis-subpub.ts | 2 +- src/shared/redis/redis.module.ts | 16 ++++---- src/shared/shared.module.ts | 10 ++--- src/socket/base.gateway.ts | 2 +- src/socket/business-event.constant.ts | 2 +- src/socket/events/admin.gateway.ts | 2 +- src/socket/events/web.gateway.ts | 2 +- src/socket/socket.module.ts | 2 +- src/utils/captcha.util.ts | 2 +- src/utils/crypto.util.ts | 4 +- src/utils/file.util.ts | 2 +- src/utils/ip.util.ts | 2 +- src/utils/list2tree.util.ts | 2 +- src/utils/permission.util.ts | 10 ++--- src/utils/schedule.util.ts | 2 +- 144 files changed, 387 insertions(+), 387 deletions(-) diff --git a/src/app.module.ts b/src/app.module.ts index 7b5542d..d5484cd 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -33,7 +33,7 @@ import { ContractModule } from './modules/contract/contract.module'; expandVariables: true, // 指定多个 env 文件时,第一个优先级最高 envFilePath: ['.env.local', `.env.${process.env.NODE_ENV}`, '.env'], - load: [...Object.values(config)], + load: [...Object.values(config)] }), SharedModule, DatabaseModule, @@ -53,7 +53,7 @@ import { ContractModule } from './modules/contract/contract.module'; TodoModule, - ContractModule, + ContractModule ], providers: [ { provide: APP_FILTER, useClass: AllExceptionsFilter }, @@ -64,7 +64,7 @@ import { ContractModule } from './modules/contract/contract.module'; { provide: APP_INTERCEPTOR, useClass: IdempotenceInterceptor }, { provide: APP_GUARD, useClass: JwtAuthGuard }, - { provide: APP_GUARD, useClass: RbacGuard }, - ], + { provide: APP_GUARD, useClass: RbacGuard } + ] }) export class AppModule {} diff --git a/src/common/adapters/fastify.adapter.ts b/src/common/adapters/fastify.adapter.ts index 67ecb8c..c36f024 100644 --- a/src/common/adapters/fastify.adapter.ts +++ b/src/common/adapters/fastify.adapter.ts @@ -4,7 +4,7 @@ import { FastifyAdapter } from '@nestjs/platform-fastify'; const app: FastifyAdapter = new FastifyAdapter({ trustProxy: true, - logger: false, + logger: false // forceCloseConnections: true, }); export { app as fastifyApp }; @@ -13,12 +13,12 @@ app.register(FastifyMultipart, { limits: { fields: 10, // Max number of non-file fields fileSize: 1024 * 1024 * 6, // limit size 6M - files: 5, // Max number of file fields - }, + files: 5 // Max number of file fields + } }); app.register(FastifyCookie, { - secret: 'cookie-secret', // 这个 secret 不太重要,不存鉴权相关,无关紧要 + secret: 'cookie-secret' // 这个 secret 不太重要,不存鉴权相关,无关紧要 }); app.getInstance().addHook('onRequest', (request, reply, done) => { diff --git a/src/common/adapters/socket.adapter.ts b/src/common/adapters/socket.adapter.ts index ce50f40..ae18518 100644 --- a/src/common/adapters/socket.adapter.ts +++ b/src/common/adapters/socket.adapter.ts @@ -18,7 +18,7 @@ export class RedisIoAdapter extends IoAdapter { const redisAdapter = createAdapter(pubClient, subClient, { key: RedisIoAdapterKey, - requestsTimeout: 10000, + requestsTimeout: 10000 }); server.adapter(redisAdapter); return server; diff --git a/src/common/decorators/api-result.decorator.ts b/src/common/decorators/api-result.decorator.ts index 65887fa..dc54efe 100644 --- a/src/common/decorators/api-result.decorator.ts +++ b/src/common/decorators/api-result.decorator.ts @@ -16,7 +16,7 @@ function genBaseProp(type: Type) { export function ApiResult>({ type, isPage, - status, + status }: { type?: TModel | TModel[]; isPage?: boolean; @@ -31,7 +31,7 @@ export function ApiResult>({ properties: { items: { type: 'array', - items: { $ref: getSchemaPath(type[0]) }, + items: { $ref: getSchemaPath(type[0]) } }, meta: { type: 'object', @@ -40,15 +40,15 @@ export function ApiResult>({ totalItems: { type: 'number', default: 0 }, itemsPerPage: { type: 'number', default: 0 }, totalPages: { type: 'number', default: 0 }, - currentPage: { type: 'number', default: 0 }, - }, - }, - }, + currentPage: { type: 'number', default: 0 } + } + } + } }; } else { prop = { type: 'array', - items: genBaseProp(type[0]), + items: genBaseProp(type[0]) }; } } else if (type) { @@ -68,11 +68,11 @@ export function ApiResult>({ { $ref: getSchemaPath(ResOp) }, { properties: { - data: prop, - }, - }, - ], - }, + data: prop + } + } + ] + } }) ); } diff --git a/src/common/decorators/field.decorator.ts b/src/common/decorators/field.decorator.ts index f3863f2..3423135 100644 --- a/src/common/decorators/field.decorator.ts +++ b/src/common/decorators/field.decorator.ts @@ -11,7 +11,7 @@ import { Max, MaxLength, Min, - MinLength, + MinLength } from 'class-validator'; import { isNumber } from 'lodash'; @@ -22,7 +22,7 @@ import { ToLowerCase, ToNumber, ToTrim, - ToUpperCase, + ToUpperCase } from './transform.decorator'; interface IOptionalOptions { diff --git a/src/common/decorators/id-param.decorator.ts b/src/common/decorators/id-param.decorator.ts index 4967ce2..eb41a79 100644 --- a/src/common/decorators/id-param.decorator.ts +++ b/src/common/decorators/id-param.decorator.ts @@ -7,7 +7,7 @@ export function IdParam() { errorHttpStatusCode: HttpStatus.NOT_ACCEPTABLE, exceptionFactory: _error => { throw new NotAcceptableException('id 格式不正确'); - }, + } }) ); } diff --git a/src/common/dto/cursor.dto.ts b/src/common/dto/cursor.dto.ts index 59e7912..b3b0305 100644 --- a/src/common/dto/cursor.dto.ts +++ b/src/common/dto/cursor.dto.ts @@ -9,7 +9,7 @@ export class CursorDto { @Expose() @IsOptional({ always: true }) @Transform(({ value: val }) => (val ? Number.parseInt(val) : 0), { - toClassOnly: true, + toClassOnly: true }) cursor?: number; @@ -20,7 +20,7 @@ export class CursorDto { @IsOptional({ always: true }) @Expose() @Transform(({ value: val }) => (val ? Number.parseInt(val) : 10), { - toClassOnly: true, + toClassOnly: true }) limit?: number; } diff --git a/src/common/dto/pager.dto.ts b/src/common/dto/pager.dto.ts index 2467702..11f9348 100644 --- a/src/common/dto/pager.dto.ts +++ b/src/common/dto/pager.dto.ts @@ -4,7 +4,7 @@ import { Allow, IsEnum, IsInt, IsOptional, IsString, Max, Min } from 'class-vali export enum Order { ASC = 'ASC', - DESC = 'DESC', + DESC = 'DESC' } export class PagerDto { @@ -14,7 +14,7 @@ export class PagerDto { @Expose() @IsOptional({ always: true }) @Transform(({ value: val }) => (val ? Number.parseInt(val) : 1), { - toClassOnly: true, + toClassOnly: true }) page?: number; @@ -25,7 +25,7 @@ export class PagerDto { @IsOptional({ always: true }) @Expose() @Transform(({ value: val }) => (val ? Number.parseInt(val) : 10), { - toClassOnly: true, + toClassOnly: true }) pageSize?: number; diff --git a/src/common/entity/common.entity.ts b/src/common/entity/common.entity.ts index b726edf..f8c190e 100644 --- a/src/common/entity/common.entity.ts +++ b/src/common/entity/common.entity.ts @@ -6,7 +6,7 @@ import { CreateDateColumn, PrimaryGeneratedColumn, UpdateDateColumn, - VirtualColumn, + VirtualColumn } from 'typeorm'; // 如果觉得前端转换时间太麻烦,并且不考虑通用性的话,可以在服务端进行转换,eg: @UpdateDateColumn({ name: 'updated_at', transformer }) diff --git a/src/common/exceptions/biz.exception.ts b/src/common/exceptions/biz.exception.ts index 9b51262..11275b9 100644 --- a/src/common/exceptions/biz.exception.ts +++ b/src/common/exceptions/biz.exception.ts @@ -12,7 +12,7 @@ export class BusinessException extends HttpException { super( HttpException.createBody({ code: RESPONSE_SUCCESS_CODE, - message: error, + message: error }), HttpStatus.OK ); @@ -24,7 +24,7 @@ export class BusinessException extends HttpException { super( HttpException.createBody({ code, - message, + message }), HttpStatus.OK ); diff --git a/src/common/exceptions/socket.exception.ts b/src/common/exceptions/socket.exception.ts index c25de02..ca0cde3 100644 --- a/src/common/exceptions/socket.exception.ts +++ b/src/common/exceptions/socket.exception.ts @@ -14,7 +14,7 @@ export class SocketException extends WsException { super( HttpException.createBody({ code: 0, - message: error, + message: error }) ); this.errorCode = 0; @@ -25,7 +25,7 @@ export class SocketException extends WsException { super( HttpException.createBody({ code, - message, + message }) ); diff --git a/src/common/filters/any-exception.filter.ts b/src/common/filters/any-exception.filter.ts index f31ab40..aee7fd5 100644 --- a/src/common/filters/any-exception.filter.ts +++ b/src/common/filters/any-exception.filter.ts @@ -4,7 +4,7 @@ import { ExceptionFilter, HttpException, HttpStatus, - Logger, + Logger } from '@nestjs/common'; import { FastifyReply, FastifyRequest } from 'fastify'; @@ -62,7 +62,7 @@ export class AllExceptionsFilter implements ExceptionFilter { const resBody: IBaseResponse = { code: apiErrorCode, message, - data: null, + data: null }; response.status(status).send(resBody); diff --git a/src/common/interceptors/idempotence.interceptor.ts b/src/common/interceptors/idempotence.interceptor.ts index 6fab029..0569aa6 100644 --- a/src/common/interceptors/idempotence.interceptor.ts +++ b/src/common/interceptors/idempotence.interceptor.ts @@ -12,7 +12,7 @@ import { getRedisKey } from '~/utils/redis.util'; import { HTTP_IDEMPOTENCE_KEY, - HTTP_IDEMPOTENCE_OPTIONS, + HTTP_IDEMPOTENCE_OPTIONS } from '../decorators/idempotence.decorator'; const IdempotenceHeaderKey = 'x-idempotence'; @@ -70,7 +70,7 @@ export class IdempotenceInterceptor implements NestInterceptor { pendingMessage = '相同请求正在处理中...', handler: errorHandler, expired = 60, - disableGenerateKey = false, + disableGenerateKey = false } = options; const redis = this.cacheService.getClient(); @@ -93,7 +93,7 @@ export class IdempotenceInterceptor implements NestInterceptor { const message = { 1: errorMessage, - 0: pendingMessage, + 0: pendingMessage }[resultValue]; throw new ConflictException(message); } else { diff --git a/src/common/interceptors/timeout.interceptor.ts b/src/common/interceptors/timeout.interceptor.ts index 464d53c..7a1382b 100644 --- a/src/common/interceptors/timeout.interceptor.ts +++ b/src/common/interceptors/timeout.interceptor.ts @@ -3,7 +3,7 @@ import { ExecutionContext, Injectable, NestInterceptor, - RequestTimeoutException, + RequestTimeoutException } from '@nestjs/common'; import { Observable, TimeoutError, throwError } from 'rxjs'; import { catchError, timeout } from 'rxjs/operators'; diff --git a/src/common/interceptors/transform.interceptor.ts b/src/common/interceptors/transform.interceptor.ts index 8ba5c95..f52f8b9 100644 --- a/src/common/interceptors/transform.interceptor.ts +++ b/src/common/interceptors/transform.interceptor.ts @@ -3,7 +3,7 @@ import { ExecutionContext, HttpStatus, Injectable, - NestInterceptor, + NestInterceptor } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { Observable } from 'rxjs'; diff --git a/src/config/app.config.ts b/src/config/app.config.ts index 072be51..079e0ce 100644 --- a/src/config/app.config.ts +++ b/src/config/app.config.ts @@ -13,8 +13,8 @@ export const AppConfig = registerAs(appRegToken, () => ({ logger: { level: env('LOGGER_LEVEL'), - maxFiles: envNumber('LOGGER_MAX_FILES'), - }, + maxFiles: envNumber('LOGGER_MAX_FILES') + } })); export type IAppConfig = ConfigType; diff --git a/src/config/database.config.ts b/src/config/database.config.ts index 2f9f706..02df861 100644 --- a/src/config/database.config.ts +++ b/src/config/database.config.ts @@ -24,7 +24,7 @@ const dataSourceOptions: DataSourceOptions = { multipleStatements: currentScript === 'typeorm', entities: ['dist/modules/**/*.entity{.ts,.js}'], migrations: ['dist/migrations/*{.ts,.js}'], - subscribers: ['dist/modules/**/*.subscriber{.ts,.js}'], + subscribers: ['dist/modules/**/*.subscriber{.ts,.js}'] }; export const dbRegToken = 'database'; diff --git a/src/config/index.ts b/src/config/index.ts index 4154c0a..57bae35 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -33,5 +33,5 @@ export default { OssConfig, RedisConfig, SecurityConfig, - SwaggerConfig, + SwaggerConfig }; diff --git a/src/config/mailer.config.ts b/src/config/mailer.config.ts index 2f60052..6e17271 100644 --- a/src/config/mailer.config.ts +++ b/src/config/mailer.config.ts @@ -11,8 +11,8 @@ export const MailerConfig = registerAs(mailerRegToken, () => ({ secure: true, auth: { user: env('SMTP_USER'), - pass: env('SMTP_PASS'), - }, + pass: env('SMTP_PASS') + } })); export type IMailerConfig = ConfigType; diff --git a/src/config/oss.config.ts b/src/config/oss.config.ts index 0f00e42..10ffda8 100644 --- a/src/config/oss.config.ts +++ b/src/config/oss.config.ts @@ -26,7 +26,7 @@ export const OssConfig = registerAs(ossRegToken, () => ({ domain: env('OSS_DOMAIN'), bucket: env('OSS_BUCKET'), zone: parseZone(env('OSS_ZONE') || 'Zone_z2'), - access: (env('OSS_ACCESS_TYPE') as any) || 'public', + access: (env('OSS_ACCESS_TYPE') as any) || 'public' })); export type IOssConfig = ConfigType; diff --git a/src/config/redis.config.ts b/src/config/redis.config.ts index 5cbdbff..3260bc4 100644 --- a/src/config/redis.config.ts +++ b/src/config/redis.config.ts @@ -8,7 +8,7 @@ export const RedisConfig = registerAs(redisRegToken, () => ({ host: env('REDIS_HOST', '127.0.0.1'), port: envNumber('REDIS_PORT', 6379), password: env('REDIS_PASSWORD'), - db: envNumber('REDIS_DB'), + db: envNumber('REDIS_DB') })); export type IRedisConfig = ConfigType; diff --git a/src/config/security.config.ts b/src/config/security.config.ts index f69ac11..fb2f1b1 100644 --- a/src/config/security.config.ts +++ b/src/config/security.config.ts @@ -8,7 +8,7 @@ export const SecurityConfig = registerAs(securityRegToken, () => ({ jwtSecret: env('JWT_SECRET'), jwtExprire: envNumber('JWT_EXPIRE'), refreshSecret: env('REFRESH_TOKEN_SECRET'), - refreshExpire: envNumber('REFRESH_TOKEN_EXPIRE'), + refreshExpire: envNumber('REFRESH_TOKEN_EXPIRE') })); export type ISecurityConfig = ConfigType; diff --git a/src/config/swagger.config.ts b/src/config/swagger.config.ts index c29a9c3..efbbb1a 100644 --- a/src/config/swagger.config.ts +++ b/src/config/swagger.config.ts @@ -6,7 +6,7 @@ export const swaggerRegToken = 'swagger'; export const SwaggerConfig = registerAs(swaggerRegToken, () => ({ enable: envBoolean('SWAGGER_ENABLE'), - path: env('SWAGGER_PATH'), + path: env('SWAGGER_PATH') })); export type ISwaggerConfig = ConfigType; diff --git a/src/constants/cache.constant.ts b/src/constants/cache.constant.ts index 34d9b26..858bf7f 100644 --- a/src/constants/cache.constant.ts +++ b/src/constants/cache.constant.ts @@ -3,6 +3,6 @@ export enum RedisKeys { CAPTCHA_IMG_PREFIX = 'captcha:img:', AUTH_TOKEN_PREFIX = 'auth:token:', AUTH_PERM_PREFIX = 'auth:permission:', - AUTH_PASSWORD_V_PREFIX = 'auth:passwordVersion:', + AUTH_PASSWORD_V_PREFIX = 'auth:passwordVersion:' } export const API_CACHE_PREFIX = 'api-cache:'; diff --git a/src/constants/error-code.constant.ts b/src/constants/error-code.constant.ts index 4046758..95af623 100644 --- a/src/constants/error-code.constant.ts +++ b/src/constants/error-code.constant.ts @@ -45,5 +45,5 @@ export enum ErrorEnum { // OSS相关 OSS_FILE_OR_DIR_EXIST = '1401:当前创建的文件或目录已存在', OSS_NO_OPERATION_REQUIRED = '1402:无需操作', - OSS_EXCEE_MAXIMUM_QUANTITY = '1403:已超出支持的最大处理数量', + OSS_EXCEE_MAXIMUM_QUANTITY = '1403:已超出支持的最大处理数量' } diff --git a/src/constants/event-bus.constant.ts b/src/constants/event-bus.constant.ts index 7d35e8a..ad5e7e7 100644 --- a/src/constants/event-bus.constant.ts +++ b/src/constants/event-bus.constant.ts @@ -1,4 +1,4 @@ export enum EventBusEvents { TokenExpired = 'token.expired', - SystemException = 'system.exception', + SystemException = 'system.exception' } diff --git a/src/constants/response.constant.ts b/src/constants/response.constant.ts index 5b5395b..a34fb9b 100644 --- a/src/constants/response.constant.ts +++ b/src/constants/response.constant.ts @@ -11,5 +11,5 @@ export enum ContentTypeEnum { // form-data qs FORM_URLENCODED = 'application/x-www-form-urlencoded;charset=UTF-8', // form-data upload - FORM_DATA = 'multipart/form-data;charset=UTF-8', + FORM_DATA = 'multipart/form-data;charset=UTF-8' } diff --git a/src/helper/crud/crud.factory.ts b/src/helper/crud/crud.factory.ts index 67b0e6d..af72c80 100644 --- a/src/helper/crud/crud.factory.ts +++ b/src/helper/crud/crud.factory.ts @@ -13,7 +13,7 @@ import { BaseService } from './base.service'; export function BaseCrudFactory any>({ entity, dto, - permissions, + permissions }: { entity: E; dto?: Type; @@ -35,7 +35,7 @@ export function BaseCrudFactory any>({ CREATE: `${prefix}:create`, READ: `${prefix}:read`, UPDATE: `${prefix}:update`, - DELETE: `${prefix}:delete`, + DELETE: `${prefix}:delete` } as const); @Controller(pluralizeName) diff --git a/src/helper/paginate/create-pagination.ts b/src/helper/paginate/create-pagination.ts index 589e416..2adfa11 100644 --- a/src/helper/paginate/create-pagination.ts +++ b/src/helper/paginate/create-pagination.ts @@ -5,7 +5,7 @@ export function createPaginationObject({ items, totalItems, currentPage, - limit, + limit }: { items: T[]; totalItems?: number; @@ -19,7 +19,7 @@ export function createPaginationObject({ itemCount: items.length, itemsPerPage: limit, totalPages, - currentPage, + currentPage }; return new Pagination(items, meta); diff --git a/src/helper/paginate/index.ts b/src/helper/paginate/index.ts index b50b8a8..181243d 100644 --- a/src/helper/paginate/index.ts +++ b/src/helper/paginate/index.ts @@ -3,7 +3,7 @@ import { FindOptionsWhere, ObjectLiteral, Repository, - SelectQueryBuilder, + SelectQueryBuilder } from 'typeorm'; import { createPaginationObject } from './create-pagination'; @@ -19,7 +19,7 @@ function resolveOptions(options: IPaginationOptions): [number, number, Paginatio return [ page || DEFAULT_PAGE, pageSize || DEFAULT_LIMIT, - paginationType || PaginationTypeEnum.TAKE_AND_SKIP, + paginationType || PaginationTypeEnum.TAKE_AND_SKIP ]; } @@ -34,9 +34,9 @@ async function paginateRepository( repository.find({ skip: limit * (page - 1), take: limit, - ...searchOptions, + ...searchOptions }), - undefined, + undefined ]; const [items, total] = await Promise.all(promises); @@ -45,7 +45,7 @@ async function paginateRepository( items, totalItems: total, currentPage: page, - limit, + limit }); } @@ -65,7 +65,7 @@ async function paginateQueryBuilder( items, totalItems: total, currentPage: page, - limit, + limit }); } @@ -80,7 +80,7 @@ export async function paginateRaw( ? queryBuilder.limit(limit).offset((page - 1) * limit) : queryBuilder.take(limit).skip((page - 1) * limit) ).getRawMany(), - queryBuilder.getCount(), + queryBuilder.getCount() ]; const [items, total] = await Promise.all(promises); @@ -89,7 +89,7 @@ export async function paginateRaw( items, totalItems: total, currentPage: page, - limit, + limit }); } @@ -104,7 +104,7 @@ export async function paginateRawAndEntities( ? queryBuilder.limit(limit).offset((page - 1) * limit) : queryBuilder.take(limit).skip((page - 1) * limit) ).getRawAndEntities(), - queryBuilder.getCount(), + queryBuilder.getCount() ]; const [itemObject, total] = await Promise.all(promises); @@ -114,9 +114,9 @@ export async function paginateRawAndEntities( items: itemObject.entities, totalItems: total, currentPage: page, - limit, + limit }), - itemObject.raw, + itemObject.raw ]; } diff --git a/src/helper/paginate/interface.ts b/src/helper/paginate/interface.ts index d2cd7d9..c7d3062 100644 --- a/src/helper/paginate/interface.ts +++ b/src/helper/paginate/interface.ts @@ -2,7 +2,7 @@ import { ObjectLiteral } from 'typeorm'; export enum PaginationTypeEnum { LIMIT_AND_OFFSET = 'limit', - TAKE_AND_SKIP = 'take', + TAKE_AND_SKIP = 'take' } export interface IPaginationOptions { diff --git a/src/main.ts b/src/main.ts index 2a174a4..3c6498e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,7 +23,7 @@ declare const module: any; async function bootstrap() { const app = await NestFactory.create(AppModule, fastifyApp, { bufferLogs: true, - snapshot: true, + snapshot: true // forceCloseConnections: true, }); @@ -57,7 +57,7 @@ async function bootstrap() { const msg = e.constraints![rule]; return msg; })[0] - ), + ) }) ); diff --git a/src/modules/auth/auth.constant.ts b/src/modules/auth/auth.constant.ts index 0a9f744..0815718 100644 --- a/src/modules/auth/auth.constant.ts +++ b/src/modules/auth/auth.constant.ts @@ -14,12 +14,12 @@ export const AuthStrategy = { JWT: 'jwt', GITHUB: 'github', - GOOGLE: 'google', + GOOGLE: 'google' } as const; export const Roles = { ADMIN: 'admin', - USER: 'user', + USER: 'user' // GUEST: 'guest', } as const; diff --git a/src/modules/auth/auth.module.ts b/src/modules/auth/auth.module.ts index 8d67c3a..e0c54d6 100644 --- a/src/modules/auth/auth.module.ts +++ b/src/modules/auth/auth.module.ts @@ -41,18 +41,18 @@ const strategies = [LocalStrategy, JwtStrategy]; return { secret: jwtSecret, expires: jwtExprire, - ignoreExpiration: isDev, + ignoreExpiration: isDev }; }, - inject: [ConfigService], + inject: [ConfigService] }), UserModule, RoleModule, MenuModule, - LogModule, + LogModule ], controllers: [...controllers], providers: [...providers, ...strategies], - exports: [TypeOrmModule, JwtModule, ...providers], + exports: [TypeOrmModule, JwtModule, ...providers] }) export class AuthModule {} diff --git a/src/modules/auth/controllers/captcha.controller.ts b/src/modules/auth/controllers/captcha.controller.ts index 4200db0..41b0591 100644 --- a/src/modules/auth/controllers/captcha.controller.ts +++ b/src/modules/auth/controllers/captcha.controller.ts @@ -35,11 +35,11 @@ export class CaptchaController { noise: 4, width: isEmpty(width) ? 100 : width, height: isEmpty(height) ? 50 : height, - charPreset: '1234567890', + charPreset: '1234567890' }); const result = { img: `data:image/svg+xml;base64,${Buffer.from(svg.data).toString('base64')}`, - id: generateUUID(), + id: generateUUID() }; // 5分钟过期时间 await this.redis.set(genCaptchaImgKey(result.id), svg.text, 'EX', 60 * 5); diff --git a/src/modules/auth/dto/account.dto.ts b/src/modules/auth/dto/account.dto.ts index e5b73e5..cf87459 100644 --- a/src/modules/auth/dto/account.dto.ts +++ b/src/modules/auth/dto/account.dto.ts @@ -57,7 +57,7 @@ export class MenuMeta extends PartialType( 'id', 'roles', 'path', - 'name', + 'name' ] as const) ) { title: string; @@ -66,7 +66,7 @@ export class AccountMenus extends PickType(MenuEntity, [ 'id', 'path', 'name', - 'component', + 'component' ] as const) { meta: MenuMeta; } diff --git a/src/modules/auth/dto/captcha.dto.ts b/src/modules/auth/dto/captcha.dto.ts index 8f8c0bf..fdff06c 100644 --- a/src/modules/auth/dto/captcha.dto.ts +++ b/src/modules/auth/dto/captcha.dto.ts @@ -6,7 +6,7 @@ export class ImageCaptchaDto { @ApiProperty({ required: false, default: 100, - description: '验证码宽度', + description: '验证码宽度' }) @Type(() => Number) @IsInt() @@ -16,7 +16,7 @@ export class ImageCaptchaDto { @ApiProperty({ required: false, default: 50, - description: '验证码宽度', + description: '验证码宽度' }) @Type(() => Number) @IsInt() diff --git a/src/modules/auth/entities/access-token.entity.ts b/src/modules/auth/entities/access-token.entity.ts index e57a142..fbbdc0c 100644 --- a/src/modules/auth/entities/access-token.entity.ts +++ b/src/modules/auth/entities/access-token.entity.ts @@ -6,7 +6,7 @@ import { JoinColumn, ManyToOne, OneToOne, - PrimaryGeneratedColumn, + PrimaryGeneratedColumn } from 'typeorm'; import { UserEntity } from '~/modules/user/user.entity'; @@ -28,12 +28,12 @@ export class AccessTokenEntity extends BaseEntity { created_at!: Date; @OneToOne(() => RefreshTokenEntity, refreshToken => refreshToken.accessToken, { - cascade: true, + cascade: true }) refreshToken!: RefreshTokenEntity; @ManyToOne(() => UserEntity, user => user.accessTokens, { - onDelete: 'CASCADE', + onDelete: 'CASCADE' }) @JoinColumn({ name: 'user_id' }) user!: UserEntity; diff --git a/src/modules/auth/entities/refresh-token.entity.ts b/src/modules/auth/entities/refresh-token.entity.ts index b511922..4df36ce 100644 --- a/src/modules/auth/entities/refresh-token.entity.ts +++ b/src/modules/auth/entities/refresh-token.entity.ts @@ -5,7 +5,7 @@ import { Entity, JoinColumn, OneToOne, - PrimaryGeneratedColumn, + PrimaryGeneratedColumn } from 'typeorm'; import { AccessTokenEntity } from './access-token.entity'; @@ -25,7 +25,7 @@ export class RefreshTokenEntity extends BaseEntity { created_at!: Date; @OneToOne(() => AccessTokenEntity, accessToken => accessToken.refreshToken, { - onDelete: 'CASCADE', + onDelete: 'CASCADE' }) @JoinColumn() accessToken!: AccessTokenEntity; diff --git a/src/modules/auth/guards/jwt-auth.guard.ts b/src/modules/auth/guards/jwt-auth.guard.ts index 052c87b..c42ff73 100644 --- a/src/modules/auth/guards/jwt-auth.guard.ts +++ b/src/modules/auth/guards/jwt-auth.guard.ts @@ -27,7 +27,7 @@ export class JwtAuthGuard extends AuthGuard(AuthStrategy.JWT) { async canActivate(context: ExecutionContext): Promise { const isPublic = this.reflector.getAllAndOverride(PUBLIC_KEY, [ context.getHandler(), - context.getClass(), + context.getClass() ]); const request = context.switchToHttp().getRequest(); // const response = context.switchToHttp().getResponse() diff --git a/src/modules/auth/guards/rbac.guard.ts b/src/modules/auth/guards/rbac.guard.ts index 408a747..3cf7239 100644 --- a/src/modules/auth/guards/rbac.guard.ts +++ b/src/modules/auth/guards/rbac.guard.ts @@ -18,7 +18,7 @@ export class RbacGuard implements CanActivate { async canActivate(context: ExecutionContext): Promise { const isPublic = this.reflector.getAllAndOverride(PUBLIC_KEY, [ context.getHandler(), - context.getClass(), + context.getClass() ]); if (isPublic) return true; @@ -34,7 +34,7 @@ export class RbacGuard implements CanActivate { const payloadPermission = this.reflector.getAllAndOverride(PERMISSION_KEY, [ context.getHandler(), - context.getClass(), + context.getClass() ]); // 控制器没有设置接口权限,则默认通过 diff --git a/src/modules/auth/guards/resource.guard.ts b/src/modules/auth/guards/resource.guard.ts index db45299..301181f 100644 --- a/src/modules/auth/guards/resource.guard.ts +++ b/src/modules/auth/guards/resource.guard.ts @@ -23,7 +23,7 @@ export class ResourceGuard implements CanActivate { async canActivate(context: ExecutionContext): Promise { const isPublic = this.reflector.getAllAndOverride(PUBLIC_KEY, [ context.getHandler(), - context.getClass(), + context.getClass() ]); const request = context.switchToHttp().getRequest(); @@ -66,9 +66,9 @@ export class ResourceGuard implements CanActivate { const recordQuery = { where: { id: In(items), - user: { id: user.uid }, + user: { id: user.uid } }, - relations: ['user'], + relations: ['user'] }; const records = await repo.find(recordQuery); diff --git a/src/modules/auth/services/token.service.ts b/src/modules/auth/services/token.service.ts index 786090f..2e552cd 100644 --- a/src/modules/auth/services/token.service.ts +++ b/src/modules/auth/services/token.service.ts @@ -56,7 +56,7 @@ export class TokenService { const payload: IAuthUser = { uid, pv: 1, - roles, + roles }; const jwtSign = this.jwtService.sign(payload); @@ -74,7 +74,7 @@ export class TokenService { return { accessToken: jwtSign, - refreshToken, + refreshToken }; } @@ -85,11 +85,11 @@ export class TokenService { */ async generateRefreshToken(accessToken: AccessTokenEntity, now: dayjs.Dayjs): Promise { const refreshTokenPayload = { - uuid: generateUUID(), + uuid: generateUUID() }; const refreshTokenSign = this.jwtService.sign(refreshTokenPayload, { - secret: this.securityConfig.refreshSecret, + secret: this.securityConfig.refreshSecret }); const refreshToken = new RefreshTokenEntity(); @@ -110,7 +110,7 @@ export class TokenService { return AccessTokenEntity.findOne({ where: { value }, relations: ['user', 'refreshToken'], - cache: true, + cache: true }); } @@ -120,7 +120,7 @@ export class TokenService { */ async removeAccessToken(value: string) { const accessToken = await AccessTokenEntity.findOne({ - where: { value }, + where: { value } }); if (accessToken) await accessToken.remove(); } @@ -132,7 +132,7 @@ export class TokenService { async removeRefreshToken(value: string) { const refreshToken = await RefreshTokenEntity.findOne({ where: { value }, - relations: ['accessToken'], + relations: ['accessToken'] }); if (refreshToken) { if (refreshToken.accessToken) await refreshToken.accessToken.remove(); diff --git a/src/modules/auth/strategies/jwt.strategy.ts b/src/modules/auth/strategies/jwt.strategy.ts index caf763b..a5175e7 100644 --- a/src/modules/auth/strategies/jwt.strategy.ts +++ b/src/modules/auth/strategies/jwt.strategy.ts @@ -12,7 +12,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, AuthStrategy.JWT) { super({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), ignoreExpiration: false, - secretOrKey: securityConfig.jwtSecret, + secretOrKey: securityConfig.jwtSecret }); } diff --git a/src/modules/auth/strategies/local.strategy.ts b/src/modules/auth/strategies/local.strategy.ts index f0c10da..da2d9d2 100644 --- a/src/modules/auth/strategies/local.strategy.ts +++ b/src/modules/auth/strategies/local.strategy.ts @@ -10,7 +10,7 @@ export class LocalStrategy extends PassportStrategy(Strategy, AuthStrategy.LOCAL constructor(private authService: AuthService) { super({ usernameField: 'credential', - passwordField: 'password', + passwordField: 'password' }); } diff --git a/src/modules/contract/contract.controller.ts b/src/modules/contract/contract.controller.ts index 7a20986..5755395 100644 --- a/src/modules/contract/contract.controller.ts +++ b/src/modules/contract/contract.controller.ts @@ -9,7 +9,7 @@ export const permissions = definePermission('app:contract', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('Contract - 合同') diff --git a/src/modules/contract/contract.module.ts b/src/modules/contract/contract.module.ts index 2dab2b4..ad30ded 100644 --- a/src/modules/contract/contract.module.ts +++ b/src/modules/contract/contract.module.ts @@ -4,6 +4,6 @@ import { ContractService } from './contract.service'; @Module({ controllers: [ContractController], - providers: [ContractService], + providers: [ContractService] }) export class ContractModule {} diff --git a/src/modules/health/health.controller.ts b/src/modules/health/health.controller.ts index 372e19b..6927b4c 100644 --- a/src/modules/health/health.controller.ts +++ b/src/modules/health/health.controller.ts @@ -5,7 +5,7 @@ import { HealthCheck, HttpHealthIndicator, MemoryHealthIndicator, - TypeOrmHealthIndicator, + TypeOrmHealthIndicator } from '@nestjs/terminus'; import { Perm, definePermission } from '../auth/decorators/permission.decorator'; @@ -15,7 +15,7 @@ export const PermissionHealth = definePermission('app:health', { DB: 'database', MH: 'memory-heap', MR: 'memory-rss', - DISK: 'disk', + DISK: 'disk' } as const); @ApiTags('Health - 健康检查') @@ -65,7 +65,7 @@ export class HealthController { return this.disk.checkStorage('disk', { // The used disk storage should not exceed 75% of the full disk size thresholdPercent: 0.75, - path: '/', + path: '/' }); } } diff --git a/src/modules/health/health.module.ts b/src/modules/health/health.module.ts index e488987..674c072 100644 --- a/src/modules/health/health.module.ts +++ b/src/modules/health/health.module.ts @@ -6,6 +6,6 @@ import { HealthController } from './health.controller'; @Module({ imports: [TerminusModule, HttpModule], - controllers: [HealthController], + controllers: [HealthController] }) export class HealthModule {} diff --git a/src/modules/netdisk/manager/manage.class.ts b/src/modules/netdisk/manager/manage.class.ts index d2dfa0b..1c099d8 100644 --- a/src/modules/netdisk/manager/manage.class.ts +++ b/src/modules/netdisk/manager/manage.class.ts @@ -49,7 +49,7 @@ export class SFileInfoDetail { mimeType: string; @ApiProperty({ - description: '文件存储类型,2 表示归档存储,1 表示低频存储,0表示普通存储。', + description: '文件存储类型,2 表示归档存储,1 表示低频存储,0表示普通存储。' }) type: number; diff --git a/src/modules/netdisk/manager/manage.controller.ts b/src/modules/netdisk/manager/manage.controller.ts index 58e12e6..8a6d2eb 100644 --- a/src/modules/netdisk/manager/manage.controller.ts +++ b/src/modules/netdisk/manager/manage.controller.ts @@ -17,7 +17,7 @@ import { GetFileListDto, MKDirDto, MarkFileDto, - RenameDto, + RenameDto } from './manage.dto'; import { NetDiskManageService } from './manage.service'; @@ -33,7 +33,7 @@ export const permissions = definePermission('netdisk:manage', { DOWNLOAD: 'download', RENAME: 'rename', CUT: 'cut', - COPY: 'copy', + COPY: 'copy' } as const); @ApiTags('NetDiskManage - 网盘管理模块') @@ -67,7 +67,7 @@ export class NetDiskManageController { checkIsDemoMode(); return { - token: this.manageService.createUploadToken(`${user.uid}`), + token: this.manageService.createUploadToken(`${user.uid}`) }; } @@ -84,7 +84,7 @@ export class NetDiskManageController { @Perm(permissions.MARK) async mark(@Body() dto: MarkFileDto): Promise { await this.manageService.changeFileHeaders(dto.name, dto.path, { - mark: dto.mark, + mark: dto.mark }); } diff --git a/src/modules/netdisk/manager/manage.dto.ts b/src/modules/netdisk/manager/manage.dto.ts index 1b54c84..11897e4 100644 --- a/src/modules/netdisk/manager/manage.dto.ts +++ b/src/modules/netdisk/manager/manage.dto.ts @@ -11,7 +11,7 @@ import { ValidateNested, ValidationArguments, ValidatorConstraint, - ValidatorConstraintInterface, + ValidatorConstraintInterface } from 'class-validator'; import { isEmpty } from 'lodash'; diff --git a/src/modules/netdisk/manager/manage.service.ts b/src/modules/netdisk/manager/manage.service.ts index 9f639c7..50f4d8e 100644 --- a/src/modules/netdisk/manager/manage.service.ts +++ b/src/modules/netdisk/manager/manage.service.ts @@ -11,7 +11,7 @@ import { NETDISK_COPY_SUFFIX, NETDISK_DELIMITER, NETDISK_HANDLE_MAX_ITEM, - NETDISK_LIMIT, + NETDISK_LIMIT } from '~/constants/oss.constant'; import { AccountInfo } from '~/modules/user/user.model'; @@ -38,7 +38,7 @@ export class NetDiskManageService { ) { this.mac = new qiniu.auth.digest.Mac(this.qiniuConfig.accessKey, this.qiniuConfig.secretKey); this.config = new qiniu.conf.Config({ - zone: this.qiniuConfig.zone, + zone: this.qiniuConfig.zone }); // bucket manager this.bucketManager = new qiniu.rs.BucketManager(this.mac, this.config); @@ -60,7 +60,7 @@ export class NetDiskManageService { prefix: searching ? '' : prefix, limit: NETDISK_LIMIT, delimiter: searching ? '' : NETDISK_DELIMITER, - marker, + marker }, (err, respBody, respInfo) => { if (err) { @@ -80,7 +80,7 @@ export class NetDiskManageService { fileList.push({ name: (dirPath as string).substr(0, dirPath.length - 1).replace(prefix, ''), type: 'dir', - id: generateRandomValue(10), + id: generateRandomValue(10) }); } } @@ -104,7 +104,7 @@ export class NetDiskManageService { id: generateRandomValue(10), name: ditName, type: 'dir', - belongTo: pathList.join(NETDISK_DELIMITER), + belongTo: pathList.join(NETDISK_DELIMITER) }); } else if (name.includes(skey)) { // 文件 @@ -115,7 +115,7 @@ export class NetDiskManageService { fsize: item.fsize, mimeType: item.mimeType, putTime: new Date(Number.parseInt(item.putTime) / 10000), - belongTo: pathList.join(NETDISK_DELIMITER), + belongTo: pathList.join(NETDISK_DELIMITER) }); } } else { @@ -128,7 +128,7 @@ export class NetDiskManageService { type: 'file', fsize: item.fsize, mimeType: item.mimeType, - putTime: new Date(Number.parseInt(item.putTime) / 10000), + putTime: new Date(Number.parseInt(item.putTime) / 10000) }); } } @@ -136,7 +136,7 @@ export class NetDiskManageService { } resolve({ list: fileList, - marker: respBody.marker || null, + marker: respBody.marker || null }); } else { reject( @@ -170,7 +170,7 @@ export class NetDiskManageService { putTime: new Date(Number.parseInt(respBody.putTime) / 10000), type: respBody.type, uploader: '', - mark: respBody?.['x-qn-meta']?.['!mark'] ?? '', + mark: respBody?.['x-qn-meta']?.['!mark'] ?? '' }; if (!respBody.endUser) { resolve(detailInfo); @@ -295,7 +295,7 @@ export class NetDiskManageService { scope: this.qiniuConfig.bucket, insertOnly: 1, fsizeLimit: 1024 ** 2 * 10, - endUser, + endUser }); const uploadToken = policy.uploadToken(this.mac); return uploadToken; @@ -310,7 +310,7 @@ export class NetDiskManageService { const fileName = `${dir}${name}`; const toFileName = `${dir}${toName}`; const op = { - force: true, + force: true }; return new Promise((resolve, reject) => { this.bucketManager.move( @@ -345,7 +345,7 @@ export class NetDiskManageService { const fileName = `${dir}${name}`; const toFileName = `${toDir}${name}`; const op = { - force: true, + force: true }; return new Promise((resolve, reject) => { this.bucketManager.move( @@ -383,7 +383,7 @@ export class NetDiskManageService { const bn = basename(name, ext); const toFileName = `${toDir}${bn}${NETDISK_COPY_SUFFIX}${ext}`; const op = { - force: true, + force: true }; return new Promise((resolve, reject) => { this.bucketManager.copy( @@ -420,7 +420,7 @@ export class NetDiskManageService { let hasFile = true; let marker = ''; const op = { - force: true, + force: true }; const bucketName = this.qiniuConfig.bucket; while (hasFile) { @@ -431,7 +431,7 @@ export class NetDiskManageService { { prefix: dirName, limit: NETDISK_HANDLE_MAX_ITEM, - marker, + marker }, (err, respBody, respInfo) => { if (err) { @@ -567,7 +567,7 @@ export class NetDiskManageService { { prefix: dirName, limit: NETDISK_HANDLE_MAX_ITEM, - marker, + marker }, (err, respBody, respInfo) => { if (err) { @@ -618,7 +618,7 @@ export class NetDiskManageService { async copyMultiFileOrDir(fileList: FileOpItem[], dir: string, toDir: string): Promise { const files = fileList.filter(item => item.type === 'file'); const op = { - force: true, + force: true }; if (files.length > 0) { // 批处理文件 @@ -671,7 +671,7 @@ export class NetDiskManageService { { prefix: dirName, limit: NETDISK_HANDLE_MAX_ITEM, - marker, + marker }, (err, respBody, respInfo) => { if (err) { @@ -729,7 +729,7 @@ export class NetDiskManageService { async moveMultiFileOrDir(fileList: FileOpItem[], dir: string, toDir: string): Promise { const files = fileList.filter(item => item.type === 'file'); const op = { - force: true, + force: true }; if (files.length > 0) { // 批处理文件 @@ -782,7 +782,7 @@ export class NetDiskManageService { { prefix: dirName, limit: NETDISK_HANDLE_MAX_ITEM, - marker, + marker }, (err, respBody, respInfo) => { if (err) { diff --git a/src/modules/netdisk/netdisk.module.ts b/src/modules/netdisk/netdisk.module.ts index 4883791..dc14031 100644 --- a/src/modules/netdisk/netdisk.module.ts +++ b/src/modules/netdisk/netdisk.module.ts @@ -15,11 +15,11 @@ import { NetDiskOverviewService } from './overview/overview.service'; RouterModule.register([ { path: 'netdisk', - module: NetdiskModule, - }, - ]), + module: NetdiskModule + } + ]) ], controllers: [NetDiskManageController, NetDiskOverviewController], - providers: [NetDiskManageService, NetDiskOverviewService], + providers: [NetDiskManageService, NetDiskOverviewService] }) export class NetdiskModule {} diff --git a/src/modules/netdisk/overview/overview.controller.ts b/src/modules/netdisk/overview/overview.controller.ts index acdfc9f..20a8ae7 100644 --- a/src/modules/netdisk/overview/overview.controller.ts +++ b/src/modules/netdisk/overview/overview.controller.ts @@ -8,7 +8,7 @@ import { OverviewSpaceInfo } from './overview.dto'; import { NetDiskOverviewService } from './overview.service'; export const permissions = definePermission('netdisk:overview', { - DESC: 'desc', + DESC: 'desc' } as const); @ApiTags('NetDiskOverview - 网盘概览模块') @@ -35,7 +35,7 @@ export class NetDiskOverviewController { hitSize: hit.datas[hit.datas.length - 1], spaceSize: space.datas[space.datas.length - 1], flowTrend: flow, - sizeTrend: space, + sizeTrend: space }; } } diff --git a/src/modules/netdisk/overview/overview.service.ts b/src/modules/netdisk/overview/overview.service.ts index 72e0387..1f8a352 100644 --- a/src/modules/netdisk/overview/overview.service.ts +++ b/src/modules/netdisk/overview/overview.service.ts @@ -36,7 +36,7 @@ export class NetDiskOverviewService { getStatisticUrl(type: string, queryParams = {}) { const defaultParams = { $bucket: this.qiniuConfig.bucket, - g: 'day', + g: 'day' }; const searchParams = new URLSearchParams({ ...defaultParams, ...queryParams }); return decodeURIComponent(`${OSS_API}/v6/${type}?${searchParams}`); @@ -53,8 +53,8 @@ export class NetDiskOverviewService { return this.httpService.axiosRef.get(url, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: `${accessToken}`, - }, + Authorization: `${accessToken}` + } }); } @@ -89,7 +89,7 @@ export class NetDiskOverviewService { datas: data.datas, times: data.times.map(e => { return dayjs.unix(e).date(); - }), + }) }; } @@ -105,7 +105,7 @@ export class NetDiskOverviewService { times: data.times.map(e => { return dayjs.unix(e).date(); }), - datas: data.datas, + datas: data.datas }; } @@ -121,7 +121,7 @@ export class NetDiskOverviewService { end, $ftype: 0, $src: 'origin', - select: 'flow', + select: 'flow' }); const { data } = await this.getStatisticData(url); const times = []; @@ -132,7 +132,7 @@ export class NetDiskOverviewService { }); return { times, - datas, + datas }; } @@ -148,7 +148,7 @@ export class NetDiskOverviewService { end, $ftype: 0, $src: 'inner', - select: 'hit', + select: 'hit' }); const { data } = await this.getStatisticData(url); const times = []; @@ -159,7 +159,7 @@ export class NetDiskOverviewService { }); return { times, - datas, + datas }; } } diff --git a/src/modules/sse/sse.controller.ts b/src/modules/sse/sse.controller.ts index e9f0ecc..e6c581f 100644 --- a/src/modules/sse/sse.controller.ts +++ b/src/modules/sse/sse.controller.ts @@ -5,7 +5,7 @@ import { ParseIntPipe, Req, Res, - Sse, + Sse } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { FastifyReply, FastifyRequest } from 'fastify'; @@ -26,7 +26,7 @@ export class SseController implements BeforeApplicationShutdown { private closeAllConnect() { this.sseService.sendToAll({ type: 'close', - data: 'bye~', + data: 'bye~' }); this.replyMap.forEach(reply => { reply.raw.end().destroy(); diff --git a/src/modules/sse/sse.module.ts b/src/modules/sse/sse.module.ts index 62bcc39..4185d1b 100644 --- a/src/modules/sse/sse.module.ts +++ b/src/modules/sse/sse.module.ts @@ -7,6 +7,6 @@ import { SseService } from './sse.service'; imports: [], controllers: [SseController], providers: [SseService], - exports: [SseService], + exports: [SseService] }) export class SseModule {} diff --git a/src/modules/sse/sse.service.ts b/src/modules/sse/sse.service.ts index a514e36..cec6e37 100644 --- a/src/modules/sse/sse.service.ts +++ b/src/modules/sse/sse.service.ts @@ -58,9 +58,9 @@ export class SseService { const roleMenus = await RoleEntity.find({ where: { menus: { - id: In(menuIds), - }, - }, + id: In(menuIds) + } + } }); const roleIds = roleMenus.map(n => n.id).concat(ROOT_ROLE_ID); await this.noticeClientToUpdateMenusByRoleIds(roleIds); @@ -73,9 +73,9 @@ export class SseService { const users = await UserEntity.find({ where: { roles: { - id: In(roleIds), - }, - }, + id: In(roleIds) + } + } }); if (users) { const userIds = users.map(n => n.id); diff --git a/src/modules/system/dept/dept.controller.ts b/src/modules/system/dept/dept.controller.ts index 06d28a8..044c045 100644 --- a/src/modules/system/dept/dept.controller.ts +++ b/src/modules/system/dept/dept.controller.ts @@ -18,7 +18,7 @@ export const permissions = definePermission('system:dept', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiSecurityAuth() diff --git a/src/modules/system/dept/dept.dto.ts b/src/modules/system/dept/dept.dto.ts index 14b15cf..42d2507 100644 --- a/src/modules/system/dept/dept.dto.ts +++ b/src/modules/system/dept/dept.dto.ts @@ -8,7 +8,7 @@ import { IsString, Min, MinLength, - ValidateNested, + ValidateNested } from 'class-validator'; export class DeptDto { diff --git a/src/modules/system/dept/dept.module.ts b/src/modules/system/dept/dept.module.ts index aeade9c..6de2058 100644 --- a/src/modules/system/dept/dept.module.ts +++ b/src/modules/system/dept/dept.module.ts @@ -14,6 +14,6 @@ const services = [DeptService]; imports: [TypeOrmModule.forFeature([DeptEntity]), UserModule, RoleModule], controllers: [DeptController], providers: [...services], - exports: [TypeOrmModule, ...services], + exports: [TypeOrmModule, ...services] }) export class DeptModule {} diff --git a/src/modules/system/dept/dept.service.ts b/src/modules/system/dept/dept.service.ts index 418eaf3..8d846c3 100644 --- a/src/modules/system/dept/dept.service.ts +++ b/src/modules/system/dept/dept.service.ts @@ -46,7 +46,7 @@ export class DeptService { await this.deptRepository.save({ ...data, - parent, + parent }); } @@ -61,7 +61,7 @@ export class DeptService { await this.deptRepository.save({ ...item, ...data, - parent, + parent }); } @@ -117,7 +117,7 @@ export class DeptService { const deptTree = await this.deptRepository.findTrees({ depth: 2, - relations: ['parent'], + relations: ['parent'] }); deleteEmptyChildren(deptTree); diff --git a/src/modules/system/dict-item/dict-item.controller.ts b/src/modules/system/dict-item/dict-item.controller.ts index a0ac474..4687594 100644 --- a/src/modules/system/dict-item/dict-item.controller.ts +++ b/src/modules/system/dict-item/dict-item.controller.ts @@ -17,7 +17,7 @@ export const permissions = definePermission('system:dict-item', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('System - 字典项模块') diff --git a/src/modules/system/dict-item/dict-item.module.ts b/src/modules/system/dict-item/dict-item.module.ts index 824e0f9..4929562 100644 --- a/src/modules/system/dict-item/dict-item.module.ts +++ b/src/modules/system/dict-item/dict-item.module.ts @@ -11,6 +11,6 @@ const services = [DictItemService]; imports: [TypeOrmModule.forFeature([DictItemEntity])], controllers: [DictItemController], providers: [...services], - exports: [TypeOrmModule, ...services], + exports: [TypeOrmModule, ...services] }) export class DictItemModule {} diff --git a/src/modules/system/dict-item/dict-item.service.ts b/src/modules/system/dict-item/dict-item.service.ts index 295cb60..a1f5cac 100644 --- a/src/modules/system/dict-item/dict-item.service.ts +++ b/src/modules/system/dict-item/dict-item.service.ts @@ -26,7 +26,7 @@ export class DictItemService { pageSize, label, value, - typeId, + typeId }: DictItemQueryDto): Promise> { const queryBuilder = this.dictItemRepository .createQueryBuilder('dict_item') @@ -35,8 +35,8 @@ export class DictItemService { ...(label && { label: Like(`%${label}%`) }), ...(value && { value: Like(`%${value}%`) }), type: { - id: typeId, - }, + id: typeId + } }); return paginate(queryBuilder, { page, pageSize }); @@ -57,8 +57,8 @@ export class DictItemService { await this.dictItemRepository.insert({ ...rest, type: { - id: typeId, - }, + id: typeId + } }); } @@ -70,8 +70,8 @@ export class DictItemService { await this.dictItemRepository.update(id, { ...rest, type: { - id: typeId, - }, + id: typeId + } }); } diff --git a/src/modules/system/dict-type/dict-type.controller.ts b/src/modules/system/dict-type/dict-type.controller.ts index 4d98575..8c3c347 100644 --- a/src/modules/system/dict-type/dict-type.controller.ts +++ b/src/modules/system/dict-type/dict-type.controller.ts @@ -17,7 +17,7 @@ export const permissions = definePermission('system:dict-type', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('System - 字典类型模块') diff --git a/src/modules/system/dict-type/dict-type.module.ts b/src/modules/system/dict-type/dict-type.module.ts index b5ad211..626bb5e 100644 --- a/src/modules/system/dict-type/dict-type.module.ts +++ b/src/modules/system/dict-type/dict-type.module.ts @@ -11,6 +11,6 @@ const services = [DictTypeService]; imports: [TypeOrmModule.forFeature([DictTypeEntity])], controllers: [DictTypeController], providers: [...services], - exports: [TypeOrmModule, ...services], + exports: [TypeOrmModule, ...services] }) export class DictTypeModule {} diff --git a/src/modules/system/dict-type/dict-type.service.ts b/src/modules/system/dict-type/dict-type.service.ts index 2b730fc..cda4d92 100644 --- a/src/modules/system/dict-type/dict-type.service.ts +++ b/src/modules/system/dict-type/dict-type.service.ts @@ -25,11 +25,11 @@ export class DictTypeService { page, pageSize, name, - code, + code }: DictTypeQueryDto): Promise> { const queryBuilder = this.dictTypeRepository.createQueryBuilder('dict_type').where({ ...(name && { name: Like(`%${name}%`) }), - ...(code && { code: Like(`%${code}%`) }), + ...(code && { code: Like(`%${code}%`) }) }); return paginate(queryBuilder, { page, pageSize }); diff --git a/src/modules/system/log/log.controller.ts b/src/modules/system/log/log.controller.ts index 144de21..b98c08d 100644 --- a/src/modules/system/log/log.controller.ts +++ b/src/modules/system/log/log.controller.ts @@ -17,7 +17,7 @@ import { TaskLogService } from './services/task-log.service'; export const permissions = definePermission('system:log', { TaskList: 'task:list', LogList: 'login:list', - CaptchaList: 'captcha:list', + CaptchaList: 'captcha:list' } as const); @ApiSecurityAuth() diff --git a/src/modules/system/log/log.module.ts b/src/modules/system/log/log.module.ts index 7f1b5b8..b39d2ea 100644 --- a/src/modules/system/log/log.module.ts +++ b/src/modules/system/log/log.module.ts @@ -16,10 +16,10 @@ const providers = [LoginLogService, TaskLogService, CaptchaLogService]; @Module({ imports: [ TypeOrmModule.forFeature([LoginLogEntity, CaptchaLogEntity, TaskLogEntity]), - UserModule, + UserModule ], controllers: [LogController], providers: [...providers], - exports: [TypeOrmModule, ...providers], + exports: [TypeOrmModule, ...providers] }) export class LogModule {} diff --git a/src/modules/system/log/services/captcha-log.service.ts b/src/modules/system/log/services/captcha-log.service.ts index b45c04c..970a7d8 100644 --- a/src/modules/system/log/services/captcha-log.service.ts +++ b/src/modules/system/log/services/captcha-log.service.ts @@ -25,7 +25,7 @@ export class CaptchaLogService { account, code, provider, - userId: uid, + userId: uid }); } @@ -36,7 +36,7 @@ export class CaptchaLogService { return paginate(queryBuilder, { page, - pageSize, + pageSize }); } diff --git a/src/modules/system/log/services/login-log.service.ts b/src/modules/system/log/services/login-log.service.ts index 256c78b..6f03578 100644 --- a/src/modules/system/log/services/login-log.service.ts +++ b/src/modules/system/log/services/login-log.service.ts @@ -23,7 +23,7 @@ async function parseLoginLog(e: any, parser: UAParser): Promise { os: `${`${uaResult.os.name ?? ''} `}${uaResult.os.version}`, browser: `${`${uaResult.browser.name ?? ''} `}${uaResult.browser.version}`, username: e.user_username, - time: e.login_log_created_at, + time: e.login_log_created_at }; } @@ -42,7 +42,7 @@ export class LoginLogService { ip, ua, address, - user: { id: uid }, + user: { id: uid } }); } catch (e) { console.error(e); @@ -59,15 +59,15 @@ export class LoginLogService { ...(time && { createdAt: Between(time[0], time[1]) }), ...(username && { user: { - username: Like(`%${username}%`), - }, - }), + username: Like(`%${username}%`) + } + }) }) .orderBy('login_log.created_at', 'DESC'); const { items, ...rest } = await paginateRaw(queryBuilder, { page, - pageSize, + pageSize }); const parser = new UAParser(); @@ -75,7 +75,7 @@ export class LoginLogService { return { items: loginLogInfos, - ...rest, + ...rest }; } diff --git a/src/modules/system/log/services/task-log.service.ts b/src/modules/system/log/services/task-log.service.ts index e0da14a..c5fd706 100644 --- a/src/modules/system/log/services/task-log.service.ts +++ b/src/modules/system/log/services/task-log.service.ts @@ -20,7 +20,7 @@ export class TaskLogService { status, detail: err, time, - task: { id: tid }, + task: { id: tid } }); return result.id; } @@ -33,7 +33,7 @@ export class TaskLogService { return paginate(queryBuilder, { page, - pageSize, + pageSize }); } diff --git a/src/modules/system/menu/menu.controller.ts b/src/modules/system/menu/menu.controller.ts index af30512..d14b8de 100644 --- a/src/modules/system/menu/menu.controller.ts +++ b/src/modules/system/menu/menu.controller.ts @@ -6,7 +6,7 @@ import { Get, Post, Put, - Query, + Query } from '@nestjs/common'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { flattenDeep } from 'lodash'; @@ -17,7 +17,7 @@ import { ApiSecurityAuth } from '~/common/decorators/swagger.decorator'; import { Perm, definePermission, - getDefinePermissions, + getDefinePermissions } from '~/modules/auth/decorators/permission.decorator'; import { MenuDto, MenuQueryDto, MenuUpdateDto } from './menu.dto'; @@ -29,7 +29,7 @@ export const permissions = definePermission('system:menu', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('System - 菜单权限模块') diff --git a/src/modules/system/menu/menu.dto.ts b/src/modules/system/menu/menu.dto.ts index 4d734e5..da2b024 100644 --- a/src/modules/system/menu/menu.dto.ts +++ b/src/modules/system/menu/menu.dto.ts @@ -7,7 +7,7 @@ import { IsString, Min, MinLength, - ValidateIf, + ValidateIf } from 'class-validator'; export class MenuDto { diff --git a/src/modules/system/menu/menu.entity.ts b/src/modules/system/menu/menu.entity.ts index e31a638..938c497 100644 --- a/src/modules/system/menu/menu.entity.ts +++ b/src/modules/system/menu/menu.entity.ts @@ -49,7 +49,7 @@ export class MenuEntity extends CommonEntity { status: number; @ManyToMany(() => RoleEntity, role => role.menus, { - onDelete: 'CASCADE', + onDelete: 'CASCADE' }) roles: Relation; } diff --git a/src/modules/system/menu/menu.module.ts b/src/modules/system/menu/menu.module.ts index bfe18d5..03aa7c2 100644 --- a/src/modules/system/menu/menu.module.ts +++ b/src/modules/system/menu/menu.module.ts @@ -15,6 +15,6 @@ const providers = [MenuService, SseService]; imports: [TypeOrmModule.forFeature([MenuEntity]), forwardRef(() => RoleModule)], controllers: [MenuController], providers: [...providers], - exports: [TypeOrmModule, ...providers], + exports: [TypeOrmModule, ...providers] }) export class MenuModule {} diff --git a/src/modules/system/menu/menu.service.ts b/src/modules/system/menu/menu.service.ts index 9adaf75..b156714 100644 --- a/src/modules/system/menu/menu.service.ts +++ b/src/modules/system/menu/menu.service.ts @@ -39,9 +39,9 @@ export class MenuService { ...(path && { path: Like(`%${path}%`) }), ...(permission && { permission: Like(`%${permission}%`) }), ...(component && { component: Like(`%${component}%`) }), - ...(isNumber(status) ? { status } : null), + ...(isNumber(status) ? { status } : null) }, - order: { orderNo: 'ASC' }, + order: { orderNo: 'ASC' } }); const menuList = generatorMenu(menus); @@ -166,7 +166,7 @@ export class MenuService { if (this.roleService.hasAdminRole(roleIds)) { result = await this.menuRepository.findBy({ permission: Not(IsNull()), - type: In([1, 2]), + type: In([1, 2]) }); } else { if (isEmpty(roleIds)) return permission; @@ -237,9 +237,9 @@ export class MenuService { return !!(await this.menuRepository.findOne({ where: { roles: { - id, - }, - }, + id + } + } })); } } diff --git a/src/modules/system/online/online.controller.ts b/src/modules/system/online/online.controller.ts index e1069cd..22c96f8 100644 --- a/src/modules/system/online/online.controller.ts +++ b/src/modules/system/online/online.controller.ts @@ -16,7 +16,7 @@ import { OnlineService } from './online.service'; export const permissions = definePermission('system:online', { LIST: 'list', - KICK: 'kick', + KICK: 'kick' } as const); @ApiTags('System - 在线用户模块') diff --git a/src/modules/system/online/online.module.ts b/src/modules/system/online/online.module.ts index 793e71b..85ec082 100644 --- a/src/modules/system/online/online.module.ts +++ b/src/modules/system/online/online.module.ts @@ -18,10 +18,10 @@ const providers = [OnlineService]; forwardRef(() => SocketModule), AuthModule, UserModule, - RoleModule, + RoleModule ], controllers: [OnlineController], providers, - exports: [...providers], + exports: [...providers] }) export class OnlineModule {} diff --git a/src/modules/system/online/online.service.ts b/src/modules/system/online/online.service.ts index 8bf11fa..39ba7c2 100644 --- a/src/modules/system/online/online.service.ts +++ b/src/modules/system/online/online.service.ts @@ -90,7 +90,7 @@ export class OnlineService { time: e.created_at, os: `${u.os.name} ${u.os.version}`, browser: `${u.browser.name} ${u.browser.version}`, - disable: currentUid === e.id || e.id === rootUserId, + disable: currentUid === e.id || e.id === rootUserId }; }); } diff --git a/src/modules/system/param-config/param-config.controller.ts b/src/modules/system/param-config/param-config.controller.ts index b792eb3..baaddd7 100644 --- a/src/modules/system/param-config/param-config.controller.ts +++ b/src/modules/system/param-config/param-config.controller.ts @@ -16,7 +16,7 @@ export const permissions = definePermission('system:param-config', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('System - 参数配置模块') diff --git a/src/modules/system/param-config/param-config.module.ts b/src/modules/system/param-config/param-config.module.ts index 0da5acf..e7797b4 100644 --- a/src/modules/system/param-config/param-config.module.ts +++ b/src/modules/system/param-config/param-config.module.ts @@ -11,6 +11,6 @@ const services = [ParamConfigService]; imports: [TypeOrmModule.forFeature([ParamConfigEntity])], controllers: [ParamConfigController], providers: [...services], - exports: [TypeOrmModule, ...services], + exports: [TypeOrmModule, ...services] }) export class ParamConfigModule {} diff --git a/src/modules/system/param-config/param-config.service.ts b/src/modules/system/param-config/param-config.service.ts index 926b5ae..7f185ff 100644 --- a/src/modules/system/param-config/param-config.service.ts +++ b/src/modules/system/param-config/param-config.service.ts @@ -24,13 +24,13 @@ export class ParamConfigService { async page({ page, pageSize, - name, + name }: ParamConfigQueryDto): Promise> { const queryBuilder = this.paramConfigRepository.createQueryBuilder('config'); if (name) { queryBuilder.where('config.name LIKE :name', { - name: `%${name}%`, + name: `%${name}%` }); } @@ -80,7 +80,7 @@ export class ParamConfigService { async findValueByKey(key: string): Promise { const result = await this.paramConfigRepository.findOne({ where: { key }, - select: ['value'], + select: ['value'] }); if (result) return result.value; diff --git a/src/modules/system/role/role.controller.ts b/src/modules/system/role/role.controller.ts index 05ba9c6..192ca13 100644 --- a/src/modules/system/role/role.controller.ts +++ b/src/modules/system/role/role.controller.ts @@ -6,7 +6,7 @@ import { Get, Post, Put, - Query, + Query } from '@nestjs/common'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; @@ -28,7 +28,7 @@ export const permissions = definePermission('system:role', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('System - 角色模块') diff --git a/src/modules/system/role/role.entity.ts b/src/modules/system/role/role.entity.ts index 7a4854b..58d2159 100644 --- a/src/modules/system/role/role.entity.ts +++ b/src/modules/system/role/role.entity.ts @@ -37,7 +37,7 @@ export class RoleEntity extends CommonEntity { @JoinTable({ name: 'sys_role_menus', joinColumn: { name: 'role_id', referencedColumnName: 'id' }, - inverseJoinColumn: { name: 'menu_id', referencedColumnName: 'id' }, + inverseJoinColumn: { name: 'menu_id', referencedColumnName: 'id' } }) menus: Relation; } diff --git a/src/modules/system/role/role.module.ts b/src/modules/system/role/role.module.ts index b43e4a2..087fef6 100644 --- a/src/modules/system/role/role.module.ts +++ b/src/modules/system/role/role.module.ts @@ -15,6 +15,6 @@ const providers = [RoleService, SseService]; imports: [TypeOrmModule.forFeature([RoleEntity]), forwardRef(() => MenuModule)], controllers: [RoleController], providers: [...providers], - exports: [TypeOrmModule, ...providers], + exports: [TypeOrmModule, ...providers] }) export class RoleModule {} diff --git a/src/modules/system/role/role.service.ts b/src/modules/system/role/role.service.ts index 0908d4f..d8694cc 100644 --- a/src/modules/system/role/role.service.ts +++ b/src/modules/system/role/role.service.ts @@ -32,17 +32,17 @@ export class RoleService { pageSize, name, value, - status, + status }: RoleQueryDto): Promise> { const queryBuilder = this.roleRepository.createQueryBuilder('role').where({ ...(name ? { name: Like(`%${name}%`) } : null), ...(value ? { value: Like(`%${value}%`) } : null), - ...(isNumber(status) ? { status } : null), + ...(isNumber(status) ? { status } : null) }); return paginate(queryBuilder, { page, - pageSize, + pageSize }); } @@ -53,13 +53,13 @@ export class RoleService { const info = await this.roleRepository .createQueryBuilder('role') .where({ - id, + id }) .getOne(); const menus = await this.menuRepository.find({ where: { roles: { id } }, - select: ['id'], + select: ['id'] }); return { ...info, menuIds: menus.map(m => m.id) }; @@ -76,7 +76,7 @@ export class RoleService { async create({ menuIds, ...data }: RoleDto): Promise<{ roleId: number }> { const role = await this.roleRepository.save({ ...data, - menus: menuIds ? await this.menuRepository.findBy({ id: In(menuIds) }) : [], + menus: menuIds ? await this.menuRepository.findBy({ id: In(menuIds) }) : [] }); return { roleId: role.id }; @@ -92,7 +92,7 @@ export class RoleService { // using transaction await this.entityManager.transaction(async manager => { const menus = await this.menuRepository.find({ - where: { id: In(menuIds) }, + where: { id: In(menuIds) } }); const role = await this.roleRepository.findOne({ where: { id } }); @@ -108,8 +108,8 @@ export class RoleService { async getRoleIdsByUser(id: number): Promise { const roles = await this.roleRepository.find({ where: { - users: { id }, - }, + users: { id } + } }); if (!isEmpty(roles)) return roles.map(r => r.id); @@ -120,7 +120,7 @@ export class RoleService { async getRoleValues(ids: number[]): Promise { return ( await this.roleRepository.findBy({ - id: In(ids), + id: In(ids) }) ).map(r => r.value); } @@ -128,8 +128,8 @@ export class RoleService { async isAdminRoleByUser(uid: number): Promise { const roles = await this.roleRepository.find({ where: { - users: { id: uid }, - }, + users: { id: uid } + } }); if (!isEmpty(roles)) { @@ -149,9 +149,9 @@ export class RoleService { return this.roleRepository.exist({ where: { users: { - roles: { id }, - }, - }, + roles: { id } + } + } }); } } diff --git a/src/modules/system/serve/serve.module.ts b/src/modules/system/serve/serve.module.ts index a2963cc..4a2f421 100644 --- a/src/modules/system/serve/serve.module.ts +++ b/src/modules/system/serve/serve.module.ts @@ -11,6 +11,6 @@ const providers = [ServeService]; imports: [forwardRef(() => SystemModule)], controllers: [ServeController], providers: [...providers], - exports: [...providers], + exports: [...providers] }) export class ServeModule {} diff --git a/src/modules/system/serve/serve.service.ts b/src/modules/system/serve/serve.service.ts index b20c2f5..59b7ba1 100644 --- a/src/modules/system/serve/serve.service.ts +++ b/src/modules/system/serve/serve.service.ts @@ -15,7 +15,7 @@ export class ServeService { si.osInfo(), si.cpu(), si.currentLoad(), - si.mem(), + si.mem() ]) ).map((p: any) => p.value); @@ -36,7 +36,7 @@ export class ServeService { npmVersion: versions.npm, nodeVersion: versions.node, os: osinfo.platform, - arch: osinfo.arch, + arch: osinfo.arch }, cpu: { manufacturer: cpuinfo.manufacturer, @@ -49,15 +49,15 @@ export class ServeService { coresLoad: currentLoadinfo.cpus.map(e => { return { rawLoad: e.rawLoad, - rawLoadIdle: e.rawLoadIdle, + rawLoadIdle: e.rawLoadIdle }; - }), + }) }, disk: diskinfo, memory: { total: meminfo.total, - available: meminfo.available, - }, + available: meminfo.available + } }; } } diff --git a/src/modules/system/system.module.ts b/src/modules/system/system.module.ts index c919c1c..83d9189 100644 --- a/src/modules/system/system.module.ts +++ b/src/modules/system/system.module.ts @@ -26,7 +26,7 @@ const modules = [ LogModule, TaskModule, OnlineModule, - ServeModule, + ServeModule ]; @Module({ @@ -36,10 +36,10 @@ const modules = [ { path: 'system', module: SystemModule, - children: [...modules], - }, - ]), + children: [...modules] + } + ]) ], - exports: [...modules], + exports: [...modules] }) export class SystemModule {} diff --git a/src/modules/system/task/constant.ts b/src/modules/system/task/constant.ts index e32bf7a..0dac2d1 100644 --- a/src/modules/system/task/constant.ts +++ b/src/modules/system/task/constant.ts @@ -1,11 +1,11 @@ export enum TaskStatus { Disabled = 0, - Activited = 1, + Activited = 1 } export enum TaskType { Cron = 0, - Interval = 1, + Interval = 1 } export const SYS_TASK_QUEUE_NAME = 'system:sys-task'; diff --git a/src/modules/system/task/task.controller.ts b/src/modules/system/task/task.controller.ts index 975c0b5..e0c7a92 100644 --- a/src/modules/system/task/task.controller.ts +++ b/src/modules/system/task/task.controller.ts @@ -20,7 +20,7 @@ export const permissions = definePermission('system:task', { ONCE: 'once', START: 'start', - STOP: 'stop', + STOP: 'stop' } as const); @ApiTags('System - 任务调度模块') diff --git a/src/modules/system/task/task.dto.ts b/src/modules/system/task/task.dto.ts index 0d9af8b..62ab7e6 100644 --- a/src/modules/system/task/task.dto.ts +++ b/src/modules/system/task/task.dto.ts @@ -13,7 +13,7 @@ import { ValidateIf, ValidationArguments, ValidatorConstraint, - ValidatorConstraintInterface, + ValidatorConstraintInterface } from 'class-validator'; import * as parser from 'cron-parser'; import { isEmpty } from 'lodash'; @@ -70,7 +70,7 @@ export class TaskDto { endTime: string; @ApiPropertyOptional({ - description: '限制执行次数,负数则无限制', + description: '限制执行次数,负数则无限制' }) @IsOptional() @IsInt() diff --git a/src/modules/system/task/task.module.ts b/src/modules/system/task/task.module.ts index 99ce40b..5aba9a3 100644 --- a/src/modules/system/task/task.module.ts +++ b/src/modules/system/task/task.module.ts @@ -24,14 +24,14 @@ const providers = [TaskService, TaskConsumer]; name: SYS_TASK_QUEUE_NAME, useFactory: (configService: ConfigService) => ({ redis: configService.get('redis'), - prefix: SYS_TASK_QUEUE_PREFIX, + prefix: SYS_TASK_QUEUE_PREFIX }), - inject: [ConfigService], + inject: [ConfigService] }), - LogModule, + LogModule ], controllers: [TaskController], providers: [...providers], - exports: [TypeOrmModule, ...providers], + exports: [TypeOrmModule, ...providers] }) export class TaskModule {} diff --git a/src/modules/system/task/task.service.ts b/src/modules/system/task/task.service.ts index dddf2ed..aa59bf5 100644 --- a/src/modules/system/task/task.service.ts +++ b/src/modules/system/task/task.service.ts @@ -5,7 +5,7 @@ import { Injectable, Logger, NotFoundException, - OnModuleInit, + OnModuleInit } from '@nestjs/common'; import { ModuleRef, Reflector } from '@nestjs/core'; import { UnknownElementException } from '@nestjs/core/errors/exceptions/unknown-element.exception'; @@ -69,7 +69,7 @@ export class TaskService implements OnModuleInit { 'failed', 'paused', 'waiting', - 'completed', + 'completed' ]); jobs.forEach(j => { j.remove(); @@ -90,7 +90,7 @@ export class TaskService implements OnModuleInit { name, service, type, - status, + status }: TaskQueryDto): Promise> { const queryBuilder = this.taskRepository .createQueryBuilder('task') @@ -98,7 +98,7 @@ export class TaskService implements OnModuleInit { ...(name ? { name: Like(`%${name}%`) } : null), ...(service ? { service: Like(`%${service}%`) } : null), ...(type ? { type } : null), - ...(isNumber(status) ? { status } : null), + ...(isNumber(status) ? { status } : null) }) .orderBy('task.id', 'ASC'); @@ -166,12 +166,12 @@ export class TaskService implements OnModuleInit { if (task.type === 1) { // 间隔 Repeat every millis (cron setting cannot be used together with this setting.) repeat = { - every: task.every, + every: task.every }; } else { // cron repeat = { - cron: task.cron, + cron: task.cron }; // Start date when the repeat job should start repeating (only with cron). if (task.startTime) repeat.startDate = task.startTime; @@ -187,13 +187,13 @@ export class TaskService implements OnModuleInit { if (job && job.opts) { await this.taskRepository.update(task.id, { jobOpts: JSON.stringify(job.opts.repeat), - status: 1, + status: 1 }); } else { // update status to 0,标识暂停任务,因为启动失败 await job?.remove(); await this.taskRepository.update(task.id, { - status: TaskStatus.Disabled, + status: TaskStatus.Disabled }); throw new BadRequestException('Task Start failed'); } @@ -208,7 +208,7 @@ export class TaskService implements OnModuleInit { const exist = await this.existJob(task.id.toString()); if (!exist) { await this.taskRepository.update(task.id, { - status: TaskStatus.Disabled, + status: TaskStatus.Disabled }); return; } @@ -218,7 +218,7 @@ export class TaskService implements OnModuleInit { 'failed', 'paused', 'waiting', - 'completed', + 'completed' ]); jobs .filter(j => j.data.id === task.id) @@ -301,7 +301,7 @@ export class TaskService implements OnModuleInit { if (!methodName) throw new BadRequestException('serviceName define BadRequestException'); const service = await this.moduleRef.get(serviceName, { - strict: false, + strict: false }); // 安全注解检查 diff --git a/src/modules/tasks/tasks.module.ts b/src/modules/tasks/tasks.module.ts index dd7561d..c422124 100644 --- a/src/modules/tasks/tasks.module.ts +++ b/src/modules/tasks/tasks.module.ts @@ -21,7 +21,7 @@ function createAliasProviders(): ExistingProvider[] { for (const p of providers) { aliasProviders.push({ provide: p.name, - useExisting: p, + useExisting: p }); } return aliasProviders; @@ -40,7 +40,7 @@ export class TasksModule { module: TasksModule, imports: [SystemModule, LogModule], providers: [...providers, ...aliasProviders], - exports: aliasProviders, + exports: aliasProviders }; } } diff --git a/src/modules/todo/todo.controller.ts b/src/modules/todo/todo.controller.ts index ca415d0..d1802a0 100644 --- a/src/modules/todo/todo.controller.ts +++ b/src/modules/todo/todo.controller.ts @@ -19,7 +19,7 @@ export const permissions = definePermission('todo', { CREATE: 'create', READ: 'read', UPDATE: 'update', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('Business - Todo模块') diff --git a/src/modules/todo/todo.module.ts b/src/modules/todo/todo.module.ts index 78ee8ff..28a7b3e 100644 --- a/src/modules/todo/todo.module.ts +++ b/src/modules/todo/todo.module.ts @@ -11,6 +11,6 @@ const services = [TodoService]; imports: [TypeOrmModule.forFeature([TodoEntity])], controllers: [TodoController], providers: [...services], - exports: [TypeOrmModule, ...services], + exports: [TypeOrmModule, ...services] }) export class TodoModule {} diff --git a/src/modules/tools/email/email.module.ts b/src/modules/tools/email/email.module.ts index 76e689a..504c1de 100644 --- a/src/modules/tools/email/email.module.ts +++ b/src/modules/tools/email/email.module.ts @@ -4,6 +4,6 @@ import { EmailController } from './email.controller'; @Module({ imports: [], - controllers: [EmailController], + controllers: [EmailController] }) export class EmailModule {} diff --git a/src/modules/tools/storage/storage.controller.ts b/src/modules/tools/storage/storage.controller.ts index c7a13a3..0be18f2 100644 --- a/src/modules/tools/storage/storage.controller.ts +++ b/src/modules/tools/storage/storage.controller.ts @@ -15,7 +15,7 @@ import { StorageService } from './storage.service'; export const permissions = definePermission('tool:storage', { LIST: 'list', - DELETE: 'delete', + DELETE: 'delete' } as const); @ApiTags('Tools - 存储模块') diff --git a/src/modules/tools/storage/storage.entity.ts b/src/modules/tools/storage/storage.entity.ts index 584ec59..7680f12 100644 --- a/src/modules/tools/storage/storage.entity.ts +++ b/src/modules/tools/storage/storage.entity.ts @@ -13,7 +13,7 @@ export class Storage extends CommonEntity { type: 'varchar', length: 200, nullable: true, - comment: '真实文件名', + comment: '真实文件名' }) @ApiProperty({ description: '真实文件名' }) fileName: string; diff --git a/src/modules/tools/storage/storage.module.ts b/src/modules/tools/storage/storage.module.ts index e74ca3f..3324cf3 100644 --- a/src/modules/tools/storage/storage.module.ts +++ b/src/modules/tools/storage/storage.module.ts @@ -13,6 +13,6 @@ const services = [StorageService]; imports: [TypeOrmModule.forFeature([Storage, UserEntity])], controllers: [StorageController], providers: [...services], - exports: [TypeOrmModule, ...services], + exports: [TypeOrmModule, ...services] }) export class StorageModule {} diff --git a/src/modules/tools/storage/storage.service.ts b/src/modules/tools/storage/storage.service.ts index 99c5fb9..5a8cbf3 100644 --- a/src/modules/tools/storage/storage.service.ts +++ b/src/modules/tools/storage/storage.service.ts @@ -24,7 +24,7 @@ export class StorageService { async create(dto: StorageCreateDto, userId: number): Promise { await this.storageRepository.save({ ...dto, - userId, + userId }); } @@ -48,7 +48,7 @@ export class StorageService { size, extName, time, - username, + username }: StoragePageDto): Promise> { const queryBuilder = this.storageRepository .createQueryBuilder('storage') @@ -60,15 +60,15 @@ export class StorageService { ...(size && { size: Between(size[0], size[1]) }), ...(time && { createdAt: Between(time[0], time[1]) }), ...(username && { - userId: await (await this.userRepository.findOneBy({ username })).id, - }), + userId: await (await this.userRepository.findOneBy({ username })).id + }) }) .orderBy('storage.created_at', 'DESC'); const { items, ...rest } = await paginateRaw(queryBuilder, { page, pageSize, - paginationType: PaginationTypeEnum.LIMIT_AND_OFFSET, + paginationType: PaginationTypeEnum.LIMIT_AND_OFFSET }); function formatResult(result: Storage[]) { @@ -81,14 +81,14 @@ export class StorageService { type: e.storage_type, size: e.storage_size, createdAt: e.storage_created_at, - username: e.user_username, + username: e.user_username }; }); } return { items: formatResult(items), - ...rest, + ...rest }; } diff --git a/src/modules/tools/tools.module.ts b/src/modules/tools/tools.module.ts index 9e8b5e0..efbd337 100644 --- a/src/modules/tools/tools.module.ts +++ b/src/modules/tools/tools.module.ts @@ -15,10 +15,10 @@ const modules = [StorageModule, EmailModule, UploadModule]; { path: 'tools', module: ToolsModule, - children: [...modules], - }, - ]), + children: [...modules] + } + ]) ], - exports: [...modules], + exports: [...modules] }) export class ToolsModule {} diff --git a/src/modules/tools/upload/file.constraint.ts b/src/modules/tools/upload/file.constraint.ts index 3adcf49..ab3caf2 100644 --- a/src/modules/tools/upload/file.constraint.ts +++ b/src/modules/tools/upload/file.constraint.ts @@ -4,7 +4,7 @@ import { ValidationOptions, ValidatorConstraint, ValidatorConstraintInterface, - registerDecorator, + registerDecorator } from 'class-validator'; import { has, isArray } from 'lodash'; @@ -45,7 +45,7 @@ export function IsFile(limits?: FileLimit, validationOptions?: ValidationOptions propertyName, options: validationOptions, constraints: [limits], - validator: FileConstraint, + validator: FileConstraint }); }; } diff --git a/src/modules/tools/upload/upload.controller.ts b/src/modules/tools/upload/upload.controller.ts index e501d68..7c44644 100644 --- a/src/modules/tools/upload/upload.controller.ts +++ b/src/modules/tools/upload/upload.controller.ts @@ -11,7 +11,7 @@ import { FileUploadDto } from './upload.dto'; import { UploadService } from './upload.service'; export const permissions = definePermission('upload', { - UPLOAD: 'upload', + UPLOAD: 'upload' } as const); @ApiSecurityAuth() @@ -25,7 +25,7 @@ export class UploadController { @ApiOperation({ summary: '上传' }) @ApiConsumes('multipart/form-data') @ApiBody({ - type: FileUploadDto, + type: FileUploadDto }) async upload(@Req() req: FastifyRequest, @AuthUser() user: IAuthUser) { if (!req.isMultipart()) throw new BadRequestException('Request is not multipart'); @@ -41,7 +41,7 @@ export class UploadController { const path = await this.uploadService.saveFile(file, user.uid); return { - filename: path, + filename: path }; } catch (error) { console.log(error); diff --git a/src/modules/tools/upload/upload.dto.ts b/src/modules/tools/upload/upload.dto.ts index 1bf0400..dc28e7c 100644 --- a/src/modules/tools/upload/upload.dto.ts +++ b/src/modules/tools/upload/upload.dto.ts @@ -11,10 +11,10 @@ export class FileUploadDto { @IsFile( { mimetypes: ['image/png', 'image/gif', 'image/jpeg', 'image/webp', 'image/svg+xml'], - fileSize: 1024 * 1024 * 10, + fileSize: 1024 * 1024 * 10 }, { - message: '文件类型不正确', + message: '文件类型不正确' } ) file: MultipartFile; diff --git a/src/modules/tools/upload/upload.module.ts b/src/modules/tools/upload/upload.module.ts index b5a83df..4f14cc1 100644 --- a/src/modules/tools/upload/upload.module.ts +++ b/src/modules/tools/upload/upload.module.ts @@ -11,6 +11,6 @@ const services = [UploadService]; imports: [forwardRef(() => StorageModule)], controllers: [UploadController], providers: [...services], - exports: [...services], + exports: [...services] }) export class UploadModule {} diff --git a/src/modules/tools/upload/upload.service.ts b/src/modules/tools/upload/upload.service.ts index 7e42663..605f977 100644 --- a/src/modules/tools/upload/upload.service.ts +++ b/src/modules/tools/upload/upload.service.ts @@ -12,7 +12,7 @@ import { getFilePath, getFileType, getSize, - saveLocalFile, + saveLocalFile } from '~/utils/file.util'; @Injectable() @@ -44,7 +44,7 @@ export class UploadService { path, type, size, - userId, + userId }); return path; diff --git a/src/modules/user/constant.ts b/src/modules/user/constant.ts index 2510ff6..82e2c34 100644 --- a/src/modules/user/constant.ts +++ b/src/modules/user/constant.ts @@ -1,4 +1,4 @@ export enum UserStatus { Disable = 0, - Enabled = 1, + Enabled = 1 } diff --git a/src/modules/user/dto/password.dto.ts b/src/modules/user/dto/password.dto.ts index 6b5e30c..ea5fedb 100644 --- a/src/modules/user/dto/password.dto.ts +++ b/src/modules/user/dto/password.dto.ts @@ -11,7 +11,7 @@ export class PasswordUpdateDto { @ApiProperty({ description: '新密码' }) @Matches(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Za-z])\S*$/, { - message: '密码必须包含数字、字母,长度为6-16', + message: '密码必须包含数字、字母,长度为6-16' }) newPassword: string; } @@ -24,7 +24,7 @@ export class UserPasswordDto { @ApiProperty({ description: '更改后的密码' }) @Matches(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Za-z])\S*$/, { - message: '密码格式不正确', + message: '密码格式不正确' }) password: string; } diff --git a/src/modules/user/dto/user.dto.ts b/src/modules/user/dto/user.dto.ts index 17bb5b6..3b2c3c7 100644 --- a/src/modules/user/dto/user.dto.ts +++ b/src/modules/user/dto/user.dto.ts @@ -12,7 +12,7 @@ import { Matches, MaxLength, MinLength, - ValidateIf, + ValidateIf } from 'class-validator'; import { isEmpty } from 'lodash'; @@ -34,7 +34,7 @@ export class UserDto { @ApiProperty({ description: '登录密码', example: 'a123456' }) @IsOptional() @Matches(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Za-z])\S*$/, { - message: '密码必须包含数字、字母,长度为6-16', + message: '密码必须包含数字、字母,长度为6-16' }) password: string; diff --git a/src/modules/user/user.controller.ts b/src/modules/user/user.controller.ts index d462edb..fca5e25 100644 --- a/src/modules/user/user.controller.ts +++ b/src/modules/user/user.controller.ts @@ -7,7 +7,7 @@ import { ParseArrayPipe, Post, Put, - Query, + Query } from '@nestjs/common'; import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'; @@ -31,7 +31,7 @@ export const permissions = definePermission('system:user', { DELETE: 'delete', PASSWORD_UPDATE: 'password:update', - PASSWORD_RESET: 'pass:reset', + PASSWORD_RESET: 'pass:reset' } as const); @ApiTags('System - 用户模块') @@ -78,7 +78,7 @@ export class UserController { @ApiParam({ name: 'id', type: String, - schema: { oneOf: [{ type: 'string' }, { type: 'number' }] }, + schema: { oneOf: [{ type: 'string' }, { type: 'number' }] } }) @Perm(permissions.DELETE) async delete( diff --git a/src/modules/user/user.entity.ts b/src/modules/user/user.entity.ts index 7cd2031..3df5839 100644 --- a/src/modules/user/user.entity.ts +++ b/src/modules/user/user.entity.ts @@ -7,7 +7,7 @@ import { ManyToMany, ManyToOne, OneToMany, - Relation, + Relation } from 'typeorm'; import { CommonEntity } from '~/common/entity/common.entity'; @@ -54,7 +54,7 @@ export class UserEntity extends CommonEntity { @JoinTable({ name: 'sys_user_roles', joinColumn: { name: 'user_id', referencedColumnName: 'id' }, - inverseJoinColumn: { name: 'role_id', referencedColumnName: 'id' }, + inverseJoinColumn: { name: 'role_id', referencedColumnName: 'id' } }) roles: Relation; @@ -63,7 +63,7 @@ export class UserEntity extends CommonEntity { dept: Relation; @OneToMany(() => AccessTokenEntity, accessToken => accessToken.user, { - cascade: true, + cascade: true }) accessTokens: Relation; } diff --git a/src/modules/user/user.module.ts b/src/modules/user/user.module.ts index 928c52b..621db3a 100644 --- a/src/modules/user/user.module.ts +++ b/src/modules/user/user.module.ts @@ -16,6 +16,6 @@ const providers = [UserService]; imports: [TypeOrmModule.forFeature([UserEntity]), RoleModule, MenuModule, ParamConfigModule], controllers: [UserController], providers: [...providers], - exports: [TypeOrmModule, ...providers], + exports: [TypeOrmModule, ...providers] }) export class UserModule {} diff --git a/src/modules/user/user.service.ts b/src/modules/user/user.service.ts index 36fa5d8..a3a2867 100644 --- a/src/modules/user/user.service.ts +++ b/src/modules/user/user.service.ts @@ -48,7 +48,7 @@ export class UserService { .createQueryBuilder('user') .where({ id, - status: UserStatus.Enabled, + status: UserStatus.Enabled }) .getOne(); } @@ -58,7 +58,7 @@ export class UserService { .createQueryBuilder('user') .where({ username, - status: UserStatus.Enabled, + status: UserStatus.Enabled }) .getOne(); } @@ -94,7 +94,7 @@ export class UserService { ...(info.email ? { email: info.email } : null), ...(info.phone ? { phone: info.phone } : null), ...(info.qq ? { qq: info.qq } : null), - ...(info.remark ? { remark: info.remark } : null), + ...(info.remark ? { remark: info.remark } : null) }; if (!info.avatar && info.qq) { @@ -137,7 +137,7 @@ export class UserService { */ async create({ username, password, roleIds, deptId, ...data }: UserDto): Promise { const exists = await this.userRepository.findOneBy({ - username, + username }); if (!isEmpty(exists)) throw new BusinessException(ErrorEnum.SYSTEM_USER_EXISTS); @@ -156,7 +156,7 @@ export class UserService { ...data, psalt: salt, roles: await this.roleRepository.findBy({ id: In(roleIds) }), - dept: await DeptEntity.findOneBy({ id: deptId }), + dept: await DeptEntity.findOneBy({ id: deptId }) }); const result = await manager.save(u); @@ -176,7 +176,7 @@ export class UserService { await manager.update(UserEntity, id, { ...data, - status, + status }); const user = await this.userRepository @@ -234,7 +234,7 @@ export class UserService { */ async findRootUserId(): Promise { const user = await this.userRepository.findOneBy({ - roles: { id: ROOT_ROLE_ID }, + roles: { id: ROOT_ROLE_ID } }); return user.id; } @@ -249,7 +249,7 @@ export class UserService { nickname, deptId, email, - status, + status }: UserQueryDto): Promise> { const queryBuilder = this.userRepository .createQueryBuilder('user') @@ -260,14 +260,14 @@ export class UserService { ...(username ? { username: Like(`%${username}%`) } : null), ...(nickname ? { nickname: Like(`%${nickname}%`) } : null), ...(email ? { email: Like(`%${email}%`) } : null), - ...(isNumber(status) ? { status } : null), + ...(isNumber(status) ? { status } : null) }); if (deptId) queryBuilder.andWhere('dept.id = :deptId', { deptId }); return paginate(queryBuilder, { page, - pageSize, + pageSize }); } @@ -323,7 +323,7 @@ export class UserService { */ async register({ username, ...data }: RegisterDto): Promise { const exists = await this.userRepository.findOneBy({ - username, + username }); if (!isEmpty(exists)) throw new BusinessException(ErrorEnum.SYSTEM_USER_EXISTS); @@ -336,7 +336,7 @@ export class UserService { username, password, status: 1, - psalt: salt, + psalt: salt }); const user = await manager.save(u); diff --git a/src/setup-swagger.ts b/src/setup-swagger.ts index d80d52e..8b49b32 100644 --- a/src/setup-swagger.ts +++ b/src/setup-swagger.ts @@ -27,12 +27,12 @@ export function setupSwagger( description: 'Auth', type: 'apiKey', in: 'header', - name: 'Authorization', + name: 'Authorization' }); const document = SwaggerModule.createDocument(app, documentBuilder.build(), { ignoreGlobalPrefix: false, - extraModels: [CommonEntity, ResOp, Pagination, TreeResult], + extraModels: [CommonEntity, ResOp, Pagination, TreeResult] }); SwaggerModule.setup(path, app, document); diff --git a/src/shared/database/constraints/entity-exist.constraint.ts b/src/shared/database/constraints/entity-exist.constraint.ts index 3f482b7..37702b1 100644 --- a/src/shared/database/constraints/entity-exist.constraint.ts +++ b/src/shared/database/constraints/entity-exist.constraint.ts @@ -4,7 +4,7 @@ import { ValidationOptions, ValidatorConstraint, ValidatorConstraintInterface, - registerDecorator, + registerDecorator } from 'class-validator'; import { DataSource, ObjectType, Repository } from 'typeorm'; @@ -74,7 +74,7 @@ function IsEntityExist( propertyName, options: validationOptions, constraints: [condition], - validator: EntityExistConstraint, + validator: EntityExistConstraint }); }; } diff --git a/src/shared/database/constraints/unique.constraint.ts b/src/shared/database/constraints/unique.constraint.ts index 2f3450b..39d4fec 100644 --- a/src/shared/database/constraints/unique.constraint.ts +++ b/src/shared/database/constraints/unique.constraint.ts @@ -4,7 +4,7 @@ import { ValidationOptions, ValidatorConstraint, ValidatorConstraintInterface, - registerDecorator, + registerDecorator } from 'class-validator'; import { isNil, merge } from 'lodash'; import { DataSource, ObjectType } from 'typeorm'; @@ -26,13 +26,13 @@ export class UniqueConstraint implements ValidatorConstraintInterface { async validate(value: any, args: ValidationArguments) { // 获取要验证的模型和字段 const config: Omit = { - field: args.property, + field: args.property }; const condition = ('entity' in args.constraints[0] ? merge(config, args.constraints[0]) : { ...config, - entity: args.constraints[0], + entity: args.constraints[0] }) as unknown as Required; if (!condition.entity) return false; try { @@ -40,7 +40,7 @@ export class UniqueConstraint implements ValidatorConstraintInterface { const repo = this.dataSource.getRepository(condition.entity); return isNil( await repo.findOne({ - where: { [condition.field]: value }, + where: { [condition.field]: value } }) ); } catch (err) { @@ -82,7 +82,7 @@ function IsUnique(params: ObjectType | Condition, validationOptions?: Valid propertyName, options: validationOptions, constraints: [params], - validator: UniqueConstraint, + validator: UniqueConstraint }); }; } diff --git a/src/shared/database/database.module.ts b/src/shared/database/database.module.ts index 528df0f..eeee523 100644 --- a/src/shared/database/database.module.ts +++ b/src/shared/database/database.module.ts @@ -33,7 +33,7 @@ const providers = [EntityExistConstraint, UniqueConstraint]; ...configService.get('database'), autoLoadEntities: true, logging: loggerOptions, - logger: new TypeORMLogger(loggerOptions), + logger: new TypeORMLogger(loggerOptions) }; }, // dataSource receives the configured DataSourceOptions @@ -41,10 +41,10 @@ const providers = [EntityExistConstraint, UniqueConstraint]; dataSourceFactory: async options => { const dataSource = await new DataSource(options).initialize(); return dataSource; - }, - }), + } + }) ], providers, - exports: providers, + exports: providers }) export class DatabaseModule {} diff --git a/src/shared/helper/cron.service.ts b/src/shared/helper/cron.service.ts index 09fb895..c53b4ea 100644 --- a/src/shared/helper/cron.service.ts +++ b/src/shared/helper/cron.service.ts @@ -20,8 +20,8 @@ export class CronService { const expiredTokens = await AccessTokenEntity.find({ where: { - expired_at: LessThan(new Date()), - }, + expired_at: LessThan(new Date()) + } }); let deleteCount = 0; diff --git a/src/shared/helper/helper.module.ts b/src/shared/helper/helper.module.ts index dc8e166..7ce4fc5 100644 --- a/src/shared/helper/helper.module.ts +++ b/src/shared/helper/helper.module.ts @@ -9,6 +9,6 @@ const providers: Provider[] = [CronService, QQService]; @Module({ imports: [], providers, - exports: providers, + exports: providers }) export class HelperModule {} diff --git a/src/shared/logger/logger.module.ts b/src/shared/logger/logger.module.ts index 0cd7a70..385b778 100644 --- a/src/shared/logger/logger.module.ts +++ b/src/shared/logger/logger.module.ts @@ -9,7 +9,7 @@ export class LoggerModule { global: true, module: LoggerModule, providers: [LoggerService], - exports: [LoggerService], + exports: [LoggerService] }; } } diff --git a/src/shared/logger/logger.service.ts b/src/shared/logger/logger.service.ts index ce477cd..bb9fd37 100644 --- a/src/shared/logger/logger.service.ts +++ b/src/shared/logger/logger.service.ts @@ -14,7 +14,7 @@ export enum LogLevel { WARN = 'warn', INFO = 'info', DEBUG = 'debug', - VERBOSE = 'verbose', + VERBOSE = 'verbose' } @Injectable() @@ -49,7 +49,7 @@ export class LoggerService extends ConsoleLogger { datePattern: 'YYYY-MM-DD', maxFiles: this.maxFiles, format: format.combine(format.timestamp(), format.json()), - auditFile: 'logs/.audit/app.json', + auditFile: 'logs/.audit/app.json' }), new transports.DailyRotateFile({ level: LogLevel.ERROR, @@ -57,9 +57,9 @@ export class LoggerService extends ConsoleLogger { datePattern: 'YYYY-MM-DD', maxFiles: this.maxFiles, format: format.combine(format.timestamp(), format.json()), - auditFile: 'logs/.audit/app-error.json', - }), - ], + auditFile: 'logs/.audit/app-error.json' + }) + ] }); // if (isDev) { @@ -105,7 +105,7 @@ export class LoggerService extends ConsoleLogger { const hasStack = !!context; this.winstonLogger.log(LogLevel.ERROR, { context: hasStack ? context : stack, - message: hasStack ? new Error(message) : message, + message: hasStack ? new Error(message) : message }); } } diff --git a/src/shared/mailer/mailer.module.ts b/src/shared/mailer/mailer.module.ts index 24d1e1f..25ba1d0 100644 --- a/src/shared/mailer/mailer.module.ts +++ b/src/shared/mailer/mailer.module.ts @@ -20,21 +20,21 @@ const providers: Provider[] = [MailerService]; defaults: { from: { name: configService.get('app').name, - address: configService.get('mailer').auth.user, - }, + address: configService.get('mailer').auth.user + } }, template: { dir: join(__dirname, '..', '..', '/assets/templates'), adapter: new HandlebarsAdapter(), options: { - strict: true, - }, - }, + strict: true + } + } }), - inject: [ConfigService], - }), + inject: [ConfigService] + }) ], providers, - exports: providers, + exports: providers }) export class MailerModule {} diff --git a/src/shared/mailer/mailer.service.ts b/src/shared/mailer/mailer.service.ts index 2b5fcf3..cd6b90c 100644 --- a/src/shared/mailer/mailer.service.ts +++ b/src/shared/mailer/mailer.service.ts @@ -79,13 +79,13 @@ export class MailerService { return this.mailerService.sendMail({ to, subject, - text: content, + text: content }); } else { return this.mailerService.sendMail({ to, subject, - html: content, + html: content }); } } @@ -99,8 +99,8 @@ export class MailerService { subject, template: './verification-code-zh', context: { - code, - }, + code + } }); } catch (error) { console.log(error); @@ -109,7 +109,7 @@ export class MailerService { return { to, - code, + code }; } diff --git a/src/shared/redis/cache.service.ts b/src/shared/redis/cache.service.ts index 6edd80e..d8ccb54 100644 --- a/src/shared/redis/cache.service.ts +++ b/src/shared/redis/cache.service.ts @@ -46,7 +46,7 @@ export class CacheService { if (this._emitter) return this._emitter; this._emitter = new Emitter(this.redisClient, { - key: RedisIoAdapterKey, + key: RedisIoAdapterKey }); return this._emitter; diff --git a/src/shared/redis/redis-subpub.ts b/src/shared/redis/redis-subpub.ts index 4f4934c..3a8d07f 100644 --- a/src/shared/redis/redis-subpub.ts +++ b/src/shared/redis/redis-subpub.ts @@ -15,7 +15,7 @@ export class RedisSubPub { public init() { const redisOptions: RedisOptions = { host: this.redisConfig.host, - port: this.redisConfig.port, + port: this.redisConfig.port }; if (this.redisConfig.password) redisOptions.password = this.redisConfig.password; diff --git a/src/shared/redis/redis.module.ts b/src/shared/redis/redis.module.ts index b227914..8fa4c90 100644 --- a/src/shared/redis/redis.module.ts +++ b/src/shared/redis/redis.module.ts @@ -21,9 +21,9 @@ const providers: Provider[] = [ const redisOptions: RedisOptions = configService.get('redis'); return new RedisSubPub(redisOptions); }, - inject: [ConfigService], + inject: [ConfigService] }, - RedisPubSubService, + RedisPubSubService ]; @Global() @@ -39,22 +39,22 @@ const providers: Provider[] = [ isGlobal: true, store: redisStore, isCacheableValue: () => true, - ...redisOptions, + ...redisOptions }; }, - inject: [ConfigService], + inject: [ConfigService] }), // redis NestRedisModule.forRootAsync({ imports: [ConfigModule], useFactory: (configService: ConfigService) => ({ readyLog: true, - config: configService.get('redis'), + config: configService.get('redis') }), - inject: [ConfigService], - }), + inject: [ConfigService] + }) ], providers, - exports: [...providers, CacheModule], + exports: [...providers, CacheModule] }) export class RedisModule {} diff --git a/src/shared/shared.module.ts b/src/shared/shared.module.ts index f0f222f..5eaf868 100644 --- a/src/shared/shared.module.ts +++ b/src/shared/shared.module.ts @@ -25,8 +25,8 @@ import { RedisModule } from './redis/redis.module'; ThrottlerModule.forRoot([ { limit: 3, - ttl: 60000, - }, + ttl: 60000 + } ]), EventEmitterModule.forRoot({ wildcard: true, @@ -35,15 +35,15 @@ import { RedisModule } from './redis/redis.module'; removeListener: false, maxListeners: 20, verboseMemoryLeak: isDev, - ignoreErrors: false, + ignoreErrors: false }), // redis RedisModule, // mailer MailerModule, // helper - HelperModule, + HelperModule ], - exports: [HttpModule, MailerModule, RedisModule, HelperModule], + exports: [HttpModule, MailerModule, RedisModule, HelperModule] }) export class SharedModule {} diff --git a/src/socket/base.gateway.ts b/src/socket/base.gateway.ts index 8ce4e34..920e573 100644 --- a/src/socket/base.gateway.ts +++ b/src/socket/base.gateway.ts @@ -7,7 +7,7 @@ export abstract class BaseGateway { return { type, data: message, - code, + code }; } diff --git a/src/socket/business-event.constant.ts b/src/socket/business-event.constant.ts index 1864d6c..5d0f133 100644 --- a/src/socket/business-event.constant.ts +++ b/src/socket/business-event.constant.ts @@ -7,5 +7,5 @@ export enum BusinessEvents { // 用户上线事件 USER_ONLINE = 'USER_ONLINE', USER_OFFLINE = 'USER_OFFLINE', - USER_KICK = 'USER_KICK', + USER_KICK = 'USER_KICK' } diff --git a/src/socket/events/admin.gateway.ts b/src/socket/events/admin.gateway.ts index 2b8c810..26007b9 100644 --- a/src/socket/events/admin.gateway.ts +++ b/src/socket/events/admin.gateway.ts @@ -4,7 +4,7 @@ import { OnGatewayConnection, OnGatewayDisconnect, WebSocketGateway, - WebSocketServer, + WebSocketServer } from '@nestjs/websockets'; import { Server } from 'socket.io'; diff --git a/src/socket/events/web.gateway.ts b/src/socket/events/web.gateway.ts index 7d46d32..c1250ae 100644 --- a/src/socket/events/web.gateway.ts +++ b/src/socket/events/web.gateway.ts @@ -4,7 +4,7 @@ import { OnGatewayConnection, OnGatewayDisconnect, WebSocketGateway, - WebSocketServer, + WebSocketServer } from '@nestjs/websockets'; import { Server } from 'socket.io'; diff --git a/src/socket/socket.module.ts b/src/socket/socket.module.ts index 0affa35..adadb4b 100644 --- a/src/socket/socket.module.ts +++ b/src/socket/socket.module.ts @@ -11,6 +11,6 @@ const providers: Provider[] = [AdminEventsGateway, WebEventsGateway]; @Module({ imports: [forwardRef(() => SystemModule), AuthModule], providers, - exports: [...providers], + exports: [...providers] }) export class SocketModule {} diff --git a/src/utils/captcha.util.ts b/src/utils/captcha.util.ts index 65ccf3d..443b540 100644 --- a/src/utils/captcha.util.ts +++ b/src/utils/captcha.util.ts @@ -9,7 +9,7 @@ export function createCaptcha() { background: '#eee', fontSize: 50, width: 110, - height: 38, + height: 38 }); } diff --git a/src/utils/crypto.util.ts b/src/utils/crypto.util.ts index 58dd902..1c072dd 100644 --- a/src/utils/crypto.util.ts +++ b/src/utils/crypto.util.ts @@ -8,7 +8,7 @@ export function aesEncrypt(data) { const enc = CryptoJS.AES.encrypt(data, key, { iv, mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7, + padding: CryptoJS.pad.Pkcs7 }); return enc.toString(); } @@ -18,7 +18,7 @@ export function aesDecrypt(data) { const dec = CryptoJS.AES.decrypt(data, key, { iv, mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7, + padding: CryptoJS.pad.Pkcs7 }); return dec.toString(CryptoJS.enc.Utf8); } diff --git a/src/utils/file.util.ts b/src/utils/file.util.ts index 35a63b6..b7a41c5 100644 --- a/src/utils/file.util.ts +++ b/src/utils/file.util.ts @@ -10,7 +10,7 @@ enum Type { TXT = '文档', MUSIC = '音乐', VIDEO = '视频', - OTHER = '其他', + OTHER = '其他' } export function getFileType(extName: string) { diff --git a/src/utils/ip.util.ts b/src/utils/ip.util.ts index 60ce375..b9079ca 100644 --- a/src/utils/ip.util.ts +++ b/src/utils/ip.util.ts @@ -46,7 +46,7 @@ export async function getIpAddress(ip: string) { if (isLAN(ip)) return '内网IP'; try { let { data } = await axios.get(`https://whois.pconline.com.cn/ipJson.jsp?ip=${ip}&json=true`, { - responseType: 'arraybuffer', + responseType: 'arraybuffer' }); data = new TextDecoder('gbk').decode(data); data = JSON.parse(data); diff --git a/src/utils/list2tree.util.ts b/src/utils/list2tree.util.ts index d1999a3..10541cb 100644 --- a/src/utils/list2tree.util.ts +++ b/src/utils/list2tree.util.ts @@ -19,7 +19,7 @@ export function list2Tree( const children = list2Tree(items, item.id); return { ...item, - ...(children.length ? { children } : null), + ...(children.length ? { children } : null) }; }); } diff --git a/src/utils/permission.util.ts b/src/utils/permission.util.ts index 6769122..a35d086 100644 --- a/src/utils/permission.util.ts +++ b/src/utils/permission.util.ts @@ -15,7 +15,7 @@ function createRoute(menu: MenuEntity, _isRoot) { show: menu.show, activeMenu: menu.activeMenu, status: menu.status, - keepAlive: menu.keepAlive, + keepAlive: menu.keepAlive }; if (isExternal(menu.path)) { @@ -24,7 +24,7 @@ function createRoute(menu: MenuEntity, _isRoot) { path: menu.path, // component: 'IFrame', name: menu.name, - meta: { ...commonMeta }, + meta: { ...commonMeta } }; } @@ -35,7 +35,7 @@ function createRoute(menu: MenuEntity, _isRoot) { path: menu.path, component: menu.component, name: menu.name, - meta: { ...commonMeta }, + meta: { ...commonMeta } }; } @@ -45,8 +45,8 @@ function createRoute(menu: MenuEntity, _isRoot) { name: menu.name, component: menu.component, meta: { - ...commonMeta, - }, + ...commonMeta + } }; } diff --git a/src/utils/schedule.util.ts b/src/utils/schedule.util.ts index 052fc80..66c468a 100644 --- a/src/utils/schedule.util.ts +++ b/src/utils/schedule.util.ts @@ -88,7 +88,7 @@ export function createNotifyManager() { batchCalls, schedule, setNotifyFunction, - setBatchNotifyFunction, + setBatchNotifyFunction } as const; }