package com.eshore.gringotts.web.domain.base.entity;

import com.eshore.gringotts.web.domain.entity.CheckOrder;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@Setter
@ToString
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class CheckingNeededEntity extends LogicDeleteEntity {
    private String description;

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private State state = State.DRAFT;

    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @ToString.Exclude
    private CheckOrder order;

    public enum State {
        /**
         * 无确权
         */
        NONE,
        /**
         * 草稿
         */
        DRAFT,
        /**
         * 审查中
         */
        CHECKING,
        /**
         * 用户审核
         */
        OWNER_CHECKING,
        /**
         * 正常
         */
        NORMAL,
        /**
         * 驳回
         */
        REJECT,
    }
}
