package com.ylx.merchant.domain.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
@ApiModel("客户端商户详情vo")
public class MerchantDetailVO implements Serializable {
    private static final long serialVersionUID = 119264984492021349L;

    @ApiModelProperty("商户id")
    private Integer id;

    @ApiModelProperty(name = "商户姓名")
    private String name;

    @ApiModelProperty(name = "商户昵称")
    private String nickName;

    @ApiModelProperty("商户头像")
    private String avatar;

    @ApiModelProperty(name = "商户形象照")
    private List<String> headshots;

    @ApiModelProperty(name = "商户生活照")
    private List<String> lifestyles;

    @JsonIgnore
    @ApiModelProperty(name = "商户形象照")
    private String headshotStr;

    @JsonIgnore
    @ApiModelProperty(name = "商户生活照")
    private String lifestyleStr;

    @ApiModelProperty(name = "商户背景")
    private String background;

    @ApiModelProperty(name = "商户简介")
    private String brief;

    @ApiModelProperty("距离：千米")
    private BigDecimal distance;

    @ApiModelProperty("商户评分")
    private Double score;

    @ApiModelProperty("是否收藏")
    private boolean collected;

    public List<String> getHeadshots() {
        return convertToList(this.headshotStr);
    }

    public List<String> getLifestyles() {
        return convertToList(this.lifestyleStr);
    }

    private List<String> convertToList(String str) {
        if (str == null || str.isEmpty()) {
            return new ArrayList<>();
        }
        return Arrays.asList(str.split(","));
    }

}
