package com.game.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.game.business.domain.AppUserGameRecordCount;
import com.game.business.mapper.AppUserGameRecordCountMapper;
import com.game.business.service.IAppUserGameRecordCountService;
import com.game.business.util.StringUtils;
import com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class AppUserGameRecordCountServiceImpl extends ServiceImpl<AppUserGameRecordCountMapper, AppUserGameRecordCount> implements IAppUserGameRecordCountService {

    @Autowired
    private AppUserGameRecordCountMapper appUserGameRecordCountMapper;

    @Override
    public List<AppUserGameRecordCount> selectByDate(Long userId, String startDate, String endDate,Long gameId,String gameDate) {
        LambdaQueryWrapper<AppUserGameRecordCount> queryWrapper = new LambdaQueryWrapper<>();
        if(null != userId){
            queryWrapper.eq(AppUserGameRecordCount::getUserId, userId);
        }
        if(StringUtils.isNotBlank(startDate)){
            queryWrapper.ge(AppUserGameRecordCount::getCreateTime, startDate);
        }
        if(StringUtils.isNotBlank(endDate)){
            queryWrapper.le(AppUserGameRecordCount::getCreateTime, endDate);
        }
        if(null != gameId){
            queryWrapper.eq(AppUserGameRecordCount::getGameId, gameId);
        }
        if(StringUtils.isNotBlank(gameDate)){
            queryWrapper.like(AppUserGameRecordCount::getGameDate, gameDate);
        }
        return appUserGameRecordCountMapper.selectList(queryWrapper);
    }

}
