import { BaseModel } from 'src/common/entities/base.entity';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

/**
 * 사용자/관리자 정보 (tb_user)
 */
@Entity({ name: 'tb_user' })
export class UserModel extends BaseModel {
  @PrimaryGeneratedColumn({
    name: 'pk_user_no',
    type: 'int',
    comment: '내부 PK (자동증가)',
  })
  pkUserNo: number;

  @Column({
    name: 'user_id',
    type: 'varchar',
    length: 100,
    nullable: false,
    unique: true,
    comment: '로그인 ID',
  })
  userId: string;

  @Column({
    name: 'user_pw',
    type: 'varchar',
    length: 200,
    nullable: false,
    comment: '비밀번호 (암호화)',
  })
  userPw: string;

  @Column({
    name: 'user_name',
    type: 'varchar',
    length: 100,
    nullable: false,
    comment: '이름',
  })
  userName: string;

  @Column({
    name: 'user_phone',
    type: 'varchar',
    length: 20,
    nullable: true,
    comment: '핸드폰번호',
  })
  userPhone: string;

  @Column({
    name: 'user_email',
    type: 'varchar',
    length: 100,
    nullable: true,
    unique: true,
    comment: '이메일 (인증용)',
  })
  userEmail: string;

  @Column({
    name: 'user_role',
    type: 'varchar',
    length: 20,
    nullable: false,
    default: 'USER',
    comment: '권한 (USER: 일반, ADMIN: 관리자)',
  })
  userRole: 'USER' | 'ADMIN';
}
