package com.nokia.tsl_data.entity;

import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.Instant;

@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "sys_data_dictionary", schema = "tsl_data")
public class SysDataDictionary {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // 类型名
    @Column(name = "type", columnDefinition = "varchar(50)")
    private String type;

    // 真实码
    @Column(name = "real_code", columnDefinition = "varchar(50)")
    private String realCode;

    // 真实名
    @Column(name = "real_name", columnDefinition = "varchar(100)")
    private String realName;

    // 其他码
    @Column(name = "nick_code", columnDefinition = "varchar(50)")
    private String nickCode;

    // 其他名
    @Column(name = "nick_name", columnDefinition = "varchar(100)")
    private String nickName;

    // 用于排序
    @Column(name = "ord", columnDefinition = "int4")
    private Integer ord;

    @OneToOne
    @JoinColumn(name = "parent_id", referencedColumnName = "id")
    private SysDataDictionary parent;

    @CreatedDate
    private Instant createDate;

    @LastModifiedDate
    private Instant lastUpdateDate;
}
