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

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * 直播间详情信息
 * 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;
    }
}
