package com.izouma.nineth.dto;

import cn.hutool.core.bean.BeanUtil;
import com.izouma.nineth.domain.Asset;
import com.izouma.nineth.domain.Collection;
import com.izouma.nineth.domain.PreEmptionPrivilege;
import com.izouma.nineth.domain.User;
import com.izouma.nineth.enums.AssetStatus;
import com.izouma.nineth.enums.BuyCollectionStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;

@Data
public class CollectionDTO extends Collection {


    public CollectionDTO(){

    }

    public CollectionDTO(Collection obj, Asset asset, User user) {
        BeanUtil.copyProperties(obj, this);
        if(asset != null){
            this.userId  = asset.getUserId();
            this.officialCollectionId = asset.getCollectionId();
            this.number = asset.getNumber();
            this.assetStatus = asset.getStatus();
        }
        if(user != null){
            this.phone = user.getPhone();
            this.nickname = user.getNickname();
        }
    }

    private boolean liked;
    private boolean appointment;
    /**
     * 是否可以提前购买
     */
    private boolean isforwardBuying;

    /**
     * 是否伪装
     */
    private boolean impose;

    /**
     * 优先购
     */
    private PreEmptionPrivilege preEmptionPrivilege;

    @ApiModelProperty("官方藏品ID")
    private Long officialCollectionId;

    /**
     * 关联的用户
     */
    @ApiModelProperty("用户ID")
    private Long userId;
    @ApiModelProperty("用户手机号")
    private String phone;
    @ApiModelProperty("用户昵称")
    private String nickname;
    @ApiModelProperty("产品编号")
    private Integer number;
    @ApiModelProperty("资产状态")
    private AssetStatus assetStatus;

    /**
     * 是否可购买
     */
    @Enumerated(EnumType.STRING)
    private BuyCollectionStatus buyCollectionStatus;
}
