TgMessage.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
  2. @Index('idx_chat_type', [ 'chatType' ], {})
  3. @Index('idx_chatId', [ 'chatId' ], {})
  4. @Index('uk_message', [ 'botId', 'messageId', 'chatId' ], { unique: true })
  5. @Entity('tg_message', { schema: 'tgbot' })
  6. export default class TgMessage {
  7. @PrimaryGeneratedColumn({ type: 'int', name: 'id', unsigned: true })
  8. id: number;
  9. @Column('bigint', { name: 'botId', comment: '哪个机器人监听的' })
  10. botId: number;
  11. @Column('bigint', { name: 'messageId', comment: 'Telegram消息ID' })
  12. messageId: number;
  13. @Column('bigint', { name: 'chatId', comment: '群组ID或个人ID' })
  14. chatId: number;
  15. @Column('varchar', {
  16. name: 'chatType',
  17. comment: 'group 群组 private个人',
  18. length: 50,
  19. default: () => "'group'",
  20. })
  21. chatType: string;
  22. @Column('varchar', {
  23. name: 'chatTitle',
  24. nullable: true,
  25. comment: '群组标题',
  26. length: 255,
  27. })
  28. chatTitle: string | null;
  29. @Column('varchar', {
  30. name: 'chatName',
  31. nullable: true,
  32. comment: '个人聊天昵称',
  33. length: 255,
  34. })
  35. chatName: string | null;
  36. @Column('varchar', {
  37. name: 'chatUsername',
  38. nullable: true,
  39. comment: '个人聊天用户名',
  40. length: 255,
  41. })
  42. chatUsername: string | null;
  43. @Column('bigint', { name: 'fromUserId', comment: '发送者用户id' })
  44. fromUserId: string;
  45. @Column('varchar', {
  46. name: 'fromName',
  47. nullable: true,
  48. comment: '发送者名字',
  49. length: 255,
  50. })
  51. fromName: string | null;
  52. @Column('varchar', {
  53. name: 'fromUsername',
  54. nullable: true,
  55. comment: '发送者用户名',
  56. length: 255,
  57. })
  58. fromUsername: string | null;
  59. @Column('tinyint', {
  60. name: 'isBot',
  61. comment: '是否来自机器人',
  62. unsigned: true,
  63. default: () => "'0'",
  64. })
  65. isBot: number;
  66. @Column('int', { name: 'sentTime', nullable: true, comment: '发送时间' })
  67. sentTime: number | null;
  68. @Column('text', { name: 'text', nullable: true, comment: '消息内容' })
  69. text: string | null;
  70. @Column('datetime', {
  71. name: 'createTime',
  72. comment: '创建时间',
  73. default: () => 'CURRENT_TIMESTAMP',
  74. })
  75. createTime: Date;
  76. @Column('datetime', {
  77. name: 'updateTime',
  78. comment: '跟新时间',
  79. default: () => 'CURRENT_TIMESTAMP',
  80. })
  81. updateTime: Date;
  82. }