package com.ym.mec.biz.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ym.mec.biz.dal.dao.ImLiveBroadcastRoomMemberDao;
import com.ym.mec.biz.dal.entity.ImLiveBroadcastRoomMember;
import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomDetailVo;
import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomMemberVo;
import com.ym.mec.biz.service.ImLiveBroadcastRoomDataService;
import com.ym.mec.biz.service.ImLiveBroadcastRoomMemberService;
import com.ym.mec.biz.service.ImLiveRoomVideoService;
import com.ym.mec.common.page.PageInfo;
import com.ym.mec.common.page.PageUtil;
import com.ym.mec.common.page.WrapperUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 直播间人员关系表(ImLiveBroadcastRoomMember)表服务实现类
 *
 * @author hgw
 * @since 2022-02-21 14:26:59
 */
@Service("imLiveBroadcastRoomMemberService")
public class ImLiveBroadcastRoomMemberServiceImpl extends ServiceImpl<ImLiveBroadcastRoomMemberDao, ImLiveBroadcastRoomMember> implements ImLiveBroadcastRoomMemberService {

    private final static Logger log = LoggerFactory.getLogger(ImLiveBroadcastRoomMemberServiceImpl.class);

    @Autowired
    private ImLiveBroadcastRoomDataService imLiveBroadcastRoomDataService;
    @Autowired
    private ImLiveRoomVideoService imLiveRoomVideoService;

    @Override
    public ImLiveBroadcastRoomMemberDao getDao() {
        return this.baseMapper;
    }

    /**
     * 查询直播详情
     */
    @Override
    public ImLiveBroadcastRoomDetailVo queryRoomDetail(Map<String, Object> param) {
        String roomUid = WrapperUtil.toStr(param, "roomUid", "请传入房间编号");
        ImLiveBroadcastRoomDetailVo vo = imLiveBroadcastRoomDataService.getDao().queryByRoomUid(roomUid);
        vo.setVideoList(imLiveRoomVideoService.queryList(roomUid));
        return vo;
    }

    @Override
    public PageInfo<ImLiveBroadcastRoomMemberVo> queryRoomMember(Map<String, Object> param) {
        Page<ImLiveBroadcastRoomMemberVo> pageInfo = PageUtil.getPageInfo(param);
        return PageUtil.pageInfo(baseMapper.queryMemberPage(pageInfo, param));
    }

}

