1
0

TgGroupBot.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {
  2. Column,
  3. Entity,
  4. Index,
  5. JoinColumn,
  6. ManyToOne,
  7. PrimaryGeneratedColumn,
  8. } from 'typeorm';
  9. import TgBot from './TgBot';
  10. import TgGroup from './TgGroup';
  11. @Index('idx_bot', [ 'botId' ], {})
  12. @Index('idx_group', [ 'groupId' ], {})
  13. @Index('uk_group_bot', [ 'groupId', 'botId' ], { unique: true })
  14. @Entity('tg_group_bot', { schema: 'tgbot' })
  15. export default class TgGroupBot {
  16. @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  17. id: number;
  18. @Column('bigint', { name: 'groupId', comment: '群组ID' })
  19. groupId: number;
  20. @Column('bigint', { name: 'botId', comment: '机器人ID' })
  21. botId: number;
  22. @Column('datetime', {
  23. name: 'createTime',
  24. comment: '创建时间',
  25. default: () => 'CURRENT_TIMESTAMP',
  26. })
  27. createTime: Date;
  28. @Column('datetime', {
  29. name: 'updateTime',
  30. comment: '更新时间',
  31. default: () => 'CURRENT_TIMESTAMP',
  32. })
  33. updateTime: Date;
  34. @ManyToOne(() => TgBot, tgBot => tgBot.tgGroupBots, {
  35. onDelete: 'CASCADE',
  36. onUpdate: 'NO ACTION',
  37. })
  38. @JoinColumn([{ name: 'botId', referencedColumnName: 'botId' }])
  39. bot: TgBot;
  40. @ManyToOne(() => TgGroup, tgGroup => tgGroup.tgGroupBots, {
  41. onDelete: 'CASCADE',
  42. onUpdate: 'NO ACTION',
  43. })
  44. @JoinColumn([{ name: 'groupId', referencedColumnName: 'groupId' }])
  45. group: TgGroup;
  46. }