package com.game.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.game.business.mapper.LiveLiveMapper;
import com.game.business.domain.LiveLive;
import com.game.business.service.ILiveLiveService;
import com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;

/**
 * 直播管理Service业务层处理
 *
 * @author game
 * @date 2024-08-30
 */
@Service
public class LiveLiveServiceImpl extends ServiceImpl<LiveLiveMapper, LiveLive> implements ILiveLiveService {
    @Autowired
    private LiveLiveMapper liveLiveMapper;

    /**
     * 查询直播管理
     *
     * @param id 直播管理主键
     * @return 直播管理
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public LiveLive selectLiveLiveById(Long id) {
        return liveLiveMapper.selectLiveLiveById(id);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public LiveLive selectLiveLiveByUserId(Long userId) {
        LambdaQueryWrapper<LiveLive> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(LiveLive::getUserId, userId);
        return liveLiveMapper.selectOne(queryWrapper);
    }

    /**
     * 查询直播管理列表
     *
     * @param liveLive 直播管理
     * @return 直播管理
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<LiveLive> selectLiveLiveList(LiveLive liveLive) {
        return liveLiveMapper.selectLiveLiveList(liveLive);
    }

    /**
     * 新增直播管理
     *
     * @param liveLive 直播管理
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int insertLiveLive(LiveLive liveLive) {
            return liveLiveMapper.insertLiveLive(liveLive);
    }

    /**
     * 修改直播管理
     *
     * @param liveLive 直播管理
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int updateLiveLive(LiveLive liveLive) {
        return liveLiveMapper.updateLiveLive(liveLive);
    }

    /**
     * 批量删除直播管理
     *
     * @param ids 需要删除的直播管理主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteLiveLiveByIds(Long[] ids) {
        return liveLiveMapper.deleteLiveLiveByIds(ids);
    }

    /**
     * 删除直播管理信息
     *
     * @param id 直播管理主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteLiveLiveById(Long id) {
        return liveLiveMapper.deleteLiveLiveById(id);
    }
}