import { JsonTransformer } from '../../transformers/json.transformer'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm'

export enum PaperOrderStatus {
    Pending = 'pending',
    Generating = 'generating',
    Complete = 'complete'
}

@Entity()
export class PaperOrder {
    @PrimaryGeneratedColumn()
    id: number

    @CreateDateColumn()
    createdAt: Date

    @Column()
    userId: number

    @Column()
    title: string

    @Column()
    major: string

    @Column({ type: 'text' })
    description: string

    @Column({ nullable: true })
    remark?: string

    @Column({ type: 'enum', enum: PaperOrderStatus, default: PaperOrderStatus.Pending })
    status: PaperOrderStatus

    @Column({ type: 'longtext', nullable: true, transformer: new JsonTransformer() })
    chapters?: any
}
