package com.izouma.zhirongip.domain.resource;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.zhirongip.annotations.Searchable;
import com.izouma.zhirongip.annotations.SearchableOne;
import com.izouma.zhirongip.domain.BaseEntity;
import com.izouma.zhirongip.dto.ProductDTO;
import com.izouma.zhirongip.dto.TechnologyDTO;
import com.izouma.zhirongip.enums.DigitalType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "数据")
@Where(clause = "del = 0")
public class Digital extends BaseEntity {
    /*
    技术区分：包括军转民技术，民参军技术
    企业性质：包括军工单位，民口企业，民营企业
     */
    @ExcelIgnore
    private Long settingId;

    /*
    为新材料、电子信息..
     */
    @ExcelIgnore
    @ApiModelProperty(value = "所属领域")
    private Long field;

    @Transient
    @ExcelProperty(value = "技术区分")
    private String settingName;

    @Transient
    @ExcelProperty(value = "行业领域")
    private String fieldName;


    @Searchable
    @SearchableOne
    @ExcelProperty(value = "技术名称")
    private String name;

    /*
    技术： 成果所有人
    产品： 持有人
    公司： 地区
     */
    @SearchableOne
    @ExcelProperty(value = "技术所属人")
    private String owner;

    @ExcelProperty(value = "附图")
    private String img;

    @Column(columnDefinition = "TEXT")
    @ExcelProperty(value = "描述")
    private String manual;

    @ExcelIgnore
    @Enumerated(EnumType.STRING)
    private DigitalType type;

    public Digital(TechnologyDTO dto) {
        BeanUtil.copyProperties(dto, this);
    }

    public Digital(ProductDTO dto) {
        BeanUtil.copyProperties(dto, this);
    }

}
