feat: 更新数据模型和共享类型
- 更新 Prisma schema 添加 File 模型和相关字段 - 更新共享类型定义,添加文件和密码重置相关类型 - 添加 CaptchaScene.RESET_PASSWORD 场景 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,18 +12,40 @@ model User {
|
||||
email String
|
||||
password String
|
||||
name String?
|
||||
avatarId String? // 头像文件 ID
|
||||
isSuperAdmin Boolean @default(false) // 超级管理员标记
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
roles UserRole[]
|
||||
roles UserRole[]
|
||||
uploadFiles File[] @relation("FileUploader")
|
||||
|
||||
// 复合唯一约束:未删除用户邮箱唯一,已删除用户邮箱可重复
|
||||
@@unique([email, deletedAt])
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
// 文件表
|
||||
model File {
|
||||
id String @id @default(cuid(2))
|
||||
filename String // 原始文件名
|
||||
objectName String // MinIO 中的对象名
|
||||
mimeType String // MIME 类型
|
||||
size Int // 文件大小(字节)
|
||||
purpose String // 用途: avatar, attachment 等
|
||||
uploaderId String // 上传者 ID
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
uploader User @relation("FileUploader", fields: [uploaderId], references: [id])
|
||||
|
||||
@@index([uploaderId])
|
||||
@@index([purpose])
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
// 角色表
|
||||
model Role {
|
||||
id String @id @default(cuid(2))
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string | null;
|
||||
avatarId: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
deletedAt?: Date | null;
|
||||
@@ -42,6 +43,7 @@ export interface UserResponse {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string | null;
|
||||
avatarId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt?: string | null;
|
||||
@@ -74,6 +76,7 @@ export interface AuthUser {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string | null;
|
||||
avatarId: string | null;
|
||||
}
|
||||
|
||||
// 认证响应
|
||||
@@ -102,6 +105,38 @@ export interface RefreshTokenResponse {
|
||||
refreshTokenExpiresIn: number;
|
||||
}
|
||||
|
||||
// ==================== 重置密码相关类型 ====================
|
||||
|
||||
/** 发送重置密码邮件请求 */
|
||||
export interface SendResetPasswordEmailDto {
|
||||
email: string;
|
||||
captchaId: string;
|
||||
captchaCode: string;
|
||||
}
|
||||
|
||||
/** 发送重置密码邮件响应 */
|
||||
export interface SendResetPasswordEmailResponse {
|
||||
/** 邮箱验证码 ID,用于后续重置密码 */
|
||||
emailCodeId: string;
|
||||
/** 验证码有效期(秒) */
|
||||
expiresIn: number;
|
||||
}
|
||||
|
||||
/** 重置密码请求 */
|
||||
export interface ResetPasswordDto {
|
||||
/** 邮箱验证码 ID */
|
||||
emailCodeId: string;
|
||||
/** 邮箱验证码 */
|
||||
emailCode: string;
|
||||
/** 新密码 */
|
||||
password: string;
|
||||
}
|
||||
|
||||
/** 重置密码响应 */
|
||||
export interface ResetPasswordResponse {
|
||||
message: string;
|
||||
}
|
||||
|
||||
/** JWT Token 载荷 */
|
||||
export interface TokenPayload {
|
||||
/** 用户 ID */
|
||||
|
||||
@@ -232,6 +232,7 @@ export interface UserWithRolesResponse {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string | null;
|
||||
avatarId: string | null;
|
||||
isSuperAdmin: boolean;
|
||||
roles: UserRoleResponse[];
|
||||
createdAt: string;
|
||||
|
||||
Reference in New Issue
Block a user