package com.izouma.nineth.domain;

import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.enums.ActivityCollectionType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel("活动收集")
public class ActivityCollection extends BaseEntity {
    @ApiModelProperty("活动名称")
    @Searchable
    private String name;

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

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

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

    @ApiModelProperty("藏品数量")
    private int num;

    @ApiModelProperty("剩余数量")
    private int stock;

    @ApiModelProperty("发行数量")
    private int total;

    @ApiModelProperty("领取藏品ID")
    private Long awardCollectionId;

    @ApiModelProperty("领取藏品名称")
    private String awardCollectionName;

    private int projectId;

    @ApiModelProperty("状态 是否可兑换")
    @Transient
    private Boolean collected;

    @ApiModelProperty("类型")
    @Enumerated(EnumType.ORDINAL)
    private ActivityCollectionType type;

    @ApiModelProperty("兑换藏品列表")
    @OneToMany(cascade = {CascadeType.REMOVE,CascadeType.PERSIST})
    @JoinColumn(name = "activity_id")
    private List<AwardActivityCollectionInfo> awardList;

    @ApiModelProperty("要收集的藏品列表")
    @OneToMany(cascade = {CascadeType.REMOVE,CascadeType.PERSIST})
    @JoinColumn(name = "activity_id")
    private List<ActivityCollectionInfo> activities;

    @ApiModelProperty("活动开始时间")
    private LocalDateTime startTime;

    @ApiModelProperty("活动结束时间")
    private LocalDateTime endTime;

    @ApiModelProperty("需要收集的卡片数")
    private Integer needCollectedNum;

    @ApiModelProperty("活动描述")
    @Column(columnDefinition = "TEXT")
    private String description;

    @Transient
    private List<ActivityCollectionInfo> collectionInfo;
}
