import BigNumber from 'bignumber.js'
import { DecimalTransformer } from '../../transformers/decimal.transformer'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'

export enum WithdrawStatus {
    PENDING = 'PENDING',
    SUCCESS = 'SUCCESS',
    REJECTED = 'REJECTED'
}

@Entity()
export class Withdraw {
    constructor(data: Partial<Withdraw>) {
        Object.assign(this, data)
    }

    @PrimaryGeneratedColumn()
    id: number

    @Column()
    userId: number

    @Column({ type: 'decimal', precision: 19, scale: 2, transformer: new DecimalTransformer() })
    amount: BigNumber

    @Column()
    name: string

    @Column()
    account: string

    @Column({ type: 'enum', enum: WithdrawStatus })
    status: WithdrawStatus

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

    @CreateDateColumn()
    createdAt: Date

    @UpdateDateColumn()
    updatedAt: Date
}
