package com.yonge.cooleshow.biz.dal.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yonge.cooleshow.biz.dal.enums.InOrOutEnum;
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yonge.cooleshow.biz.dal.entity.LiveBroadcastRoomMember;
import com.yonge.cooleshow.biz.dal.vo.LiveBroadcastRoomMemberVo;
import com.yonge.cooleshow.biz.dal.dto.search.LiveBroadcastRoomMemberSearch;
import com.yonge.cooleshow.biz.dal.dao.LiveBroadcastRoomMemberDao;
import com.yonge.cooleshow.biz.dal.service.LiveBroadcastRoomMemberService;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


@Service
public class LiveBroadcastRoomMemberServiceImpl extends ServiceImpl<LiveBroadcastRoomMemberDao, LiveBroadcastRoomMember> implements LiveBroadcastRoomMemberService {
    private final static Logger log = LoggerFactory.getLogger(LiveBroadcastRoomMemberServiceImpl.class);

	@Override
    public LiveBroadcastRoomMemberVo detail(Long id) {
        return baseMapper.detail(id);
    }
    
    @Override
    public IPage<LiveBroadcastRoomMemberVo> selectPage(IPage<LiveBroadcastRoomMemberVo> page, LiveBroadcastRoomMemberSearch query){
        return page.setRecords(baseMapper.selectPage(page, query));
    }

    @Override
    @Transactional
    public void saveRecord(String roomUid, Long userId, InOrOutEnum inOrOut, YesOrNoEnum speaker) {
        LiveBroadcastRoomMember liveBroadcastRoomMember = new LiveBroadcastRoomMember();
        liveBroadcastRoomMember.setRoomUid(roomUid);
        liveBroadcastRoomMember.setUserId(userId.intValue());
        liveBroadcastRoomMember.setType(inOrOut.getCode());
        liveBroadcastRoomMember.setSpeaker(speaker.getCode());
        liveBroadcastRoomMember.setJoinTime(new Date());
        this.save(liveBroadcastRoomMember);
    }

}