package com.izouma.jmrh.domain;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.jmrh.annotations.Searchable;
import com.izouma.jmrh.converter.LongArrayConverter;
import com.izouma.jmrh.dto.ExpertDTO;
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.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.time.LocalDate;
import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@Entity
@ApiModel(value = "技术经理人")
public class Expert extends BaseEntity {

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

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

    @ExcelProperty(value = "性别")
    @ApiModelProperty(value = "出生年月")
    private String sex;

    @ExcelProperty(value = "出生年月")
    @ApiModelProperty(value = "出生年月")
    private LocalDate birthday;

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

    @ExcelProperty(value = "学历")
    @Searchable
    @ApiModelProperty(value = "学历")
    private String academicQualification;

    @ExcelProperty(value = "职称")
    @Searchable
    @ApiModelProperty(value = "职称")
    private String jobTitle;

    @ExcelProperty(value = "职位")
    @ApiModelProperty(value = "职位")
    private String position;

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

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

    @ExcelProperty(value = "通讯地址")
    @ApiModelProperty(value = "通讯地址")
    private String address;

    @ExcelIgnore
    @ApiModelProperty(value = "研究方向")
    private Long affiliation;

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

    @Searchable
    @ExcelProperty(value = "个人简介")
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "个人简介")
    private String selfIntroduction;

    @ExcelIgnore
    @Transient
    private List<String> fieldName;

    @ExcelProperty(value = "专业领域")
    private String fieldNames;

    @ExcelProperty(value = "研究方向")
    @Transient
    private String affiliationName;

    public Expert(ExpertDTO dto) {
        BeanUtil.copyProperties(dto, this);
    }

    @Column(columnDefinition = "bit 1 default 0")
    private boolean del = false;
}
