import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { MembershipType } from './membership-plan.schema';

@Entity('membership_plans')
export class MembershipPlan {
  @PrimaryGeneratedColumn({ unsigned: true })
  id!: number;

  @Column({ name: 'name', type: 'varchar', length: 100, comment: '套餐名称' })
  name!: string;

  @Column({ 
    name: 'type', 
    type: 'enum', 
    enum: MembershipType, 
    comment: '套餐类型：single-单次，monthly-单月，yearly-年，lifetime-永久' 
  })
  type!: MembershipType;

  @Column({ name: 'price', type: 'decimal', precision: 10, scale: 2, comment: '价格' })
  price!: number;

  @Column({ name: 'duration_days', type: 'int', comment: '有效期天数（永久为0）' })
  durationDays!: number;

  @Column({ name: 'description', type: 'text', nullable: true, comment: '套餐描述' })
  description!: string | null;

  @Column({ name: 'features', type: 'json', comment: '套餐功能列表' })
  features!: string[];

  @Column({ name: 'is_active', type: 'tinyint', default: 1, comment: '是否启用' })
  isActive!: number;

  @Column({ name: 'sort_order', type: 'int', default: 0, comment: '排序' })
  sortOrder!: number;

  @CreateDateColumn({ name: 'created_at' })
  createdAt!: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt!: Date;
}
