diff --git a/src/server/modules/users/login-history.entity.ts b/src/server/modules/users/login-history.entity.ts deleted file mode 100644 index efda7c9..0000000 --- a/src/server/modules/users/login-history.entity.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn } from 'typeorm'; -import { UserEntity } from './user.entity'; -import { z } from 'zod'; - -@Entity({ name: 'login_history' }) -export class LoginHistoryEntity { - @PrimaryGeneratedColumn({ unsigned: true }) - id!: number; - - @ManyToOne(() => UserEntity) - @JoinColumn({ name: 'user_id' }) - user!: UserEntity; - - @Column({ - name: 'ip_address', - type: 'varchar', - length: 45, - comment: '登录IP地址' - }) - ipAddress!: string; - - @Column({ - name: 'user_agent', - type: 'text', - nullable: true, - comment: '用户代理信息' - }) - userAgent!: string | null; - - @Column({ - name: 'longitude', - type: 'decimal', - precision: 10, - scale: 6, - nullable: true, - comment: '登录位置经度' - }) - longitude!: number | null; - - @Column({ - name: 'latitude', - type: 'decimal', - precision: 10, - scale: 6, - nullable: true, - comment: '登录位置纬度' - }) - latitude!: number | null; - - @Column({ - name: 'location_name', - type: 'varchar', - length: 255, - nullable: true, - comment: '登录位置名称' - }) - locationName!: string | null; - - @CreateDateColumn({ - name: 'login_time', - type: 'timestamp', - comment: '登录时间' - }) - loginTime!: Date; - - constructor(partial?: Partial) { - Object.assign(this, partial); - } -} - -export const LoginHistorySchema = z.object({ - ipAddress: z.string().ip().openapi({ - example: '192.168.1.1', - description: '登录IP地址' - }), - userAgent: z.string().optional().openapi({ - example: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)', - description: '用户代理信息' - }), - longitude: z.number().optional().openapi({ - example: 116.404, - description: '登录位置经度' - }), - latitude: z.number().optional().openapi({ - example: 39.915, - description: '登录位置纬度' - }), - locationName: z.string().optional().openapi({ - example: '北京市朝阳区', - description: '登录位置名称' - }) -}); \ No newline at end of file diff --git a/src/server/modules/users/message.entity.ts b/src/server/modules/users/message.entity.ts deleted file mode 100644 index 1c4286e..0000000 --- a/src/server/modules/users/message.entity.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, OneToMany, ManyToOne } from 'typeorm'; -import { UserMessage } from '../messages/user-message.entity'; -import { UserEntity } from './user.entity'; -import { z } from 'zod'; - -@Entity({ name: 'messages' }) -export class MessageEntity { - @PrimaryGeneratedColumn({ unsigned: true, comment: '消息ID' }) - id!: number; - - @Column({ - type: 'varchar', - length: 255, - nullable: false, - comment: '消息标题' - }) - title!: string; - - @Column({ - type: 'text', - nullable: false, - comment: '消息内容' - }) - content!: string; - - @Column({ - type: 'enum', - enum: ['system', 'private', 'announce'], - nullable: false, - comment: '消息类型' - }) - type!: 'system' | 'private' | 'announce'; - - @Column({ - name: 'sender_id', - type: 'int', - unsigned: true, - nullable: true, - comment: '发送者ID' - }) - senderId?: number; - - @Column({ - name: 'sender_name', - type: 'varchar', - length: 255, - nullable: true, - comment: '发送者名称' - }) - senderName?: string; - - @CreateDateColumn({ - name: 'created_at', - type: 'timestamp', - comment: '创建时间' - }) - createdAt!: Date; - - @UpdateDateColumn({ - name: 'updated_at', - type: 'timestamp', - comment: '更新时间' - }) - updatedAt!: Date; - - @OneToMany(() => UserMessage, (userMessage) => userMessage.messageId) - userMessages!: UserMessage[]; - - @ManyToOne(() => UserEntity, (user) => user.senderMessages) - sender?: UserEntity; - - constructor(partial?: Partial) { - Object.assign(this, partial); - } -} - -export const MessageSchema = z.object({ - title: z.string().min(1).max(255).openapi({ - example: '系统通知', - description: '消息标题' - }), - content: z.string().min(1).openapi({ - example: '您的账户已成功创建', - description: '消息内容' - }), - type: z.enum(['system', 'private', 'announce']).openapi({ - example: 'system', - description: '消息类型' - }), - senderId: z.number().int().positive().optional().openapi({ - example: 1, - description: '发送者ID' - }), - senderName: z.string().max(255).optional().openapi({ - example: '管理员', - description: '发送者名称' - }) -}); \ No newline at end of file