import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index, } from 'typeorm'; import { ApiProperty } from '@nestjs/swagger'; @Entity('tg_account') @Index(['phone', 'deviceId'], { unique: false }) // 允许同一手机号多设备登录 export class TgAccount { @ApiProperty({ description: 'TG账号ID' }) @PrimaryGeneratedColumn() id: number; @ApiProperty({ description: '名字' }) @Column({ nullable: true, comment: '姓' }) firstname: string; @ApiProperty({ description: '姓氏' }) @Column({ nullable: true, comment: '名字' }) lastname: string; @ApiProperty({ description: '简介' }) @Column({ nullable: true, comment: '简介' }) about: string; @ApiProperty({ description: '手机号' }) @Column({ comment: '手机号' }) phone: string; @ApiProperty({ description: '用户名' }) @Column({ nullable: true, comment: '用户名' }) username: string; @ApiProperty({ description: '设备ID' }) @Column({ nullable: true, comment: '设备ID' }) deviceId: string; @ApiProperty({ description: '是否在线' }) @Column({ default: false, comment: '是否在线' }) isOnline: boolean; @ApiProperty({ description: '账号状态' }) @Column({ default: 1, comment: '账号状态: 1正常 2封号 3限制' }) status: number; @ApiProperty({ description: '会话字符串' }) @Column({ type: 'text', nullable: true, comment: '会话字符串' }) sessionString: string; @ApiProperty({ description: 'API ID' }) @Column({ nullable: true, comment: 'API ID' }) apiId: string; @ApiProperty({ description: 'API Hash' }) @Column({ nullable: true, comment: 'API Hash' }) apiHash: string; @ApiProperty({ description: '代理配置' }) @Column({ type: 'json', nullable: true, comment: '代理配置' }) proxyConfig: any; @ApiProperty({ description: '最后活跃时间' }) @Column({ type: 'datetime', nullable: true, comment: '最后活跃时间' }) lastActiveAt: Date; @ApiProperty({ description: '创建时间' }) @CreateDateColumn() createdAt: Date; @ApiProperty({ description: '更新时间' }) @UpdateDateColumn() updatedAt: Date; }