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

@Entity('sys_menu')
export class SysMenu {
  @PrimaryGeneratedColumn({ name: 'id' })
  id: number;

  @Column({ name: 'app_type', type: 'varchar', length: 255, default: 'admin' })
  app_type: string;

  @Column({ name: 'menu_name', type: 'varchar', length: 32, default: '' })
  menu_name: string;

  @Column({ name: 'menu_short_name', type: 'varchar', length: 50, default: '' })
  menu_short_name: string;

  @Column({ name: 'menu_key', type: 'varchar', length: 255, default: '' })
  menu_key: string;

  @Column({ name: 'parent_key', type: 'varchar', length: 255, default: '' })
  parent_key: string;

  @Column({ name: 'menu_type', type: 'tinyint', default: 1 })
  menu_type: number;

  @Column({ name: 'icon', type: 'varchar', length: 500, default: '' })
  icon: string;

  @Column({ name: 'api_url', type: 'varchar', length: 100, default: '' })
  api_url: string;

  @Column({ name: 'router_path', type: 'varchar', length: 128, default: '' })
  router_path: string;

  @Column({ name: 'view_path', type: 'varchar', length: 255, default: '' })
  view_path: string;

  @Column({ name: 'methods', type: 'varchar', length: 10, default: '' })
  methods: string;

  @Column({ name: 'sort', type: 'int', default: 1 })
  sort: number;

  @Column({ name: 'status', type: 'tinyint', unsigned: true, default: 1 })
  status: number;

  @Column({ name: 'is_show', type: 'tinyint', default: 1 })
  is_show: number;

  @Column({ name: 'is_del', type: 'tinyint', default: 0 })
  is_del: number;

  @CreateDateColumn({ name: 'create_time', type: 'int' })
  create_time: number;

  @UpdateDateColumn({ name: 'update_time', type: 'int' })
  update_time: number;

  @Column({ name: 'delete_time', type: 'int', default: 0 })
  delete_time: number;

  @Column({ name: 'addon', type: 'varchar', length: 255, default: '' })
  addon: string;

  @Column({ name: 'source', type: 'varchar', length: 255, default: 'system' })
  source: string;

  @Column({ name: 'menu_attr', type: 'varchar', length: 50, default: '' })
  menu_attr: string;

  @Column({ name: 'parent_select_key', type: 'varchar', length: 255, default: '' })
  parent_select_key: string;

  // 业务逻辑方法 - 与 PHP 项目保持一致
  getStatusText(): string {
    const statusMap: { [key: number]: string } = { 0: '禁用', 1: '正常' };
    return statusMap[this.status] || '未知';
  }

  getMenuTypeText(): string {
    const menuTypes: { [key: number]: string } = { 0: '目录', 1: '菜单', 2: '按钮' };
    return menuTypes[this.menu_type] || '未知';
  }

  getMenuShortNameText(): string {
    return this.menu_short_name || this.menu_name;
  }
} 