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.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "技术/产品")
@Where(clause = "del = 0")
public class TechnologyProduct extends BaseEntity {
    @ExcelIgnore
    private Long userId;

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

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

    /*
    技术： 成果所有人
    产品：持有单位
     */
    @ApiModelProperty(value = "成果所属人/持有单位")
    private String owner;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "技术成熟度/所属阶段")
    private Stage stage;

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

    /*
    技术：包括技术指标、技术特点、适用范围、预期效益
    产品：包括产品型能、应用场景、预期效益
     */
    @ExcelIgnore
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "描述")
    private String manual;

    @ApiModelProperty(value = "是否专利技术")
    private boolean isPatented;

    /*
    选择是专利技术时，出现
     */
    @Convert(converter = StringArrayConverter.class)
    @ApiModelProperty(value = "专利号")
    private List<String> patentNo;

    @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 TpType tpType;

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

    @Enumerated(EnumType.STRING)
    private ApplyStatus status;

    @Transient
    private String fieldName;
}
