import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Member } from './Member';

@Entity('member_account')
export class MemberAccount {
  @PrimaryGeneratedColumn()
  account_id: number;

  @Column({ type: 'int', default: 0, comment: '站点ID' })
  site_id: number;

  @Column({ type: 'int', comment: '会员ID' })
  member_id: number;

  @Column({ type: 'varchar', length: 50, comment: '账户类型' })
  account_type: string;

  @Column({ type: 'varchar', length: 255, comment: '账户名称' })
  account_name: string;

  @Column({ type: 'varchar', length: 255, comment: '账户号码' })
  account_number: string;

  @Column({ type: 'varchar', length: 100, comment: '开户行' })
  bank_name: string;

  @Column({ type: 'varchar', length: 100, comment: '支行名称' })
  branch_name: string;

  @Column({ type: 'varchar', length: 50, comment: '持卡人姓名' })
  cardholder_name: string;

  @Column({ type: 'varchar', length: 20, comment: '持卡人手机号' })
  cardholder_mobile: string;

  @Column({ type: 'varchar', length: 18, comment: '持卡人身份证号' })
  cardholder_id_card: string;

  @Column({ type: 'tinyint', default: 0, comment: '是否默认账户 0:否 1:是' })
  is_default: number;

  @Column({ type: 'tinyint', default: 1, comment: '状态 1:正常 0:禁用' })
  status: number;

  @Column({ type: 'varchar', length: 255, comment: '备注' })
  remark: string;

  @Column({ type: 'tinyint', default: 0, comment: '是否删除 0:否 1:是' })
  is_del: number;

  @CreateDateColumn({ comment: '创建时间' })
  create_time: Date;

  @UpdateDateColumn({ comment: '更新时间' })
  update_time: Date;

  // 关联关系
  @ManyToOne(() => Member, member => member.accounts)
  @JoinColumn({ name: 'member_id' })
  member: Member;
} 