package cn.lihongjie.coal.device.entity;

import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import cn.lihongjie.coal.deviceCategory.entity.DeviceCategoryEntity;
import cn.lihongjie.coal.deviceSupplier.entity.DeviceSupplierEntity;
import cn.lihongjie.coal.user.entity.UserEntity;

import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;

import lombok.Data;

import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;

@Data
@Entity
public class DeviceEntity extends OrgCommonEntity {
    

    @Comment("设备型号")
    private String model;


    @Comment("设备参数")

    private String parameter;

    @ManyToOne

    private DeviceSupplierEntity supplier;


    @ManyToOne
    private DeviceCategoryEntity category;



    @Comment("设备位置")
    private String location;


    @ManyToOne

    private UserEntity manager;







    @Comment("归档状态")
    @ColumnDefault("'0'")
    private String archiveStatus = "0";



    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'archiveStatus'\n"
                    + "  and i.code = archive_status)")
    private String archiveStatusName;
}
