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 com.game.business.domain.AppGameLottery;
import com.game.business.mapper.AppGameLotteryMapper;
import com.game.business.service.IAppGameLotteryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppGameLotteryServiceImpl extends ServiceImpl<AppGameLotteryMapper, AppGameLottery> implements IAppGameLotteryService {

    @Autowired
    private AppGameLotteryMapper appGameLotteryMapper;

    @Override
    public long selectCount(Long classId, Long gameId, String gameDate) {
        LambdaQueryWrapper<AppGameLottery> queryLotteryWrapper = Wrappers.lambdaQuery();;
        queryLotteryWrapper.eq(AppGameLottery::getClassId, classId);
        queryLotteryWrapper.eq(AppGameLottery::getGameId, gameId);
        queryLotteryWrapper.eq(AppGameLottery::getGameDate, gameDate);
        return appGameLotteryMapper.selectCount(queryLotteryWrapper);
    }

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

    @Override
    public boolean save(AppGameLottery appGameLottery) {
        return appGameLotteryMapper.insert(appGameLottery) > 0;
    }

    /**
     * 查询游戏开奖记录
     *
     * @param id 游戏开奖记录主键
     * @return 游戏开奖记录
     */
    @Override
    public AppGameLottery selectAppGameLotteryById(Long id) {
        return appGameLotteryMapper.selectAppGameLotteryById(id);
    }

    /**
     * 查询游戏开奖记录列表
     *
     * @param appGameLottery 游戏开奖记录
     * @return 游戏开奖记录
     */
    @Override
    public List<AppGameLottery> selectAppGameLotteryList(AppGameLottery appGameLottery) {
        return appGameLotteryMapper.selectAppGameLotteryList(appGameLottery);
    }

    /**
     * 新增游戏开奖记录
     *
     * @param appGameLottery 游戏开奖记录
     * @return 结果
     */
    @Override
    public int insertAppGameLottery(AppGameLottery appGameLottery) {
        return appGameLotteryMapper.insertAppGameLottery(appGameLottery);
    }

    /**
     * 修改游戏开奖记录
     *
     * @param appGameLottery 游戏开奖记录
     * @return 结果
     */
    @Override
    public int updateAppGameLottery(AppGameLottery appGameLottery) {
        return appGameLotteryMapper.updateAppGameLottery(appGameLottery);
    }

    /**
     * 批量删除游戏开奖记录
     *
     * @param ids 需要删除的游戏开奖记录主键
     * @return 结果
     */
    @Override
    public int deleteAppGameLotteryByIds(Long[] ids) {
        return appGameLotteryMapper.deleteAppGameLotteryByIds(ids);
    }

    /**
     * 删除游戏开奖记录信息
     *
     * @param id 游戏开奖记录主键
     * @return 结果
     */
    @Override
    public int deleteAppGameLotteryById(Long id) {
        return appGameLotteryMapper.deleteAppGameLotteryById(id);
    }
}
