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.StringArrayConverter;
import com.izouma.zhirongip.domain.BaseEntity;
import com.izouma.zhirongip.enums.*;
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.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "专利")
@Where(clause = "del = 0")
public class Patent extends BaseEntity {

    @ExcelIgnore
    private Long userId;

    @ApiModelProperty(value = "专利名称")
    private String name;

    @ApiModelProperty(value = "申请号")
    private String code;

    /*
    脱密专利没有
     */

    @ExcelIgnore
    @ApiModelProperty(value = "专利类型")
    private String patentType;
    @ApiModelProperty(value = "专利类型")
    private Long patentTypeId;

    @ApiModelProperty(value = "申请日期")
    private LocalDate applyTime;

    /**
     * setting
     */

    @ApiModelProperty(value = "行业分类")
    private Long industryClass;

    @ApiModelProperty(value = "IPC分类号")
    private String ipc;


    @ApiModelProperty(value = "法律状态")
    private String lawStatus;
    @ApiModelProperty(value = "法律状态")
    private Long lawStatusId;

    @ApiModelProperty(value = "申请人")
    @Convert(converter = StringArrayConverter.class)
    private List<String> applicant;

    @ApiModelProperty(value = "专利权人")
    @Convert(converter = StringArrayConverter.class)
    private List<String> owner;

    /*
    脱密专利没有
     */
//    @Enumerated(EnumType.STRING)
//    @ApiModelProperty(value = "专利权人类型")
//    private OwnerType ownerType;

    @ApiModelProperty(value = "发明人")
    @Convert(converter = StringArrayConverter.class)
    private List<String> inventor;

    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "摘要")
    private String digest;

    @Searchable
    @ExcelIgnore
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "权利要求书")
    private String manual;

    @ExcelIgnore
    @Convert(converter = StringArrayConverter.class)
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "专利附图")
    private List<String> img;



    @ApiModelProperty(value = "交易方式")
    private String tradingMethod;

    @ApiModelProperty(value = "交易方式")
    private Long tradingMethodId;

    /*
    （万元）
     */
    @ApiModelProperty(value = "期望价（万元）")
    private BigDecimal expectedPrice;

    @ApiModelProperty(value = "面议")
    private Boolean negotiateDirectly;

    @ApiModelProperty(value = "底价（万元）")
    private BigDecimal basePrice;

    @EnumFormat(value = CommissionType.class,
            fromExcel = {"佣金", "百分比"},
            toJavaEnum = {"COMMISSION", "PERCENTAGE"})
    @ExcelProperty(value = "佣金类型", converter = EnumExcelConverter.class)
    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "佣金类型")
    private CommissionType commissionType;

    @ApiModelProperty(value = "佣金（万元）")
    private BigDecimal commission;

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

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

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

    @ApiModelProperty(value = "所在地区")
    private String address;

    @ExcelIgnore
    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "专利分类")
    private CaseType caseType;

    @ApiModelProperty(value = "浏览量")
    private long view;

    @Enumerated(EnumType.STRING)
    private ApplyStatus status;

    @Transient
    private String industryName;
}