package com.izouma.zhirongip.domain.supply;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.zhirongip.annotations.EnumFormat;
import com.izouma.zhirongip.annotations.Searchable;
import com.izouma.zhirongip.converter.LongArrayConverter;
import com.izouma.zhirongip.converter.StringArrayConverter;
import com.izouma.zhirongip.domain.BaseEntity;
import com.izouma.zhirongip.enums.ApplyStatus;
import com.izouma.zhirongip.enums.AreaOfAffiliation;
import com.izouma.zhirongip.utils.excel.EnumExcelConverter;
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.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@Entity
@ApiModel(value = "技术经理人")
@Where(clause = "del = 0")
public class TechnicalManager extends BaseEntity {
    @ExcelIgnore
    private Long userId;

    @ExcelProperty(value = "照片")
    @ApiModelProperty(value = "照片")
    private String avatar;

    private String sex;

    @Searchable
    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "所在单位")
    private String work;

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

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

//    @ApiModelProperty(value = "主要成果")
//    @Column(columnDefinition = "TEXT")
//    private String keyAchievement;

    @Searchable
    @ExcelIgnore
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "自我介绍")
    private String selfIntroduction;

    /**
     * setting
     */
    @ExcelIgnore
    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty(value = "擅长技术领域")
    private List<Long> field;

    @ExcelIgnore
    @Column(columnDefinition = "TEXT")
    @Convert(converter = StringArrayConverter.class)
    @ApiModelProperty(value = "资质")
    private List<String> qualification;

    @Transient
    private List<String> fieldName;

    /*
    专家
     */
//    @EnumFormat(value = AreaOfAffiliation.class,
//            fromExcel = {"知识产权", "国防科工"},
//            toJavaEnum = {"INTELLECTUAL_PROPERTY", "NATIONAL_DEFENCE"})
//    @ExcelProperty(value = "所属领域", converter = EnumExcelConverter.class)
//    @Enumerated(EnumType.STRING)
//    @ApiModelProperty(value = "所属领域")
//    private AreaOfAffiliation affiliation;

    /*
    是否专家
     */
    private boolean isExpert;

    @Enumerated(EnumType.STRING)
    private ApplyStatus status;
}
