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.AppGameBetting;
import com.game.business.mapper.AppGameBettingMapper;
import com.game.business.service.IAppGameBettingService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper, AppGameBetting> implements IAppGameBettingService {

    private AppGameBettingMapper appGameBettingMapper;

    @Override
    public List<AppGameBetting> getIsWinning(Long classId, Long gameId, String gameDate, Integer isWinning) {

        LambdaQueryWrapper<AppGameBetting> queryWrapper = Wrappers.lambdaQuery();;
        queryWrapper.eq(AppGameBetting::getClassId, classId);
        queryWrapper.eq(AppGameBetting::getGameId, gameId);
        queryWrapper.eq(AppGameBetting::getGameDate, gameDate);
        queryWrapper.eq(AppGameBetting::getIsWinning, isWinning);
        return appGameBettingMapper.selectList(queryWrapper);

    }

    @Override
    public boolean updateById(AppGameBetting appGameBetting) {
        return appGameBettingMapper.updateById(appGameBetting) > 0;
    }

    @Override
    public boolean save(AppGameBetting appGameBetting) {
        return appGameBettingMapper.insert(appGameBetting) > 0;
    }
}
