package cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity;

import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillReqSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.BillHistBaseEntity;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng;
import cokr.xit.ens.modules.common.domain.BaseEntity;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;

import javax.persistence.*;

@Entity
@Getter
@ToString
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "ens_bill_his", schema = "", catalog = "", indexes = {
        @Index(name = "idx_bill_his_01", columnList = "linked_uuid, req_se"),
        @Index(name = "idx_bill_his_02", columnList = "bill_uid")
})
@Schema(name = "BillHist")
public class BillHist extends BillHistBaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    @Schema(required = true, title = "PK", example = " ")
    private Long id;

    @Schema(required = false, title = "청구서 유니크 아이디", example = " ")
    @Column(name = "bill_uid", nullable = true, unique = false, length = 45)
    private String billUid;

    @Schema(required = true, title = "청구서구분", example = " ")
    @Column(name = "bill_se", nullable = false, length = 15)
    @Enumerated(EnumType.STRING)
    private BillSeCd billSe;

    @Schema(required = true, title = "요청구분", example = " ")
    @Column(name = "req_se", nullable = false, length = 15)
    @Enumerated(EnumType.STRING)
    private BillReqSeCd reqSe;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "org_cd")
    @Schema(required = false, title = "기관코드", example = " ")
    private OrgMng orgMng;

    @Schema(required = false, title = "연계식별키", example = "")
    @Column(name = "linked_uuid")
    @Setter
    private String linkedUuid;

}
