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

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

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

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 直播间人员关系表
 * 2023-08-15 15:50:17
 */
@ApiModel(value = "ImLiveBroadcastRoomMemberWrapper对象", description = "直播间人员关系表查询对象")
public class ImLiveBroadcastRoomMemberWrapper {

    @Data
	@Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" ImLiveBroadcastRoomMemberQuery-直播间人员关系表")
    public static class ImLiveBroadcastRoomMemberQuery implements QueryInfo {
    
    	@ApiModelProperty("当前页")
        private Integer page;
        
        @ApiModelProperty("分页行数")
        private Integer rows;
        
        @ApiModelProperty("关键字匹配")
		private String keyword;
        
        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }
        
        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static ImLiveBroadcastRoomMemberQuery from(String json) {
            return JSON.parseObject(json, ImLiveBroadcastRoomMemberQuery.class);
        }
    }  

    @Data
	@ApiModel(" ImLiveBroadcastRoomMember-直播间人员关系表")
    public static class ImLiveBroadcastRoomMember {


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

        @ApiModelProperty(value = "房间标题")
        private String roomTitle;

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

        @ApiModelProperty(value = "学生编号")
        private Integer studentId;

        @ApiModelProperty(value = "学生姓名")
        private String studentName;

        @ApiModelProperty(value = "学生头像")
        private String avatar;

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

        @ApiModelProperty(value = "声部名称")
        private String subName;

        @ApiModelProperty(value = "进入房间时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private Date joinTime;

        @ApiModelProperty(value = "累计观看时长")
        private Integer totalViewTime;

        @ApiModelProperty(value = "连麦状态 0:未申请1:申请连麦中2:连麦中")
        private Integer whetherMicStatus;

        @ApiModelProperty(value = "是否黑名单")
        private boolean blackFlag;

        @ApiModelProperty("游客凭据")
        private String fingerprint;

        @ApiModelProperty(value = "是否能上麦:false否；true是")
        private boolean microphoneFlag;
        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static ImLiveBroadcastRoomMember from(String json) {
            return JSON.parseObject(json, ImLiveBroadcastRoomMember.class);
        }
	}

    @Data
    public static class RoomMemberNumDto {

        private String roomUid;

        private Integer onlineNum;

        private Integer totalNum;
    }


    @Data
    public static class RoomUserInfoVo extends LiveRoomWrapper.BaseRoomUserVo implements Serializable {

        //累计观看时长
        private Integer totalViewTime;

        //首次进入时间
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private Date firstJoinTime;

        //动态观看直播时间  主播每次开启直播后更新
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private Date dynamicLookTime;

        @ApiModelProperty("用户头象")
        private String avatar;
    }
}