package com.izouma.nineth.domain;

import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.converter.LongArrayConverter;
import com.izouma.nineth.dto.GeneralDTO;
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.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.time.LocalDateTime;
import java.util.List;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("兑换券")
public class Coupon extends BaseEntity {

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

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

    @ApiModelProperty("指定藏品")
    private boolean limited;

    @ApiModelProperty("需要支付GAS")
    private boolean needGas;

    @Convert(converter = LongArrayConverter.class)
    @Column(columnDefinition = "TEXT")
    private List<Long> collectionIds;

    private LocalDateTime expiration;

    private int projectId;

    @Transient
    private List<GeneralDTO> collections;
}
