package com.gyee.wisdom.dao.sql.system.entity;

import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.system.model.DataDictionary;
import com.gyee.wisdom.dao.sql.ModelConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;

/**
 *Author:Wanghs
 */

@Data
@NoArgsConstructor
@ToString
@EqualsAndHashCode()
@Entity
@Table(name = ModelConstants.DATA_DICTIONARY)
public class DataDictionaryEntity implements ToData<DataDictionary>{

    //编号（主键）
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = ModelConstants.ID_)
    private int id;

    //类型
    @Column(name = ModelConstants.CATEGORY_)
    private String category;

    //编码
    @Column(name = ModelConstants.CODE_)
    private String code;

    //名称
    @Column(name = ModelConstants.NAME_)
    private String name;


    //显示顺序
    @Column(name = ModelConstants.ORDER_NO)
    private int orderNo;

    //是否可用
    @Column(name = ModelConstants.ENABLED_)
    private boolean enabled;

    public DataDictionaryEntity( DataDictionary data)
    {
        this.id=data.getId();
        this.category=data.getCategory();
        this.code=data.getCode();
        this.name=data.getName();
        this.orderNo=data.getOrderNo();
        this.enabled=data.isEnabled();
    }

    @Override
    public DataDictionary toData() {
        DataDictionary data=new DataDictionary();
        data.setId(this.id);
        data.setCategory(this.category);
        data.setCode(this.code);
        data.setName(this.name);
        data.setOrderNo(this.orderNo);
        data.setEnabled(this.enabled);
        return data;

    }
}
