fix: 完善数据库实体类型安全性和配置优化
- 为所有枚举字段添加 enumName 属性确保数据库类型安全 - 移除 DB_SYNCHRONIZE 环境变量,统一设为 false 避免生产风险 - 修复 refreshToken 字段类型定义提升兼容性
This commit is contained in:
parent
546ccad21a
commit
4dd37c7ce2
|
|
@ -4,7 +4,6 @@ DB_PORT=53305
|
|||
DB_USERNAME=root
|
||||
DB_PASSWORD=WsJWXfwFx0bq6DE2kmB6
|
||||
DB_DATABASE=nano_camera_miniapp
|
||||
DB_SYNCHRONIZE=false
|
||||
DB_LOGGING=true
|
||||
DB_MIGRATIONS_RUN=true
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const databaseConfig = (
|
|||
database: configService.get<string>('DB_DATABASE', 'nano_camera_miniapp'),
|
||||
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
|
||||
migrations: [__dirname + '/../migrations/*{.ts,.js}'],
|
||||
synchronize: configService.get<boolean>('DB_SYNCHRONIZE', false), // 生产环境建议设为false
|
||||
synchronize: false,
|
||||
logging: configService.get<boolean>(
|
||||
'DB_LOGGING',
|
||||
process.env.NODE_ENV === 'development',
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ export class AdWatchEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: PlatformType,
|
||||
enumName: 'PlatformType',
|
||||
})
|
||||
platform: PlatformType;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export class ExtensionDataEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: PlatformType,
|
||||
enumName: 'PlatformType',
|
||||
})
|
||||
platform: PlatformType;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ export class PlatformUserEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: PlatformType,
|
||||
enumName: 'PlatformType',
|
||||
})
|
||||
platform: PlatformType;
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ export class PlatformUserEntity {
|
|||
accessToken: string;
|
||||
|
||||
/** 刷新令牌 - 用于刷新过期的访问令牌,维持长期授权状态 */
|
||||
@Column({ length: 500, nullable: true })
|
||||
@Column({ type: 'varchar', length: 500, nullable: true })
|
||||
refreshToken: string | null;
|
||||
|
||||
/** 令牌过期时间 - 访问令牌的过期时间戳,用于判断是否需要刷新令牌 */
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export class TemplateExecutionEntity {
|
|||
userId: string;
|
||||
|
||||
/** 执行平台 - 任务发起的平台来源 */
|
||||
@Column({ type: 'enum', enum: PlatformType })
|
||||
@Column({ type: 'enum', enum: PlatformType, enumName: 'PlatformType', })
|
||||
platform: PlatformType;
|
||||
|
||||
/** 执行类型 - 标识生成内容的类型(图片或视频) */
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export class UserCreditEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: PlatformType,
|
||||
enumName: 'PlatformType',
|
||||
})
|
||||
platform: PlatformType;
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ export class UserCreditEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: CreditType,
|
||||
enumName: 'CreditType',
|
||||
})
|
||||
type: CreditType;
|
||||
|
||||
|
|
@ -67,6 +69,7 @@ export class UserCreditEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: CreditSource,
|
||||
enumName: 'CreditSource',
|
||||
})
|
||||
source: CreditSource;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export class UserSubscriptionEntity {
|
|||
@Column({
|
||||
type: 'enum',
|
||||
enum: PlatformType,
|
||||
enumName: 'platform_type',
|
||||
})
|
||||
platform: PlatformType;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export class PlatformLoginDto {
|
|||
@ApiProperty({
|
||||
description: '平台类型',
|
||||
enum: PlatformType,
|
||||
enumName: 'PlatformType',
|
||||
example: PlatformType.WECHAT,
|
||||
})
|
||||
@IsEnum(PlatformType)
|
||||
|
|
|
|||
Loading…
Reference in New Issue