import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm'; import { User } from '../users/user.entity'; import { Agent } from '../agent/agent.entity'; @Entity('user_cards') export class UserCard { @PrimaryGeneratedColumn({ unsigned: true }) id!: number; @Column({ name: 'user_id', type: 'int', unsigned: true, comment: '用户ID' }) userId!: number; @Column({ name: 'agent_id', type: 'int', unsigned: true, nullable: true, comment: '代理商ID' }) agentId!: number | null; @Column({ name: 'card_no', type: 'varchar', length: 20, unique: true, comment: '卡号' }) cardNo!: string; @Column({ name: 'sjt_card_no', type: 'varchar', length: 20, nullable: true, comment: '盛京通卡卡号' }) sjtCardNo!: string | null; @Column({ name: 'password', type: 'varchar', length: 255, comment: '密码' }) password!: string; @Column({ name: 'auth_code', type: 'varchar', length: 16, nullable: true, comment: '付款码70_75开头16位随机数' }) authCode!: string | null; @Column({ name: 'state', type: 'int', unsigned: true, default: 1, comment: '状态 1绑定 2解绑 通用联名电子卡不可解绑' }) state!: number; @Column({ name: 'balance', type: 'decimal', precision: 10, scale: 2, unsigned: true, default: 0.00, comment: '余额' }) balance!: number; @Column({ name: 'is_default', type: 'int', default: 2, comment: '默认 1是 2否' }) isDefault!: number; @Column({ name: 'created_by', type: 'int', unsigned: true, nullable: true, comment: '创建人ID' }) createdBy!: number | null; @Column({ name: 'updated_by', type: 'int', unsigned: true, nullable: true, comment: '更新人ID' }) updatedBy!: number | null; @CreateDateColumn({ name: 'created_at', type: 'timestamp' }) createdAt!: Date; @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' }) updatedAt!: Date; @ManyToOne(() => User) @JoinColumn({ name: 'user_id', referencedColumnName: 'id' }) user!: User; @ManyToOne(() => Agent) @JoinColumn({ name: 'agent_id', referencedColumnName: 'id' }) agent!: Agent | null; }