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

@Entity('member_level')
export class MemberLevel {
  @PrimaryGeneratedColumn()
  level_id: number;

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

  @Column({ type: 'varchar', length: 50, comment: '等级名称' })
  level_name: string;

  @Column({ type: 'varchar', length: 255, comment: '等级图标' })
  level_icon: string;

  @Column({ type: 'int', default: 0, comment: '升级所需积分' })
  upgrade_point: number;

  @Column({ type: 'decimal', precision: 5, scale: 2, default: 1.0, comment: '积分倍率' })
  point_rate: number;

  @Column({ type: 'decimal', precision: 5, scale: 2, default: 1.0, comment: '折扣率' })
  discount_rate: number;

  @Column({ type: 'int', default: 0, comment: '排序' })
  sort: number;

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

  @Column({ type: 'varchar', length: 255, comment: '等级描述' })
  description: string;

  @Column({ type: 'varchar', length: 255, comment: '等级权益' })
  benefits: string;

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

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

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

  // 关联关系
  @OneToMany(() => Member, member => member.level)
  members: Member[];
} 