package com.yonge.cooleshow.student.io.request;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yonge.cooleshow.biz.dal.enums.MK;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * Created by Eric.Shang on 2022/9/22.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LiveRoomVO implements Serializable {

    @ApiModelProperty(value = "课程组id")
    private Long courseGroupId;

    @ApiModelProperty(value = "课程id")
    private Long courseId;

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

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

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

    @ApiModelProperty(value = "直播开始时间")
    @JsonFormat(pattern = MK.TIME_PATTERN, timezone = MK.TIME_ZONE)
    private Date liveStartTime;

    @ApiModelProperty(value = "直播结束时间")
    @JsonFormat(pattern = MK.TIME_PATTERN, timezone = MK.TIME_ZONE)
    private Date liveEndTime;

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

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

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

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

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

    @ApiModelProperty(value = "直播老师信息")
    private UserInfo teacher;

    @ApiModelProperty(value = "分享同学信息")
    private UserInfo student;

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

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

        @ApiModelProperty("用户名")
        private String username;

        @ApiModelProperty("手机号")
        private String phone;

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

        @ApiModelProperty("真实姓名")
        private String realName;
    }
}
