import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn, } from 'typeorm'; import TgGroupBot from './TgGroupBot'; @Index('uk_botId', [ 'botId' ], { unique: true }) @Index('uk_username', [ 'username' ], { unique: true }) @Entity('tg_bot', { schema: 'tgbot' }) export default class TgBot { @PrimaryGeneratedColumn({ type: 'int', name: 'id' }) id: number; @Column('bigint', { name: 'botId', unique: true, comment: '机器人ID' }) botId: number; @Column('varchar', { name: 'username', unique: true, comment: '机器人用户名', length: 100, }) username: string; @Column('varchar', { name: 'name', comment: '机器人名称', length: 100 }) name: string; @Column('varchar', { name: 'token', comment: '机器人Token', length: 255 }) token: string; @Column('tinyint', { name: 'status', nullable: true, comment: '机器人状态 0 1', default: () => "'1'", }) status: number | null; @Column('varchar', { name: 'description', nullable: true, comment: '机器人描述', length: 500, }) description: string | null; @Column('datetime', { name: 'createTime', comment: '创建时间', default: () => 'CURRENT_TIMESTAMP', }) createTime: Date; @Column('datetime', { name: 'updateTime', comment: '更新时间', default: () => 'CURRENT_TIMESTAMP', }) updateTime: Date; @OneToMany(() => TgGroupBot, tgGroupBot => tgGroupBot.bot) tgGroupBots: TgGroupBot[]; }