package com.game.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;

import com.game.business.domain.AppGameLottery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.game.business.mapper.AppGameLotteryHistoryMapper;
import com.game.business.domain.AppGameLotteryHistory;
import com.game.business.service.IAppGameLotteryHistoryService;
import com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;

/**
 * 游戏开奖记录（备份）Service业务层处理
 *
 * @author game
 * @date 2025-01-09
 */
@Service
public class AppGameLotteryHistoryServiceImpl extends ServiceImpl<AppGameLotteryHistoryMapper, AppGameLotteryHistory> implements IAppGameLotteryHistoryService {
    @Autowired
    private AppGameLotteryHistoryMapper appGameLotteryHistoryMapper;

    /**
     * 查询游戏开奖记录（备份）
     *
     * @param id 游戏开奖记录（备份）主键
     * @return 游戏开奖记录（备份）
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public AppGameLotteryHistory selectAppGameLotteryHistoryById(Long id) {
        return appGameLotteryHistoryMapper.selectAppGameLotteryHistoryById(id);
    }

    /**
     * 查询游戏开奖记录（备份）列表
     *
     * @param appGameLotteryHistory 游戏开奖记录（备份）
     * @return 游戏开奖记录（备份）
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<AppGameLotteryHistory> selectAppGameLotteryHistoryList(AppGameLotteryHistory appGameLotteryHistory) {
        return appGameLotteryHistoryMapper.selectAppGameLotteryHistoryList(appGameLotteryHistory);
    }

    /**
     * 新增游戏开奖记录（备份）
     *
     * @param appGameLotteryHistory 游戏开奖记录（备份）
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int insertAppGameLotteryHistory(AppGameLotteryHistory appGameLotteryHistory) {
            return appGameLotteryHistoryMapper.insertAppGameLotteryHistory(appGameLotteryHistory);
    }

    /**
     * 修改游戏开奖记录（备份）
     *
     * @param appGameLotteryHistory 游戏开奖记录（备份）
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int updateAppGameLotteryHistory(AppGameLotteryHistory appGameLotteryHistory) {
        return appGameLotteryHistoryMapper.updateAppGameLotteryHistory(appGameLotteryHistory);
    }

    /**
     * 批量删除游戏开奖记录（备份）
     *
     * @param ids 需要删除的游戏开奖记录（备份）主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteAppGameLotteryHistoryByIds(Long[] ids) {
        return appGameLotteryHistoryMapper.deleteAppGameLotteryHistoryByIds(ids);
    }

    /**
     * 删除游戏开奖记录（备份）信息
     *
     * @param id 游戏开奖记录（备份）主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteAppGameLotteryHistoryById(Long id) {
        return appGameLotteryHistoryMapper.deleteAppGameLotteryHistoryById(id);
    }

    @Override
    public AppGameLotteryHistory selectLottery(Long classId, Long gameId, String gameDate) {
        LambdaQueryWrapper<AppGameLotteryHistory> queryLotteryWrapper = Wrappers.lambdaQuery();;
        queryLotteryWrapper.eq(AppGameLotteryHistory::getClassId, classId);
        queryLotteryWrapper.eq(AppGameLotteryHistory::getGameId, gameId);
        queryLotteryWrapper.eq(AppGameLotteryHistory::getGameDate, gameDate);
        return appGameLotteryHistoryMapper.selectOne(queryLotteryWrapper);
    }
}