package com.slodon.b2b2c.vo.video;

import com.slodon.b2b2c.core.util.FileUrlUtil;
import com.slodon.b2b2c.video.pojo.Author;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 *
 * 封装相关用户搜索VO对象
 * @author wuxy
 */
@Data
@NoArgsConstructor
public class AuthorSearchVO implements Serializable {

    private static final long serialVersionUID = 134612898224764123L;
    @ApiModelProperty("作者id")
    private Integer authorId;

    @ApiModelProperty("会员名称")
    private String memberName;

    @ApiModelProperty("会员昵称")
    private String memberNickname;

    @ApiModelProperty("会员头像")
    private String memberAvatar;

    @ApiModelProperty("简介")
    private String introduction;

    @ApiModelProperty("粉丝数")
    private String fansNum;

    @ApiModelProperty("是否关注")
    private Boolean isFollow = false;

    @ApiModelProperty("是否自己")
    private Boolean isSelf = false;

    public AuthorSearchVO(Author author) {
        this.authorId = author.getAuthorId();
        this.memberName = author.getMemberName();
        this.memberNickname = author.getMemberNickname();
        this.memberAvatar = author.getMemberAvatar().startsWith("http") ? author.getMemberAvatar() : FileUrlUtil.getFileUrl(author.getMemberAvatar(), null);
        this.introduction = author.getIntroduction();
        this.fansNum = author.getFansNum() < 10000 ? author.getFansNum().toString()
                : new BigDecimal(author.getFansNum()).divide(new BigDecimal(10000), 1, RoundingMode.FLOOR) + "w";
    }
}
