main
expressgy 4 months ago
parent 0e6ff7e292
commit f9102f8761
  1. 1680
      docs/pacAuth_database_0.2.ndm2
  2. 2
      package.json
  3. 13
      pnpm-lock.yaml
  4. 4
      src/application/app.module.ts
  5. 40
      src/application/core-dict/core-dict.service.ts
  6. 17
      src/application/core-dict/dto/create-core-dict.dto.ts
  7. 5
      src/application/core-dict/dto/get-core-dict.dto.ts
  8. 53
      src/application/core-env/core-env.service.ts
  9. 5
      src/application/core-env/dto/get-core-env.dto.ts
  10. 54
      src/application/core-menu/core-menu.controller.ts
  11. 9
      src/application/core-menu/core-menu.module.ts
  12. 312
      src/application/core-menu/core-menu.service.ts
  13. 185
      src/application/core-menu/dto/create-core-menu.dto.ts
  14. 136
      src/application/core-menu/dto/get-core-menu.dto.ts
  15. 25
      src/application/core-menu/dto/update-core-menu.dto.ts
  16. 1
      src/application/core-menu/entities/core-menu.entity.ts
  17. 7
      src/application/core-service/core-service.service.ts
  18. 25
      src/common/decorator/int/int.descrator.ts
  19. 2
      src/config/configuration.ts
  20. 7
      src/entities/schema.ts
  21. 2
      src/main.ts
  22. 2
      src/service/logger/logger.service.ts
  23. 3
      src/service/snowflake/snowflake.service.ts
  24. 2
      src/utils/boolean.enum.ts
  25. 1
      src/utils/customDrizzleRowWithRecursive.ts

File diff suppressed because it is too large Load Diff

@ -43,7 +43,7 @@
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.14.1", "class-validator": "^0.14.1",
"colors": "^1.4.0", "colors": "^1.4.0",
"drizzle-orm": "^0.31.0", "drizzle-orm": "^0.31.2",
"fastify": "^4.27.0", "fastify": "^4.27.0",
"mysql2": "^3.10.0", "mysql2": "^3.10.0",
"nodemailer": "^6.9.13", "nodemailer": "^6.9.13",

@ -42,8 +42,8 @@ importers:
specifier: ^1.4.0 specifier: ^1.4.0
version: 1.4.0 version: 1.4.0
drizzle-orm: drizzle-orm:
specifier: ^0.31.0 specifier: ^0.31.2
version: 0.31.1(mysql2@3.10.0) version: 0.31.2(mysql2@3.10.0)
fastify: fastify:
specifier: ^4.27.0 specifier: ^4.27.0
version: 4.27.0 version: 4.27.0
@ -1712,8 +1712,8 @@ packages:
resolution: {integrity: sha512-dxluXlhT1N9bpj2eZR3N/z3u4H0PbbrBYgyouIobFF25tOt2Buy1abx26Jii96qcYV0JgxjhnuV+FBcgR0Xa0w==} resolution: {integrity: sha512-dxluXlhT1N9bpj2eZR3N/z3u4H0PbbrBYgyouIobFF25tOt2Buy1abx26Jii96qcYV0JgxjhnuV+FBcgR0Xa0w==}
hasBin: true hasBin: true
drizzle-orm@0.31.1: drizzle-orm@0.31.2:
resolution: {integrity: sha512-hTbYne2XX3y6sV7WSxcPH6/vNSiQSUG9VZsFI27jBMCN0OT3Ok7ao3pIT5OMAqWkzJCRFgGjAaUeTAZWPgOKag==} resolution: {integrity: sha512-QnenevbnnAzmbNzQwbhklvIYrDE8YER8K7kSrAWQSV1YvFCdSQPzj+jzqRdTSsV2cDqSpQ0NXGyL1G9I43LDLg==}
peerDependencies: peerDependencies:
'@aws-sdk/client-rds-data': '>=3' '@aws-sdk/client-rds-data': '>=3'
'@cloudflare/workers-types': '>=3' '@cloudflare/workers-types': '>=3'
@ -1723,6 +1723,7 @@ packages:
'@op-engineering/op-sqlite': '>=2' '@op-engineering/op-sqlite': '>=2'
'@opentelemetry/api': ^1.4.1 '@opentelemetry/api': ^1.4.1
'@planetscale/database': '>=1' '@planetscale/database': '>=1'
'@tidbcloud/serverless': '*'
'@types/better-sqlite3': '*' '@types/better-sqlite3': '*'
'@types/pg': '*' '@types/pg': '*'
'@types/react': '>=18' '@types/react': '>=18'
@ -1757,6 +1758,8 @@ packages:
optional: true optional: true
'@planetscale/database': '@planetscale/database':
optional: true optional: true
'@tidbcloud/serverless':
optional: true
'@types/better-sqlite3': '@types/better-sqlite3':
optional: true optional: true
'@types/pg': '@types/pg':
@ -5404,7 +5407,7 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
drizzle-orm@0.31.1(mysql2@3.10.0): drizzle-orm@0.31.2(mysql2@3.10.0):
optionalDependencies: optionalDependencies:
mysql2: 3.10.0 mysql2: 3.10.0

@ -13,6 +13,7 @@ import { HttpExceptFilter } from '@common/http-except/http-except.filter';
import { CoreDictModule } from './core-dict/core-dict.module'; import { CoreDictModule } from './core-dict/core-dict.module';
import { GlobalModule } from '@app/global.module'; import { GlobalModule } from '@app/global.module';
import { CoreEnvModule } from './core-env/core-env.module'; import { CoreEnvModule } from './core-env/core-env.module';
import { CoreMenuModule } from './core-menu/core-menu.module';
@Module({ @Module({
imports: [ imports: [
@ -20,11 +21,12 @@ import { CoreEnvModule } from './core-env/core-env.module';
isGlobal: true, isGlobal: true,
load: [configuration], load: [configuration],
}), }),
GlobalModule,
TestModule, TestModule,
CoreServiceModule, CoreServiceModule,
CoreDictModule, CoreDictModule,
GlobalModule,
CoreEnvModule, CoreEnvModule,
CoreMenuModule,
], ],
controllers: [AppController], controllers: [AppController],
providers: [ providers: [

@ -36,6 +36,7 @@ export class CoreDictService {
createName: pacAuthUser.nickname, createName: pacAuthUser.nickname,
createtime: pacCoreDict.createtime, createtime: pacCoreDict.createtime,
updateby: pacCoreDict.updateby, updateby: pacCoreDict.updateby,
updateName: pacAuthUser.nickname,
updatetime: pacCoreDict.updatetime, updatetime: pacCoreDict.updatetime,
}; };
@ -248,55 +249,48 @@ export class CoreDictService {
// DB 查字典项的查询函数QueryBuilder,作用于列表和分页查询 // DB 查字典项的查询函数QueryBuilder,作用于列表和分页查询
private getDict(data, selectData = undefined) { private getDict(data, selectData = undefined) {
this.logger.info(JSON.stringify(data, null, 2));
// ! 定义基础查询函数 // ! 定义基础查询函数
// 启用动态查询模式 $dynamic // 启用动态查询模式 $dynamic
let query = this.mysqlService.db const query = this.mysqlService.db
.select(selectData) .select(selectData)
.from(pacCoreDict) .from(pacCoreDict)
.where(isNull(pacCoreDict.deleteby))
.orderBy( .orderBy(
isTrueEnum(data.isAsc) ? asc(pacCoreDict.orderNum) : desc(pacCoreDict.orderNum), isTrueEnum(data.isAsc) ? asc(pacCoreDict.orderNum) : desc(pacCoreDict.orderNum),
isTrueEnum(data.isAsc) ? asc(pacCoreDict.dictId) : desc(pacCoreDict.dictId), isTrueEnum(data.isAsc) ? asc(pacCoreDict.dictId) : desc(pacCoreDict.dictId),
) )
.$dynamic(); .$dynamic();
// 查询条件集合
const wl = [];
// ? 未删除
wl.push(isNull(pacCoreDict.deleteby));
// ? 模糊查询 // ? 模糊查询
if (isExistKey(data, 'dictInfo')) { wl.push(
query = query.where(
or( or(
like(pacCoreDict.dictKey, likeQuery(data.dictInfo)), like(pacCoreDict.dictKey, likeQuery(data.dictInfo)),
like(pacCoreDict.dictName, likeQuery(data.dictInfo)), like(pacCoreDict.dictName, likeQuery(data.dictInfo)),
like(pacCoreDict.dictDesc, likeQuery(data.dictInfo)), like(pacCoreDict.dictDesc, likeQuery(data.dictInfo)),
), ).if(isExistKey(data, 'dictInfo')),
); );
}
// ? 是否查pac的数据 // ? 是否查pac的数据
if (isExistKey(data, 'ownOfPac') && isTrueEnum(data['ownOfPac'])) { wl.push(eq(pacCoreDict.ownOfPac, isTrueEnum(data['ownOfPac']) ? 0 : 1).if(isExistKey(data, 'ownOfPac') && isTrueEnum(data['ownOfPac'])));
query = query.where(eq(pacCoreDict.ownOfPac, isTrueEnum(data['ownOfPac']) ? 0 : 1));
}
// ? 按照层级查 // ? 按照层级查
if (isExistKey(data, 'hierarchy')) { wl.push(eq(pacCoreDict.pid, data.hierarchy).if(isExistKey(data, 'hierarchy')));
query = query.where(eq(pacCoreDict.pid, data.hierarchy));
}
// ? 是否存在目标service // ? 是否存在目标service
if (isExistKey(data, 'serviceOf')) { wl.push(eq(pacCoreDict.serviceOf, data.serviceOf).if(isExistKey(data, 'serviceOf')));
query = query.where(eq(pacCoreDict.serviceOf, data.serviceOf));
}
// ? 是否查字典类型 // ? 是否查字典类型
if (isExistKey(data, 'dictType')) { wl.push(eq(pacCoreDict.dictType, data.dictType).if(isExistKey(data, 'dictType')));
query = query.where(eq(pacCoreDict.dictType, data.dictType));
}
// ? 是否查字典状态 // ? 是否查字典状态
if (isExistKey(data, 'status')) { wl.push(eq(pacCoreDict.status, data.status).if(isExistKey(data, 'status')));
query = query.where(eq(pacCoreDict.status, data.status));
} query.where(and(...wl));
return query; return query;
} }

@ -1,25 +1,14 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { import { IsBoolean, IsEnum, IsInt, IsOptional, IsString, Length, Max, Min } from 'class-validator';
IsBoolean,
IsEnum,
IsInt,
IsOptional,
IsString,
Length,
Max,
Min
} from "class-validator";
import Trim from '@common/decorator/trim/trim.decorator'; import Trim from '@common/decorator/trim/trim.decorator';
import { import { BooleanEnum } from '@utils/boolean.enum';
BooleanEnum
} from "@utils/boolean.enum";
export class CreateCoreDictDto { export class CreateCoreDictDto {
@ApiProperty({ @ApiProperty({
description: '字典父ID', description: '字典父ID',
type: String, type: String,
example: '0', example: '0',
required: true, required: false,
minLength: 1, minLength: 1,
maxLength: 32, maxLength: 32,
}) })

@ -16,6 +16,8 @@ import { ApiProperty } from '@nestjs/swagger';
import Trim from '@common/decorator/trim/trim.decorator'; import Trim from '@common/decorator/trim/trim.decorator';
import { IsEnum, IsInt, IsOptional, IsString, Length, Max, Min } from 'class-validator'; import { IsEnum, IsInt, IsOptional, IsString, Length, Max, Min } from 'class-validator';
import { BooleanEnum } from '@utils/boolean.enum'; import { BooleanEnum } from '@utils/boolean.enum';
import {Type} from "class-transformer";
import Int from "@common/decorator/int/int.descrator";
export class GetPacCoreDictAllDto extends GetDto { export class GetPacCoreDictAllDto extends GetDto {
@ApiProperty({ @ApiProperty({
@ -78,6 +80,7 @@ export class GetPacCoreDictAllDto extends GetDto {
maximum: 100, maximum: 100,
}) })
@Trim() @Trim()
@Int()
@IsInt({ @IsInt({
message: '字典状态必须是整数!', message: '字典状态必须是整数!',
}) })
@ -88,7 +91,7 @@ export class GetPacCoreDictAllDto extends GetDto {
message: '字典状态不能超过100', message: '字典状态不能超过100',
}) })
@IsOptional() @IsOptional()
readonly status?: number; readonly status?: string;
@ApiProperty({ @ApiProperty({
description: '字典层级id', description: '字典层级id',

@ -14,8 +14,6 @@ import { likeQuery } from '@utils/likeQuery';
import { QueryBuilder } from 'drizzle-orm/mysql-core'; import { QueryBuilder } from 'drizzle-orm/mysql-core';
import { customDrizzleRowWithRecursive } from '@utils/customDrizzleRowWithRecursive'; import { customDrizzleRowWithRecursive } from '@utils/customDrizzleRowWithRecursive';
import { PacInfoType } from '@utils/myType'; import { PacInfoType } from '@utils/myType';
import { PacCoreDictIdDto } from '@app/core-dict/dto/get-core-dict.dto';
import { UpdateCoreDictDto } from '@app/core-dict/dto/update-core-dict.dto';
@Injectable() @Injectable()
export class CoreEnvService { export class CoreEnvService {
@ -205,7 +203,7 @@ export class CoreEnvService {
return '删除目标环境变量成功'; return '删除目标环境变量成功';
} else { } else {
// ! 不存在目标环境变量,直接返回 // ! 不存在目标环境变量,直接返回
return '删除目标环境变量成功'; throw new HttpException('未找到目标环境变量!', HttpStatus.BAD_REQUEST);
} }
} }
@ -258,16 +256,24 @@ export class CoreEnvService {
// ! 定义基础查询函数 // ! 定义基础查询函数
// 启用动态查询模式 $dynamic // 启用动态查询模式 $dynamic
let query = this.mysqlService.db const query = this.mysqlService.db
.select(selectData) .select(selectData)
.from(pacCoreEnv) .from(pacCoreEnv)
.where(isNull(pacCoreEnv.deleteby))
.leftJoin(pacCoreDict, and(eq(pacCoreDict.dictId, pacCoreEnv.envVal), eq(pacCoreEnv.valIsDict, 1))) .leftJoin(pacCoreDict, and(eq(pacCoreDict.dictId, pacCoreEnv.envVal), eq(pacCoreEnv.valIsDict, 1)))
.orderBy( .orderBy(
isTrueEnum(data.isAsc) ? asc(pacCoreEnv.orderNum) : desc(pacCoreEnv.orderNum), isTrueEnum(data.isAsc) ? asc(pacCoreEnv.orderNum) : desc(pacCoreEnv.orderNum),
isTrueEnum(data.isAsc) ? asc(pacCoreEnv.envId) : desc(pacCoreEnv.envId), isTrueEnum(data.isAsc) ? asc(pacCoreEnv.envId) : desc(pacCoreEnv.envId),
) )
.where( .$dynamic();
const wl = [];
// ? 未删除
wl.push(isNull(pacCoreEnv.deleteby));
// ? 模糊查询
wl.push(
or( or(
like(pacCoreEnv.envKey, likeQuery(data.envInfo)), like(pacCoreEnv.envKey, likeQuery(data.envInfo)),
like(pacCoreEnv.envName, likeQuery(data.envInfo)), like(pacCoreEnv.envName, likeQuery(data.envInfo)),
@ -276,46 +282,25 @@ export class CoreEnvService {
like(pacCoreDict.dictKey, likeQuery(data.envInfo)), like(pacCoreDict.dictKey, likeQuery(data.envInfo)),
like(pacCoreDict.dictName, likeQuery(data.envInfo)), like(pacCoreDict.dictName, likeQuery(data.envInfo)),
).if(isExistKey(data, 'envInfo')), ).if(isExistKey(data, 'envInfo')),
) );
.$dynamic();
// ? 模糊查询
// if (isExistKey(data, 'envInfo')) {
// query = query.where(
// or(
// like(pacCoreEnv.envKey, likeQuery(data.envInfo)),
// like(pacCoreEnv.envName, likeQuery(data.envInfo)),
// like(pacCoreEnv.envDesc, likeQuery(data.envInfo)),
// like(pacCoreEnv.envVal, likeQuery(data.envInfo)),
// like(pacCoreDict.dictKey, likeQuery(data.envInfo)),
// like(pacCoreDict.dictName, likeQuery(data.envInfo)),
// ),
// );
// }
// ? 来源于字典 // ? 来源于字典
// if (isTrueEnum(data.valIsDict)) { // if (isTrueEnum(data.valIsDict)) {
// } // }
// ? 是否查pac的数据 // ? 是否查pac的数据
if (isExistKey(data, 'ownOfPac') && isTrueEnum(data['ownOfPac'])) { wl.push(eq(pacCoreEnv.ownOfPac, isTrueEnum(data['ownOfPac']) ? 0 : 1).if(isExistKey(data, 'ownOfPac') && isTrueEnum(data['ownOfPac'])));
query = query.where(eq(pacCoreEnv.ownOfPac, isTrueEnum(data['ownOfPac']) ? 0 : 1));
}
// ? 按照层级查 // ? 按照层级查
if (isExistKey(data, 'hierarchy')) { wl.push(eq(pacCoreEnv.pid, data.hierarchy).if(isExistKey(data, 'hierarchy')));
query = query.where(eq(pacCoreEnv.pid, data.hierarchy));
}
// ? 是否存在目标service // ? 是否存在目标service
if (isExistKey(data, 'serviceOf')) { wl.push(eq(pacCoreEnv.serviceOf, data.serviceOf).if(isExistKey(data, 'serviceOf')));
query = query.where(eq(pacCoreEnv.serviceOf, data.serviceOf));
}
// ? 是否查环境变量状态 // ? 是否查环境变量状态
if (isExistKey(data, 'status')) { wl.push(eq(pacCoreEnv.status, data.status).if(isExistKey(data, 'status')));
query = query.where(eq(pacCoreEnv.status, data.status));
} query.where(and(...wl));
return query; return query;
} }

@ -17,6 +17,8 @@ import Trim from '@common/decorator/trim/trim.decorator';
import { IsEnum, IsInt, IsOptional, IsString, Length, Max, Min } from 'class-validator'; import { IsEnum, IsInt, IsOptional, IsString, Length, Max, Min } from 'class-validator';
import { BooleanEnum } from '@utils/boolean.enum'; import { BooleanEnum } from '@utils/boolean.enum';
import ChangeCase, { CaseType } from '@common/decorator/change-case/change-case.decorator'; import ChangeCase, { CaseType } from '@common/decorator/change-case/change-case.decorator';
import {Type} from "class-transformer";
import Int from "@common/decorator/int/int.descrator";
export class GetCoreEnvDTO extends GetDto { export class GetCoreEnvDTO extends GetDto {
@ApiProperty({ @ApiProperty({
@ -68,6 +70,7 @@ export class GetCoreEnvDTO extends GetDto {
maximum: 100, maximum: 100,
}) })
@Trim() @Trim()
@Int()
@IsInt({ @IsInt({
message: '环境变量状态必须是整数!', message: '环境变量状态必须是整数!',
}) })
@ -78,7 +81,7 @@ export class GetCoreEnvDTO extends GetDto {
message: '环境变量状态不能超过100', message: '环境变量状态不能超过100',
}) })
@IsOptional() @IsOptional()
readonly status?: number; readonly status?: string;
@ApiProperty({ @ApiProperty({
description: '环境变量层级id', description: '环境变量层级id',

@ -0,0 +1,54 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { CoreMenuService } from './core-menu.service';
import { CreateCoreMenuDto } from './dto/create-core-menu.dto';
import { UpdateCoreMenuDto } from './dto/update-core-menu.dto';
import { ApiOperation, ApiProduces, ApiTags } from '@nestjs/swagger';
import { PacInfo } from '@common/decorator/pac-info/pac-info.decorator';
import { PacInfoType } from '@utils/myType';
import { GetPacCoreMenuAllDto } from '@app/core-menu/dto/get-core-menu.dto';
@ApiTags('菜单服务')
@Controller('coremenu')
export class CoreMenuController {
constructor(private readonly coreMenuService: CoreMenuService) {}
@ApiOperation({
summary: '添加菜单',
description: '增加一个菜单/接口/菜单夹,可以是具体的项,也可以是一个层级',
})
@ApiProduces('application/json')
@Post()
create(@Body() createCoreMenuDto: CreateCoreMenuDto, @PacInfo() pacInfo: PacInfoType) {
return this.coreMenuService.create(createCoreMenuDto, pacInfo);
}
@ApiOperation({
summary: '查菜单',
description: '查询菜单分页或者列表',
})
@ApiProduces('application/json')
@Get()
findAll(@Query() getPacCoreMenuAllDto: GetPacCoreMenuAllDto, @PacInfo() pacInfo: PacInfoType) {
return this.coreMenuService.findAll(getPacCoreMenuAllDto, pacInfo);
}
@ApiOperation({
summary: '修改菜单内容',
description: '。',
})
@ApiProduces('application/json')
@Patch(':menuId')
update(@Param('menuId') id: string, @Body() updateCoreMenuDto: UpdateCoreMenuDto, @PacInfo() pacInfo: PacInfoType) {
return this.coreMenuService.update(id, updateCoreMenuDto, pacInfo);
}
@ApiOperation({
summary: '删除指定菜单项',
description: '删除指定菜单项,子项存在不允许删除',
})
@ApiProduces('application/json')
@Delete(':menuId')
remove(@Param('menuId') id: string, @PacInfo() pacInfo: PacInfoType) {
return this.coreMenuService.remove(id, pacInfo);
}
}

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { CoreMenuService } from './core-menu.service';
import { CoreMenuController } from './core-menu.controller';
@Module({
controllers: [CoreMenuController],
providers: [CoreMenuService],
})
export class CoreMenuModule {}

@ -0,0 +1,312 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { CreateCoreMenuDto } from './dto/create-core-menu.dto';
import { UpdateCoreMenuDto } from './dto/update-core-menu.dto';
import { LoggerService } from '@service/logger/logger.service';
import { MysqlService } from '@common/service/mysql/mysql.service';
import { RedisService } from '@common/service/redis/redis.service';
import { Snowflake } from '@service/snowflake/snowflake.service';
import { ConfigService } from '@nestjs/config';
import { PacInfoType } from '@utils/myType';
import { pacAuthUser, pacCoreDict, pacCoreMenu, pacCoreService } from '@entities/schema';
import { eq, sql, isNull, asc, desc, or, like, and } from 'drizzle-orm';
import { isExistKey, isTrueEnum } from '@utils/boolean.enum';
import { GetPacCoreMenuAllDto } from '@app/core-menu/dto/get-core-menu.dto';
import { likeQuery } from '@utils/likeQuery';
@Injectable()
export class CoreMenuService {
// 详细的菜单信息
private readonly menuMoreDataType = {
menuId: pacCoreMenu.menuId,
pid: pacCoreMenu.pid,
haveChildren: pacCoreMenu.haveChildren,
apiPath: pacCoreMenu.apiPath,
webPath: pacCoreMenu.webPath,
webComponentPath: pacCoreMenu.webComponentPath,
menuName: pacCoreMenu.menuName,
menuDesc: pacCoreMenu.menuDesc,
menuType: pacCoreMenu.menuType,
menuTypeKey: pacCoreDict.dictKey,
menuTypeName: pacCoreDict.dictName,
menuIcon: pacCoreMenu.menuIcon,
isFrame: pacCoreMenu.isFrame,
isVisible: pacCoreMenu.isVisible,
isActivate: pacCoreMenu.isActivate,
orderNum: pacCoreMenu.orderNum,
status: pacCoreMenu.status,
serviceOf: pacCoreMenu.serviceOf,
serviceName: pacCoreService.serviceName,
createby: pacCoreMenu.createby,
createName: pacAuthUser.nickname,
createtime: pacCoreMenu.createtime,
updateby: pacCoreMenu.updateby,
updateName: pacAuthUser.nickname,
updatetime: pacCoreMenu.updatetime,
};
// 菜单列表数据
private readonly menuListDataType = {
menuId: pacCoreMenu.menuId,
pid: pacCoreMenu.pid,
haveChildren: pacCoreMenu.haveChildren,
apiPath: pacCoreMenu.apiPath,
webPath: pacCoreMenu.webPath,
webComponentPath: pacCoreMenu.webComponentPath,
menuName: pacCoreMenu.menuName,
menuType: pacCoreMenu.menuType,
menuTypeKey: pacCoreDict.dictKey,
menuIcon: pacCoreMenu.menuIcon,
isFrame: pacCoreMenu.isFrame,
isVisible: pacCoreMenu.isVisible,
isActivate: pacCoreMenu.isActivate,
orderNum: pacCoreMenu.orderNum,
serviceOf: pacCoreMenu.serviceOf,
serviceName: pacCoreService.serviceName,
};
constructor(
private readonly logger: LoggerService,
private readonly mysqlService: MysqlService,
private readonly redisService: RedisService,
private readonly snowflake: Snowflake,
private readonly config: ConfigService,
) {}
/** Service
* NAME: create
* DESC: 创建菜单内容
* DATE: 2024-06-22 17:57:15 -
* */
public async create(createCoreMenuDto: CreateCoreMenuDto, pacInfo: PacInfoType) {
// ! 加目标锁,允许同名,所以就不加锁了
// ? 判断是不是pac,不是的话直接退出
if (this.config.get<number>('masterId') !== pacInfo.userId) {
throw new HttpException('没有权限添加菜单!', HttpStatus.UNAUTHORIZED);
}
// ! 执行写入
const newPacCoreMenu = await this.addMenuData(createCoreMenuDto, pacInfo);
// ? 判断是否存在pid,对pid的haveChildren进行变化
await this.haveChildrenSelfIncreasing(createCoreMenuDto.pid);
return newPacCoreMenu;
}
/** Service
* NAME: findAll
* DESC: 获取菜单列表/
* DATE: 2024-06-22 18:21:57 -
* */
public async findAll(getPacCoreMenuAllDto: GetPacCoreMenuAllDto, pacInfo: PacInfoType) {
// ? 是否查询列表
if (isExistKey(getPacCoreMenuAllDto, 'isList') && isTrueEnum(getPacCoreMenuAllDto['isList'])) {
// ! 返回列表数据
return await this.getMenuList(getPacCoreMenuAllDto, pacInfo);
} else {
// ! 返回分页数据
return await this.getMenuPage(getPacCoreMenuAllDto, pacInfo);
}
}
public update(id: string, updateCoreMenuDto: UpdateCoreMenuDto, pacInfo: PacInfoType) {
// ! 比较权限
if (this.config.get<number>('masterId') !== pacInfo.userId) {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
}
// ! 写入数据
}
public async remove(id: string, pacInfo: PacInfoType) {
// ! 比较权限
if (this.config.get<number>('masterId') !== pacInfo.userId) {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
}
// ! 查找菜单
const result = await this.getMore(id);
if (result.length == 0) {
throw new HttpException('未找到目标菜单!', HttpStatus.BAD_REQUEST);
}
// ! 执行删除
await this.deleteMenuItem(id, pacInfo);
// ! 更改发节点的子节点数
if (result[0].pid != 0) {
await this.haveChildrenSelfIncreasing(result[0].pid, false);
}
return '删除菜单成功';
}
// DB 增加菜单
async addMenuData(createCoreMenuDto: CreateCoreMenuDto, pacInfo: PacInfoType) {
// ! 生成雪花id,用于字典主键
const id = await this.snowflake.generate();
const newMenuData = {
menuId: id,
pid: createCoreMenuDto.pid,
apiPath: createCoreMenuDto.apiPath,
webPath: createCoreMenuDto.webPath,
webComponentPath: createCoreMenuDto.webComponentPath,
menuName: createCoreMenuDto.menuName,
menuDesc: createCoreMenuDto.menuDesc,
menuType: createCoreMenuDto.menuType,
menuIcon: createCoreMenuDto.menuIcon,
isFrame: isTrueEnum(createCoreMenuDto.isFrame) ? 1 : 0,
isVisible: isTrueEnum(createCoreMenuDto.isVisible) ? 0 : 1,
isActivate: isTrueEnum(createCoreMenuDto.isActivate) ? 0 : 1,
orderNum: createCoreMenuDto.orderNum,
serviceOf: createCoreMenuDto.serviceOf,
createby: pacInfo.userId,
createtime: sql`now()` as any,
};
return this.mysqlService.db.insert(pacCoreMenu).values(newMenuData);
}
// DB 更新父级子元素数量
private async haveChildrenSelfIncreasing(menuId: string, isAdd = true) {
return this.mysqlService.db
.update(pacCoreMenu)
.set({
haveChildren: isAdd ? sql`${pacCoreMenu.haveChildren} + 1` : sql`${pacCoreMenu.haveChildren} - 1`,
})
.where(eq(pacCoreMenu.menuId as any, menuId));
}
// 查菜单数据
private getMenuData(data: GetPacCoreMenuAllDto, pacInfo: PacInfoType, selectData = undefined) {
// ! 定义基础查询函数
// 启用动态查询模式 $dynamic
const query = this.mysqlService.db
.select(selectData)
.from(pacCoreMenu)
.leftJoin(pacCoreDict, eq(pacCoreMenu.menuType, pacCoreDict.dictId))
.leftJoin(pacCoreService, eq(pacCoreMenu.serviceOf, pacCoreService.serviceKey))
.orderBy(
isTrueEnum(data.isAsc) ? asc(pacCoreMenu.orderNum) : desc(pacCoreMenu.orderNum),
isTrueEnum(data.isAsc) ? asc(pacCoreMenu.menuId) : desc(pacCoreMenu.menuId),
)
.$dynamic();
// ! 条件列表
const wl = [];
// ? 未删除
wl.push(isNull(pacCoreMenu.deleteby));
// ? 模糊查询
wl.push(
or(like(pacCoreMenu.menuName, likeQuery(data.menuInfo)), like(pacCoreMenu.menuDesc, likeQuery(data.menuInfo))).if(isExistKey(data, 'menuInfo')),
);
// ? 根据pid查
wl.push(eq(pacCoreMenu.pid, data.hierarchy).if(isExistKey(data, 'hierarchy')));
// // ? 根据菜单类型查
wl.push(eq(pacCoreMenu.menuType, data.menuType).if(isExistKey(data, 'menuType')));
// ? 根据服务名称查
wl.push(eq(pacCoreMenu.serviceOf, data.serviceOf).if(isExistKey(data, 'serviceOf')));
// ? 根据是否是外部链接查
wl.push(eq(pacCoreMenu.isFrame, isTrueEnum(data.isFrame) ? 1 : 0).if(isExistKey(data, 'isFrame')));
// ? 根据是否显示查
wl.push(eq(pacCoreMenu.isVisible, isTrueEnum(data.isVisible) ? 0 : 1).if(isExistKey(data, 'isVisible')));
// ? 根据状态查
wl.push(eq(pacCoreMenu.status, data.status as any).if(isExistKey(data, 'status')));
// ? 判断是否是pac查的
if (this.config.get<number>('masterId') === pacInfo.userId) {
// ? 是否要按照激活查
if (isExistKey(data, 'isActivate')) {
wl.push(eq(pacCoreMenu.isActivate, isTrueEnum(data['isActivate']) ? 0 : 1));
}
} else {
// 非pac只能查激活的
wl.push(eq(pacCoreMenu.isActivate, 0));
}
query.where(and(...wl));
return query;
}
// DB 查列表数据
private getMenuList(getMenuData: GetPacCoreMenuAllDto, pacInfo: PacInfoType) {
return this.getMenuData(getMenuData, pacInfo, this.menuListDataType);
}
// DB查分页数据
private async getMenuPage(getPacCoreMenuAllDto: GetPacCoreMenuAllDto, pacInfo: PacInfoType) {
const offset = (getPacCoreMenuAllDto.pageNumber - 1) * getPacCoreMenuAllDto.pageSize;
// 使用基础查询构建查询总记录数
const totalCountQuery = this.getMenuData(getPacCoreMenuAllDto, pacInfo, {
totalCount: sql`COUNT(*)`,
});
// 使用基础查询构建分页查询
const paginatedQuery = this.getMenuData(getPacCoreMenuAllDto, pacInfo, this.menuMoreDataType)
.leftJoin(pacAuthUser, eq(pacCoreMenu.createby, pacAuthUser.userId))
.limit(getPacCoreMenuAllDto.pageSize)
.offset(offset);
return {
total: (await totalCountQuery)[0].totalCount,
rowData: await paginatedQuery,
searchData: getPacCoreMenuAllDto,
};
}
// DB 删除菜单
private deleteMenuItem(id, pacInfo: PacInfoType) {
return this.mysqlService.db
.update(pacCoreMenu)
.set({
deletetime: sql`now()`,
deleteby: pacInfo.userId,
})
.where(eq(pacCoreMenu.menuId, id));
}
// DB 获取菜单信息
private getMore(id) {
return this.mysqlService.db
.select({
menuId: pacCoreMenu.menuId,
pid: pacCoreMenu.pid,
})
.from(pacCoreMenu)
.where(and(isNull(pacCoreMenu.deleteby), eq(pacCoreMenu.menuId, id)));
}
// DB 更新菜单信息
private async updateMenuData(id, updateCoreMenuDto: UpdateCoreMenuDto, pacInfo: PacInfoType) {
return this.mysqlService.db
.update(pacCoreMenu)
.set({
apiPath: updateCoreMenuDto.apiPath,
webPath: updateCoreMenuDto.webPath,
webComponentPath: updateCoreMenuDto.webComponentPath,
menuName: updateCoreMenuDto.menuName,
menuDesc: updateCoreMenuDto.menuDesc,
menuType: updateCoreMenuDto.menuType,
menuIcon: updateCoreMenuDto.menuIcon,
isFrame: isTrueEnum(updateCoreMenuDto.isFrame) ? 1 : 0,
isVisible: isTrueEnum(updateCoreMenuDto.isVisible) ? 0 : 1,
isActivate: isTrueEnum(updateCoreMenuDto.isActivate) ? 0 : 1,
orderNum: updateCoreMenuDto.orderNum,
status: updateCoreMenuDto.status,
serviceOf: updateCoreMenuDto.serviceOf,
updateby: pacInfo.userId,
updatetime: sql`now()`,
})
.where(eq(pacCoreMenu.menuId, id));
}
}

@ -0,0 +1,185 @@
import { ApiProperty } from '@nestjs/swagger';
import Trim from '@common/decorator/trim/trim.decorator';
import {IsEnum, IsInt, IsOptional, IsString, Length, Max, Min} from 'class-validator';
import {BooleanEnum} from "@utils/boolean.enum";
export class CreateCoreMenuDto {
@ApiProperty({
description: '菜单父ID',
type: String,
example: '0',
required: false,
minLength: 1,
maxLength: 32,
})
@Trim()
@IsString({ message: '菜单关联属性应为字符串格式!' })
@IsOptional()
readonly pid?: string = '0';
@ApiProperty({
description: '菜单接口路径用:隔开',
type: String,
example: '0',
required: false,
minLength: 1,
maxLength: 255,
})
@Trim()
@IsString({ message: '菜单接口路径应为字符串格式!' })
@Length(1, 255, { message: '请将菜单接口路径长度控制在1到255位之间!' })
@IsOptional()
readonly apiPath: string;
@ApiProperty({
description: '页面路由路径,前后不要带/,会被继承',
type: String,
example: '0',
required: false,
minLength: 1,
maxLength: 255,
})
@Trim()
@IsString({ message: '页面路由路径应为字符串格式!' })
@Length(1, 255, { message: '请将页面路由路径长度控制在1到255位之间!' })
@IsOptional()
readonly webPath: string;
@ApiProperty({
description: '页面组件路径,从前端项目指定目录读取',
type: String,
example: '0',
required: false,
minLength: 1,
maxLength: 255,
})
@Trim()
@IsString({ message: '页面组件路径应为字符串格式!' })
@Length(1, 255, { message: '请将页面组件路径长度控制在1到255位之间!' })
@IsOptional()
readonly webComponentPath: string;
@ApiProperty({
description: '菜单接口权限名称',
type: String,
example: '控制面板',
required: true,
minLength: 1,
maxLength: 32,
})
@Trim()
@IsString({ message: '菜单接口权限名称应为字符串格式!' })
@Length(1, 32, { message: '菜单接口权限名称长度控制在1到32位之间!' })
readonly menuName: string;
@ApiProperty({
description: '菜单接口权限描述',
type: String,
example: '0',
required: false,
minLength: 1,
maxLength: 255,
})
@Trim()
@IsString({ message: '菜单接口权限描述应为字符串格式!' })
@Length(1, 255, { message: '请将菜单接口权限描述长度控制在1到255位之间!' })
@IsOptional()
readonly menuDesc: string;
@ApiProperty({
description: '菜单类型,来自于字典',
type: String,
example: '0',
required: true,
minLength: 19,
maxLength: 19,
})
@Trim()
@IsString({ message: '菜单类型格式不正确!' })
@Length(19, 19, { message: '菜单类型格式不正确!' })
readonly menuType: string;
@ApiProperty({
description: '菜单图标',
type: String,
example: '0',
required: false,
minLength: 1,
maxLength: 255,
})
@Trim()
@IsString({ message: '菜单图标应为字符串格式!' })
@Length(1, 255, { message: '请将菜单图标长度控制在1到255位之间!' })
@IsOptional()
readonly menuIcon: string;
@ApiProperty({
description: '是否为外部链接',
type: BooleanEnum,
enum: BooleanEnum,
example: false,
required: false,
})
@Trim()
@IsEnum(BooleanEnum, { message: '是否为外部链接参数格式错误' })
@IsOptional()
readonly isFrame?: BooleanEnum = BooleanEnum.FALSE;
@ApiProperty({
description: '是否显示',
type: BooleanEnum,
enum: BooleanEnum,
example: false,
required: false,
})
@Trim()
@IsEnum(BooleanEnum, { message: '是否显示参数格式错误' })
@IsOptional()
readonly isVisible?: BooleanEnum = BooleanEnum.TRUE;
@ApiProperty({
description: '是否激活',
type: BooleanEnum,
enum: BooleanEnum,
example: false,
required: false,
})
@Trim()
@IsEnum(BooleanEnum, { message: '是否激活参数格式错误' })
@IsOptional()
readonly isActivate?: BooleanEnum = BooleanEnum.TRUE;
@ApiProperty({
description: '排序',
type: Number,
example: 10,
required: false,
minimum: -1000,
maximum: 1000,
})
@IsOptional()
@IsInt({
message: '排序必须是整数!',
})
@Min(-1000, {
message: '排序不能小于-1000!',
})
@Max(1000, {
message: '排序不能超过1000',
})
readonly orderNum?: number = 0;
@ApiProperty({
description: '服务的唯一标识',
type: String,
example: 'CORE-PAC-AUTH',
required: false,
minLength: 2,
maxLength: 16,
})
@Trim()
@IsString({ message: '服务标识应为字符串格式!' })
@Length(2, 16, { message: '请将服务标识长度控制在2到16位之间!' })
@IsOptional()
readonly serviceOf: string;
}

@ -0,0 +1,136 @@
// | ------------------------------------------------------------
// | @版本: version 0.1
// | @创建人: 【Nie-hotok】
// | @E-mail: x71291@outlook.com
// | @所在项目: pac-auth
// | @文件描述: get-core-menu.dto.ts -
// | @创建时间: 2024-06-22 16:05
// | @更新时间: 2024-06-22 16:05
// | @修改记录:
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
// | =
// | ------------------------------------------------------------
import { GetDto } from '@dto/get.dto';
import { ApiProperty } from '@nestjs/swagger';
import Trim from '@common/decorator/trim/trim.decorator';
import { IsEnum, IsInt, IsOptional, IsString, Length, Max, Min } from 'class-validator';
import { BooleanEnum } from '@utils/boolean.enum';
import { Transform, Type } from 'class-transformer';
import Int from '@common/decorator/int/int.descrator';
export class GetPacCoreMenuAllDto extends GetDto {
@ApiProperty({
description: '菜单信息',
type: String,
example: '国家',
required: false,
minLength: 1,
maxLength: 128,
})
@Trim()
@IsString({ message: '菜单信息应为字符串格式!' })
@Length(0, 128, { message: '请将菜单信息长度控制在1到128位之间!' })
@IsOptional()
readonly menuInfo?: string;
@ApiProperty({
description: '菜单类型,来自于字典',
type: String,
example: '0',
required: false,
minLength: 19,
maxLength: 19,
})
@Trim()
@IsString({ message: '菜单类型格式不正确!' })
@Length(19, 19, { message: '菜单类型格式不正确!' })
@IsOptional()
readonly menuType: string;
@ApiProperty({
description: '服务的唯一标识',
type: String,
example: 'CORE-PAC-AUTH',
required: false,
minLength: 2,
maxLength: 16,
})
@Trim()
@IsString({ message: '服务标识应为字符串格式!' })
@Length(2, 16, { message: '请将服务标识长度控制在2到16位之间!' })
@IsOptional()
readonly serviceOf: string;
@ApiProperty({
description: '是否为外部链接',
type: BooleanEnum,
enum: BooleanEnum,
example: false,
required: false,
})
@Trim()
@IsEnum(BooleanEnum, { message: '是否为外部链接参数格式错误' })
@IsOptional()
readonly isFrame?: BooleanEnum;
@ApiProperty({
description: '是否显示',
type: BooleanEnum,
enum: BooleanEnum,
example: false,
required: false,
})
@Trim()
@IsEnum(BooleanEnum, { message: '是否显示参数格式错误' })
@IsOptional()
readonly isVisible?: BooleanEnum;
@ApiProperty({
description: '是否激活',
type: BooleanEnum,
enum: BooleanEnum,
example: false,
required: false,
})
@Trim()
@IsEnum(BooleanEnum, { message: '是否激活参数格式错误' })
@IsOptional()
readonly isActivate?: BooleanEnum;
@ApiProperty({
description: '菜单状态',
type: Number,
example: 0,
required: false,
minimum: -100,
maximum: 100,
})
@Trim()
@Int()
@IsInt({
message: '菜单状态必须是整数!',
})
@Min(-100, {
message: '菜单状态需要大于-100!',
})
@Max(100, {
message: '菜单状态不能超过100',
})
@IsOptional()
readonly status?: string;
@ApiProperty({
description: '字典层级id',
type: Number,
example: 0,
required: false,
minimum: 0,
maximum: 100,
})
@Trim()
@IsString({ message: '字典层级id应为字符串格式!' })
@Length(1, 20, { message: '字典层级id格式错误!' })
@IsOptional()
readonly hierarchy?: string;
}

@ -0,0 +1,25 @@
import { ApiProperty, PartialType } from '@nestjs/swagger';
import { CreateCoreMenuDto } from './create-core-menu.dto';
import { IsInt, IsOptional, Max, Min } from 'class-validator';
export class UpdateCoreMenuDto extends PartialType(CreateCoreMenuDto) {
@ApiProperty({
description: '状态',
type: Number,
example: 10,
required: false,
minimum: -100,
maximum: 100,
})
@IsOptional()
@IsInt({
message: '状态必须是整数!',
})
@Min(-1000, {
message: '状态不能小于-100!',
})
@Max(1000, {
message: '状态不能超过100',
})
readonly status: number;
}

@ -4,7 +4,7 @@ import { UpdateCoreServiceDto } from './dto/update-core-service.dto';
import { LoggerService } from '@service/logger/logger.service'; import { LoggerService } from '@service/logger/logger.service';
import { MysqlService } from '@common/service/mysql/mysql.service'; import { MysqlService } from '@common/service/mysql/mysql.service';
import { pacAuthUser, pacCoreService } from '@entities/schema'; import { pacAuthUser, pacCoreService } from '@entities/schema';
import { asc, desc, eq, isNull, like, or, sql } from 'drizzle-orm'; import { and, asc, desc, eq, isNull, like, or, sql } from 'drizzle-orm';
import { PacInfoType } from '@utils/myType'; import { PacInfoType } from '@utils/myType';
import { GetCoreServiceDto } from '@app/core-service/dto/get-core-service.dto'; import { GetCoreServiceDto } from '@app/core-service/dto/get-core-service.dto';
import { likeQuery } from '@utils/likeQuery'; import { likeQuery } from '@utils/likeQuery';
@ -147,16 +147,19 @@ export class CoreServiceService {
// 定义基础查询函数 // 定义基础查询函数
const buildBaseQuery = (selectData = undefined) => { const buildBaseQuery = (selectData = undefined) => {
// 启用动态查询模式 $dynamic // 启用动态查询模式 $dynamic
let query = this.mysqlService.db.select(selectData).from(pacCoreService).where(isNull(pacCoreService.deleteby)).$dynamic(); let query = this.mysqlService.db.select(selectData).from(pacCoreService).$dynamic();
// 根据条件添加额外的WHERE子句 // 根据条件添加额外的WHERE子句
if (getCoreServiceDto.serviceInfo) { if (getCoreServiceDto.serviceInfo) {
query = query.where( query = query.where(
and(
or( or(
like(pacCoreService.serviceKey, likeQuery(getCoreServiceDto.serviceInfo)), like(pacCoreService.serviceKey, likeQuery(getCoreServiceDto.serviceInfo)),
like(pacCoreService.serviceName, likeQuery(getCoreServiceDto.serviceInfo)), like(pacCoreService.serviceName, likeQuery(getCoreServiceDto.serviceInfo)),
like(pacCoreService.serviceDesc, likeQuery(getCoreServiceDto.serviceInfo)), like(pacCoreService.serviceDesc, likeQuery(getCoreServiceDto.serviceInfo)),
), ),
isNull(pacCoreService.deleteby),
),
); );
} }

@ -0,0 +1,25 @@
// | ------------------------------------------------------------
// | @版本: version 0.1
// | @创建人: 【Nie-hotok】
// | @E-mail: x71291@outlook.com
// | @所在项目: pac-auth
// | @文件描述: int.descrator.ts -
// | @创建时间: 2024-06-22 19:07
// | @更新时间: 2024-06-22 19:07
// | @修改记录:
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
// | =
// | ------------------------------------------------------------
import { Transform } from 'class-transformer';
export default function Int() {
return Transform(({ value }) => {
if (typeof value === 'string') {
if (value.trim() == '') {
return undefined;
}
return parseInt(value);
}
return value;
});
}

@ -23,7 +23,7 @@ export default () => ({
version: process.env.npm_package_version || '0.0.1', version: process.env.npm_package_version || '0.0.1',
}, },
logger: { logger: {
level: process.env['NODE_ENV'] === 'development' ? 'trace' : 'warning', level: process.env['NODE_ENV'] === undefined || 'development' ? 'trace' : 'warning',
}, },
swagger: { swagger: {
path: 'swagger', path: 'swagger',

@ -293,11 +293,12 @@ export const pacCoreMenu = mysqlTable(
menuId: bigint('menu_id', { mode: 'number' }).notNull(), menuId: bigint('menu_id', { mode: 'number' }).notNull(),
pid: bigint('pid', { mode: 'number' }).notNull(), pid: bigint('pid', { mode: 'number' }).notNull(),
haveChildren: int('have_children').default(0).notNull(), haveChildren: int('have_children').default(0).notNull(),
apiPath: varchar('api_path', { length: 255 }).notNull(), apiPath: varchar('api_path', { length: 255 }),
webPath: varchar('web_path', { length: 255 }).notNull(), webPath: varchar('web_path', { length: 255 }),
webComponentPath: varchar('web_component_path', { length: 255 }),
menuName: varchar('menu_name', { length: 255 }).notNull(), menuName: varchar('menu_name', { length: 255 }).notNull(),
menuDesc: varchar('menu_desc', { length: 255 }), menuDesc: varchar('menu_desc', { length: 255 }),
menuType: int('menu_type').default(0).notNull(), menuType: bigint('menu_type', { mode: 'number' }).notNull(),
menuIcon: varchar('menu_icon', { length: 255 }), menuIcon: varchar('menu_icon', { length: 255 }),
isFrame: int('is_frame').default(0).notNull(), isFrame: int('is_frame').default(0).notNull(),
isVisible: int('is_visible').default(0).notNull(), isVisible: int('is_visible').default(0).notNull(),

@ -56,8 +56,6 @@ async function bootstrap() {
// 获取日志模块 // 获取日志模块
const logger = app.get(LoggerService); const logger = app.get(LoggerService);
// console.log(config);
// 开发环境 // 开发环境
if (config.get<string>('env') === 'development') { if (config.get<string>('env') === 'development') {
// 在开发环境下,开启openAPI // 在开发环境下,开启openAPI

@ -39,6 +39,8 @@ export class LoggerService {
} }
}; };
// 创建一个 Winston 的 Logger 实例 // 创建一个 Winston 的 Logger 实例
private readonly logger: winston.Logger = winston.createLogger({ private readonly logger: winston.Logger = winston.createLogger({
// 设置日志级别 // 设置日志级别

@ -40,7 +40,8 @@ export class Snowflake {
if (machineId < 0 || machineId > Snowflake.MACHINE_ID_MASK) { if (machineId < 0 || machineId > Snowflake.MACHINE_ID_MASK) {
throw new Error('Machine ID must be between 0 and ' + Snowflake.MACHINE_ID_MASK.toString()); throw new Error('Machine ID must be between 0 and ' + Snowflake.MACHINE_ID_MASK.toString());
} }
console.log(machineId);
// console.log(machineId);
this.machineId = BigInt(machineId); this.machineId = BigInt(machineId);
} }

@ -36,5 +36,5 @@ export function isTrueEnum(target) {
// 判断是否存在目标值 // 判断是否存在目标值
export function isExistKey(target, key) { export function isExistKey(target, key) {
return Object.keys(target).includes(key) && target[key] !== undefined && target[key] !== null && target[key] != ''; return Object.keys(target).includes(key) && target[key] !== undefined && target[key] !== null && target[key] !== '';
} }

@ -13,7 +13,6 @@
import { sql } from 'drizzle-orm'; import { sql } from 'drizzle-orm';
// 将递归查询的自定义列明返回,数据来源于要查的列命,并增加level字段 // 将递归查询的自定义列明返回,数据来源于要查的列命,并增加level字段
export function customDrizzleRowWithRecursive(obj) { export function customDrizzleRowWithRecursive(obj) {
// ! 获取所有的列别名 // ! 获取所有的列别名

Loading…
Cancel
Save