package com.izouma.nineth.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.converter.LongArrayConverter;
import com.izouma.nineth.converter.StringArrayConverter;
import com.izouma.nineth.enums.AirDropType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;

@Data
@Entity
@Table(name = "air_drop", indexes = {
        @Index(columnList = "name")
})
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("空投")
public class AirDrop extends BaseEntity {

    @ApiModelProperty("空投名称")
    @Searchable
    private String name;

    @ApiModelProperty("备注")
    private String remark;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty("空投类型")
    private AirDropType type;

    @ApiModelProperty("兑换券ID")
    private Long couponId;

    @ApiModelProperty("藏品ID")
    private Long collectionId;

    @ApiModelProperty("惊喜盒子ID")
    private Long surpriseBoxId;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = StringArrayConverter.class)
    @ApiModelProperty("手机号")
    private List<String> phone;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty("用户ID")
    private List<Long> userIds;

    @Column(columnDefinition = "TEXT")
    private String result;

    private int projectId;

    /**
     * 操作内容
     */
    private String operation;

    /**
     * 投放价格（操作需要标记为出售）
     */
    @Column(precision = 10, scale = 2)
    private BigDecimal dropPrice;

    /**
     * 成功投放数量
     */
    private Integer dropCount;

    /**
     * 是否保存空投记录
     */
    @Transient
    @JsonIgnore
    private boolean notSave;

    @Transient
    @JsonIgnore
    private Asset asset;
}
