package com.izouma.nineth.domain;

import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.converter.FileObjectListConverter;
import com.izouma.nineth.converter.PropertyListConverter;
import com.izouma.nineth.enums.CollectionSource;
import com.izouma.nineth.enums.CollectionType;
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
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("盲盒")
public class BlinkBox extends BaseEntity {

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

    @ApiModelProperty("图片")
    @Column(columnDefinition = "TEXT")
    @Convert(converter = FileObjectListConverter.class)
    private List<FileObject> pics;

    @ApiModelProperty("铸造者")
    @Searchable
    private String minter;

    @ApiModelProperty("铸造者ID")
    private Long minterId;

    @ApiModelProperty("铸造者头像")
    private String minterAvatar;

    @ApiModelProperty("详情")
    @Column(columnDefinition = "TEXT")
    private String detail;

    @ApiModelProperty("类型")
    @Enumerated(EnumType.STRING)
    private CollectionType type;

    @ApiModelProperty("来源")
    @Enumerated(EnumType.STRING)
    private CollectionSource source;

    @ApiModelProperty("已售")
    private int sale;

    @ApiModelProperty("库存")
    private int stock;

    @ApiModelProperty("点赞")
    private int likes;

    @ApiModelProperty("上架")
    private boolean onShelf;

    @ApiModelProperty("可售")
    private boolean salable;

    @ApiModelProperty("价格")
    @Column(precision = 10, scale = 2)
    private BigDecimal price;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = PropertyListConverter.class)
    @ApiModelProperty("特性")
    private List<CollectionProperty> properties;
}
