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

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import com.yonge.cooleshow.biz.dal.entity.LiveBroadcastRoomData;
import com.yonge.cooleshow.biz.dal.wrapper.liveroom.LiveBroadcastRoomDataWrapper;
import com.yonge.cooleshow.biz.dal.mapper.LiveBroadcastRoomDataMapper;
import com.yonge.cooleshow.biz.dal.service.LiveBroadcastRoomDataService;

/**
 * 直播房间数据表
 * 2023-08-15 15:50:17
 */
@Slf4j
@Service
public class LiveBroadcastRoomDataServiceImpl extends ServiceImpl<LiveBroadcastRoomDataMapper, LiveBroadcastRoomData> implements LiveBroadcastRoomDataService {

	/**
     * 查询详情
     * @param id 详情ID
     * @return LiveBroadcastRoomData
     */
	@Override
    public LiveBroadcastRoomData detail(Long id) {
        
        return baseMapper.selectById(id);
    }
    
    /**
     * 分页查询
     * @param page IPage<LiveBroadcastRoomData>
     * @param query LiveBroadcastRoomDataWrapper.LiveBroadcastRoomDataQuery
     * @return IPage<LiveBroadcastRoomData>
     */
    @Override
    public IPage<LiveBroadcastRoomData> selectPage(IPage<LiveBroadcastRoomData> page, LiveBroadcastRoomDataWrapper.LiveBroadcastRoomDataQuery query) {
        
        return page.setRecords(baseMapper.selectPage(page, query));
    }
	
    /**
     * 添加
     * @param liveBroadcastRoomData LiveBroadcastRoomDataWrapper.LiveBroadcastRoomData
     * @return Boolean
     */
    @Override
    public Boolean add(LiveBroadcastRoomDataWrapper.LiveBroadcastRoomData liveBroadcastRoomData) {    	
        
        return this.save(JSON.parseObject(liveBroadcastRoomData.jsonString(), LiveBroadcastRoomData.class));
    }

    /**
     * 更新
     * @param liveBroadcastRoomData LiveBroadcastRoomDataWrapper.LiveBroadcastRoomData
     * @return Boolean
     */
    @Override
    public Boolean update(LiveBroadcastRoomDataWrapper.LiveBroadcastRoomData liveBroadcastRoomData){

        return this.updateById(JSON.parseObject(liveBroadcastRoomData.jsonString(), LiveBroadcastRoomData.class));       
    }
}