package com.izouma.nineth.domain;

import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.converter.FileObjectConverter;
import com.izouma.nineth.converter.LongArrayConverter;
import com.izouma.nineth.enums.ItemType;
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.time.LocalDateTime;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(indexes = {
        @Index(columnList = "minterId"),
        @Index(columnList = "reset"),
        @Index(columnList = "collectionId")
})
@Builder
@Entity
@ApiModel("藏品优先凭证活动")
public class ActivityPriorityDocument extends BaseEntity {

    @ApiModelProperty("活动名称")
    @Searchable
    private String name;

    @Column(columnDefinition = "TEXT")
    @ApiModelProperty("图片")
    private String pic;

    @ApiModelProperty("藏品名称")
    private String collectionName;

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

    @ApiModelProperty("提前购买时间（小时）")
    private int advancePurchaseTime;

    @ApiModelProperty("可提前购买次数")
    private int advancePurchaseCount;

    @ApiModelProperty("第九空间/cosmos")
    private int projectId;

    @Column(columnDefinition = "TEXT")
    @ApiModelProperty("说明")
    private String text;

    @ApiModelProperty("指定生效藏品ID")
    @Searchable
    private Long targetCollectionId;

    @ApiModelProperty("凭证类型")
    private ItemType ItemName;

    @ApiModelProperty("凭证类型")
    public Integer ItemId;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = LongArrayConverter.class)
    @ApiModelProperty("指定生效藏品ID,多藏品")
    public List<Long> targetCollectionIdList;

    @ApiModelProperty("发售完重置次数")
    public boolean reset;

    @ApiModelProperty("铸造者ID,如果是铸造系列")
    public Long minterId;

    @ApiModelProperty("过期时间")
    public LocalDateTime overdueTime;

}
