package com.yonge.cooleshow.biz.dal.wrapper.liveroom;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.microsvc.toolkit.middleware.live.message.LiveRoomConfig;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import com.yonge.cooleshow.common.enums.live.ELiveViewMode;
import com.yonge.cooleshow.common.enums.live.EUseScene;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 直播间详情信息
 * Created by Eric.Shang on 2022/9/22.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LiveRoomWrapper implements Serializable {

    // 课程组id
    private Long courseGroupId;
    // 课程id
    private Long courseId;
    // 主讲人id/老师id
    private Long speakerId;
    // 房间编号
    private String roomUid;
    private String roomTitle;
    private Date liveStartTime;
    private Date liveEndTime;
    private String liveRemark;
    private Integer liveState;
    private Integer roomState;
    private String type;
    private String coverPic;

    // 直播老师信息
    private UserInfo teacher;

    // 分享同学信息
    private UserInfo student;

    public static LiveRoomWrapper from(String jsonString) {
        return JSON.parseObject(jsonString, LiveRoomWrapper.class);
    }

    public String jsonString() {
        return JSON.toJSONString(this);
    }

    public LiveRoomWrapper teacher(UserInfo teacher) {
        this.teacher = teacher;
        return this;
    }

    public LiveRoomWrapper student(UserInfo student) {
        this.student = student;
        return this;
    }


    /**
     * 直播间老师信息
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class UserInfo implements Serializable {

        private String username;
        private String phone;
        private String avatar;
        private String realName;
    }


    /**
     * 直播间老师信息
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class LiveRoomVo implements Serializable {
        @ApiModelProperty(value = "主键")
        private Integer id;

        @ApiModelProperty(value = "房间编号")
        private String roomUid;

        @ApiModelProperty(value = "房间标题/最多12个字")
        private String roomTitle;

        @ApiModelProperty(value = "直播内容/最多200个字")
        private String liveRemark;

        @ApiModelProperty(value = "主讲人id/老师id")
        private Long speakerId;

        @ApiModelProperty(value = "主讲人id/老师id")
        private String speakerImUserId;

        @ApiModelProperty("用户类型 TEACHER 老师")
        private ClientEnum clientType;

        @ApiModelProperty(value = "主讲人名称")
        private String speakerName;

        @ApiModelProperty(value = "主讲人头像")
        private String speakerPic;

        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @ApiModelProperty(value = "直播开始时间")
        private Date liveStartTime;

        @ApiModelProperty(value = "直播状态 0未开始 1开始 2结束")
        private Integer liveState;

        @ApiModelProperty(value = "直播时长")
        private Integer liveTotalTime;

        @ApiModelProperty(value = "房间状态 0正常 1已删除")
        private Integer roomState;

        @ApiModelProperty(value = "创建人")
        private String createdByName;

        @ApiModelProperty(value = "预热模版")
        private String preTemplate;

        @ApiModelProperty(value = "房间配置json格式-是否允许点赞-是否允许聊天互动-是否允许保存直播回放")
        private String roomConfig;

        @ApiModelProperty(value = "imToken")
        private String imToken;

        @ApiModelProperty(value = "播出端-  pc网页端 移动端mobile")
        private String os;

        @ApiModelProperty(value = "是否在首页推广 0否 1是 - 每个机构只能有一个直播间在首页推广")
        private Integer popularize;

        @ApiModelProperty(value = "是否预约过该直播间 0否 1是")
        private Integer reserve;

        @ApiModelProperty(value = "当前登录人是否是黑名单用户 0否 1是")
        private Integer blacklistFlag = 0;

        @ApiModelProperty(value = "直播间可见类型-全部可见 ALL / 部分可见 PRIVATE")
        private String popularizeType;

        @ApiModelProperty(value = "点赞数")
        private Integer likeNum;
        @ApiModelProperty(value = "当前观看人数")
        private Integer lookNum;
        @ApiModelProperty(value = "累计观看人数")
        private Integer totalLookNum;

        @ApiModelProperty("预约人数")
        private Integer roomReservationNum;

        @ApiModelProperty("直播间用户签名")
        private String userSig;


        @ApiModelProperty(value = "服务提供方 ")
        private String serviceProvider;

        @ApiModelProperty("直播配置")
        private LiveRoomConfig liveRoomConfig;

        @ApiModelProperty(value = "主播状态: 0离开;1在播")
        private Integer speakerStatus;

        @ApiModelProperty(value = "推流状态: 0 暂停; 1在播")
        private Integer pushStatus;

        @ApiModelProperty(value = "禁言状态: 0 取消；1禁言")
        private Integer banStatus;

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

        @ApiModelProperty("直播观看模式")
        private ELiveViewMode viewMode;

        @ApiModelProperty(value = "购物车地址")
        private String shopCarUrl;

        @ApiModelProperty("使用场景 正常：NORMAL 音乐：MUSIC")
        private EUseScene useScene;

        @ApiModelProperty("直播类型 NORMAL:普通直播  LIVE:直播课直播")
        private String  groupType;


        @TableField("video_record_")
        @ApiModelProperty(value = "录制记录")
        private String videoRecord;


        @TableField("live_end_time_")
        @ApiModelProperty(value = "直播结束时间")
        private Date liveEndTime;

        @TableField("type_")
        @ApiModelProperty(value = "房间类型 live直播课  temp临时直播间")
        private String type;


        @ApiModelProperty(value = "封面图片")
        private String coverPic;

    }

    @Data
    public static class BaseRoomUserVo implements Serializable {

        private Long userId;

        private String userName;
    }

}
