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.ApplyStatus;
import com.izouma.zhirongip.enums.CommissionType;
import com.izouma.zhirongip.enums.CopyrightType;
import com.izouma.zhirongip.enums.TradingMethod;
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 Copyright extends BaseEntity {

    private Long userId;

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

    @ApiModelProperty(value = "登记号")
    private String code;

    @ApiModelProperty(value = "登记日期")
    private LocalDate registrationTime;

    /*
    作品类型-3 软著类型-4
     */
    @ExcelIgnore
    @ApiModelProperty(value = "作品类型/软著类型")
    private Long workType;

    /*
    软著没有作者
     */
    @ApiModelProperty(value = "作者")
    private String author;

    @ApiModelProperty(value = "著作权人")
    private String owner;


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

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

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

    /*
    （万元）
     */
    @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
    @ApiModelProperty(value = "版权/软著")
    @Enumerated(EnumType.STRING)
    private CopyrightType type;

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

    @Enumerated(EnumType.STRING)
    private ApplyStatus status;

    @Transient
    private String workName;
}