package com.donglan.ahxf.ahxfmeetregisterwindow.entity;


import com.donglan.ahxf.ahxfmeetregisterwindow.entity.compositekey.DictPrimaryKey;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * @author shj
 * @date 2019-12-30 10:40
 */
@Entity(name = "dictionary")
@Getter
@Setter
@IdClass(DictPrimaryKey.class)
public class Dict {

    @Id
    @Column(name = "dictID")
    private String id;

    @Id
    @Column(name = "dictValue")
    private String value;


    @Column(name = "description")
    private String text;

    @Column(name = "parentValue")
    private String parentId;

    @Column(name = "flag")
    private Integer isDelete;

    @Column(name = "orderNum")
    private Long orderNum;

    @OneToMany(mappedBy = "parentDict")
    @Where(clause = "FLAG=1")
    private List<Dict> childrenList;

    @ManyToOne
    @JsonIgnore
    @JoinColumns ({@JoinColumn(name="dictID",referencedColumnName = "dictID",insertable = false, updatable = false),
    @JoinColumn(name="parentValue",referencedColumnName = "dictValue",insertable = false, updatable = false)})
    private Dict parentDict;

}
