| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
- @Index('idx_chat_type', [ 'chatType' ], {})
- @Index('idx_chatId', [ 'chatId' ], {})
- @Index('uk_message', [ 'botId', 'messageId', 'chatId' ], { unique: true })
- @Entity('tg_message', { schema: 'tgbot' })
- export default class TgMessage {
- @PrimaryGeneratedColumn({ type: 'int', name: 'id', unsigned: true })
- id: number;
- @Column('bigint', { name: 'botId', comment: '哪个机器人监听的' })
- botId: number;
- @Column('bigint', { name: 'messageId', comment: 'Telegram消息ID' })
- messageId: number;
- @Column('bigint', { name: 'chatId', comment: '群组ID或个人ID' })
- chatId: number;
- @Column('varchar', {
- name: 'chatType',
- comment: 'group 群组 private个人',
- length: 50,
- default: () => "'group'",
- })
- chatType: string;
- @Column('varchar', {
- name: 'chatTitle',
- nullable: true,
- comment: '群组标题',
- length: 255,
- })
- chatTitle: string | null;
- @Column('varchar', {
- name: 'chatName',
- nullable: true,
- comment: '个人聊天昵称',
- length: 255,
- })
- chatName: string | null;
- @Column('varchar', {
- name: 'chatUsername',
- nullable: true,
- comment: '个人聊天用户名',
- length: 255,
- })
- chatUsername: string | null;
- @Column('bigint', { name: 'fromUserId', comment: '发送者用户id' })
- fromUserId: string;
- @Column('varchar', {
- name: 'fromName',
- nullable: true,
- comment: '发送者名字',
- length: 255,
- })
- fromName: string | null;
- @Column('varchar', {
- name: 'fromUsername',
- nullable: true,
- comment: '发送者用户名',
- length: 255,
- })
- fromUsername: string | null;
- @Column('tinyint', {
- name: 'isBot',
- comment: '是否来自机器人',
- unsigned: true,
- default: () => "'0'",
- })
- isBot: number;
- @Column('int', { name: 'sentTime', nullable: true, comment: '发送时间' })
- sentTime: number | null;
- @Column('text', { name: 'text', nullable: true, comment: '消息内容' })
- text: string | null;
- @Column('datetime', {
- name: 'createTime',
- comment: '创建时间',
- default: () => 'CURRENT_TIMESTAMP',
- })
- createTime: Date;
- @Column('datetime', {
- name: 'updateTime',
- comment: '跟新时间',
- default: () => 'CURRENT_TIMESTAMP',
- })
- updateTime: Date;
- }
|