package com.slodon.b2b2c.vo.video;

import com.slodon.b2b2c.core.constant.VideoConst;
import com.slodon.b2b2c.core.i18n.Language;
import com.slodon.b2b2c.core.util.FileUrlUtil;
import com.slodon.b2b2c.video.pojo.Author;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 *
 * 封装作者VO对象
 * @author wuxy
 */
@Data
public class AuthorVO implements Serializable {

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

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

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

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

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

    @ApiModelProperty("角色:1会员，2商家")
    private Integer roleType;

    @ApiModelProperty("发布权限状态:1-待审核，2-审核通过(正常发布)，3-审核拒绝，4-禁止发布")
    private Integer permissionState;

    @ApiModelProperty("发布权限状态:1-待审核，2-审核通过(正常发布)，3-审核拒绝，4-禁止发布")
    private String permissionStateValue;

    @ApiModelProperty("拒绝理由,禁止理由")
    private String remark;

    @ApiModelProperty("关注数")
    private Integer followNum;

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

    @ApiModelProperty("获赞总数")
    private Integer likeNum;

    @ApiModelProperty("绑定视频数")
    private Integer videoNum;

    @ApiModelProperty("绑定商品数")
    private Integer goodsNum;

    @ApiModelProperty("点赞视频数")
    private Integer likeVideoNum;

    @ApiModelProperty("会员等级")
    private Integer grade;

    @ApiModelProperty("会员积分")
    private Integer integral;

    public AuthorVO(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.roleType = author.getRoleType();
        this.permissionState = author.getPermissionState();
        this.permissionStateValue = dealPermissionStateValue(author.getPermissionState());
        this.remark = author.getRemark();
        this.followNum = author.getFollowNum();
        this.fansNum = author.getFansNum();
        this.likeNum = author.getLikeNum();
        this.videoNum = author.getVideoNum();
        this.goodsNum = author.getGoodsNum();
        this.likeVideoNum = author.getLikeVideoNum();
        this.grade = author.getGrade();
        this.integral = author.getIntegral();
    }

    public static String dealPermissionStateValue(Integer permissionState) {
        String value = "";
        if (StringUtils.isEmpty(permissionState)) {
            return null;
        }
        switch (permissionState) {
            case VideoConst.PERMISSION_STATE_1:
                value = "待审核";
                break;
            case VideoConst.PERMISSION_STATE_2:
                value = "正常";
                break;
            case VideoConst.PERMISSION_STATE_3:
                value = "审核拒绝";
                break;
            case VideoConst.PERMISSION_STATE_4:
                value = "禁止";
                break;
            default:
                break;
        }
        //翻译
        value = Language.translate(value);
        return value;
    }
}
