package com.izouma.zhirongip.domain.resource;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.izouma.zhirongip.annotations.Searchable;
import com.izouma.zhirongip.annotations.SearchableOne;
import com.izouma.zhirongip.converter.LongArrayConverter;
import com.izouma.zhirongip.converter.NumOfIpListConverter;
import com.izouma.zhirongip.domain.BaseEntity;
import com.izouma.zhirongip.dto.CompanyDTO;
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.*;
import java.time.LocalDateTime;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "参数设置")
@Where(clause = "del = 0")
public class Company extends BaseEntity {
    @ExcelIgnore
    @ApiModelProperty(value = "企业性质")
    private Long settingId;

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

    @Searchable
    @SearchableOne
    @ApiModelProperty(value = "企业名称")
    private String name;

    @SearchableOne
    @ApiModelProperty(value = "所属地区")
    private String owner;

    @ExcelIgnore
    private String img;

    @ExcelIgnore
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "企业简介")
    private String manual;

    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty(value = "入库入网")
    private List<Long> network;

    @ApiModelProperty(value = "武器装备科研生产单位保密资格证")
    private boolean confidentialityQualification;

    @ApiModelProperty(value = "级别")
    private Long confidentialityLevel;

    @ApiModelProperty(value = "武器装备质量管理体系认证")
    private boolean certification;

    @ApiModelProperty(value = "武器装备承制单位资格证")
    private boolean unitQualification;

    @ApiModelProperty(value = "级别")
    private Long unitLevel;

    @ApiModelProperty(value = "武器装备科研生产许可证")
    private boolean productionLicence;

    @ApiModelProperty(value = "类别")
    private Long productionLevel;

    @ApiModelProperty(value = "涉密信息系统集成")
    private boolean systemIntegration;

    @ApiModelProperty(value = "级别")
    private Long integrationLevel;

    @ApiModelProperty(value = "高新技术企业")
    private boolean highTech;

    @ApiModelProperty(value = "知识产权数量")
    @Convert(converter = NumOfIpListConverter.class)
    private List<NumOfIp> numOfIps;

    @ApiModelProperty(value = "知识产权贯标")
    private boolean standardization;

    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty(value = "级别")
    private List<Long> standardizationLevel;

    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty(value = "企业技术资质")
    private List<Long> qualificationLevel;

    @ApiModelProperty(value = "联系人")
    private String contact;

    @ApiModelProperty(value = "电话")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @ApiModelProperty(value = "官网地址")
    private String url;

    @ApiModelProperty(value = "信息更新时间")
    private LocalDateTime updateAt;

    @Transient
    private String fieldName;

    @Transient
    private String settingName;

    public Company(CompanyDTO dto) {
        BeanUtil.copyProperties(dto, this);
    }
}
