package com.izouma.zhirongip.domain.demand;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.zhirongip.annotations.EnumFormat;
import com.izouma.zhirongip.converter.LongArrayConverter;
import com.izouma.zhirongip.domain.BaseEntity;
import com.izouma.zhirongip.enums.LoanTerm;
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;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "资金")
@Where(clause = "del = 0")
public class Funding extends BaseEntity {
    @ExcelIgnore
    private Long userId;

    @ExcelProperty("拟融资额")
    @ApiModelProperty(value = "拟融资额")
    private String amount;

    @EnumFormat(value = LoanTerm.class,
            fromExcel = {"3个月以下", "3-6个月", "6个月-1年", "1-2年"},
            toJavaEnum = {"UNDER_THREE_MONTHS", "THREE_SIX_MONTHS", "SIX_MONTHS_ONE_YEAR", "ONE_TWO_YEARS"})
    @ExcelProperty(value = "转移转化方式", converter = EnumExcelConverter.class)
    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "期望贷款期限")
    private LoanTerm loanTerm;

    /*
    flag-5
     */
    @ExcelIgnore
    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty(value = "融资目的")
    private List<Long> purpose;

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

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

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

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

    @Transient
    private List<String> purposeName;

}
