user-card.entity.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
  2. import { User } from '../users/user.entity';
  3. import { Agent } from '../agent/agent.entity';
  4. @Entity('user_cards')
  5. export class UserCard {
  6. @PrimaryGeneratedColumn({ unsigned: true })
  7. id!: number;
  8. @Column({ name: 'user_id', type: 'int', unsigned: true, comment: '用户ID' })
  9. userId!: number;
  10. @Column({ name: 'agent_id', type: 'int', unsigned: true, nullable: true, comment: '代理商ID' })
  11. agentId!: number | null;
  12. @Column({ name: 'card_no', type: 'varchar', length: 20, unique: true, comment: '卡号' })
  13. cardNo!: string;
  14. @Column({ name: 'sjt_card_no', type: 'varchar', length: 20, nullable: true, comment: '盛京通卡卡号' })
  15. sjtCardNo!: string | null;
  16. @Column({ name: 'password', type: 'varchar', length: 255, comment: '密码' })
  17. password!: string;
  18. @Column({ name: 'auth_code', type: 'varchar', length: 16, nullable: true, comment: '付款码70_75开头16位随机数' })
  19. authCode!: string | null;
  20. @Column({ name: 'state', type: 'int', unsigned: true, default: 1, comment: '状态 1绑定 2解绑 通用联名电子卡不可解绑' })
  21. state!: number;
  22. @Column({ name: 'balance', type: 'decimal', precision: 10, scale: 2, unsigned: true, default: 0.00, comment: '余额' })
  23. balance!: number;
  24. @Column({ name: 'is_default', type: 'int', default: 2, comment: '默认 1是 2否' })
  25. isDefault!: number;
  26. @Column({ name: 'created_by', type: 'int', unsigned: true, nullable: true, comment: '创建人ID' })
  27. createdBy!: number | null;
  28. @Column({ name: 'updated_by', type: 'int', unsigned: true, nullable: true, comment: '更新人ID' })
  29. updatedBy!: number | null;
  30. @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  31. createdAt!: Date;
  32. @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
  33. updatedAt!: Date;
  34. @ManyToOne(() => User)
  35. @JoinColumn({ name: 'user_id', referencedColumnName: 'id' })
  36. user!: User;
  37. @ManyToOne(() => Agent)
  38. @JoinColumn({ name: 'agent_id', referencedColumnName: 'id' })
  39. agent!: Agent | null;
  40. }