import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity('system_secrets')
export class SystemSecret {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @Column({ name: 'secret_key', length: 100, comment: '密钥名' })
  secretKey: string;

  @Column({ name: 'secret_value', type: 'text', comment: '加密后的值' })
  secretValue: string;

  @Column({ name: 'description', length: 200, nullable: true, comment: '说明' })
  description: string;

  @Column({ name: 'group_name', length: 50, default: 'default', comment: '分组' })
  groupName: string;

  @Column({ type: 'enum', enum: ['all', 'prod', 'test'], default: 'all', comment: '适用环境' })
  env: 'all' | 'prod' | 'test';

  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
  updatedAt: Date;
}
