package cn.newfeifan.mall.module.distri.dal.mysql.usersigninlog;

import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.module.distri.controller.app.usersigninlog.vo.UserSignInLogPageReqVO;
import cn.newfeifan.mall.module.distri.dal.dataobject.usersigninlog.UserSignInLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户签到日志 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface UserSignInLogMapper extends BaseMapperX<UserSignInLogDO> {

    default PageResult<UserSignInLogDO> selectPage(UserSignInLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserSignInLogDO>()
                .eqIfPresent(UserSignInLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserSignInLogDO::getRunningDays, reqVO.getRunningDays())
                .betweenIfPresent(UserSignInLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserSignInLogDO::getId));
    }

    default UserSignInLogDO selectByUserId(Long loginUserId){
        return selectOne(UserSignInLogDO::getUserId, loginUserId);
    }
}