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

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.usercollectbefore.vo.UserCollectBeforePageReqVO;
import cn.newfeifan.mall.module.distri.dal.dataobject.usercollectbefore.UserCollectBeforeDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户曾经收藏过什么商品的 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface UserCollectBeforeMapper extends BaseMapperX<UserCollectBeforeDO> {

    default PageResult<UserCollectBeforeDO> selectPage(UserCollectBeforePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserCollectBeforeDO>()
                .eqIfPresent(UserCollectBeforeDO::getProductSpuId, reqVO.getProductSpuId())
                .eqIfPresent(UserCollectBeforeDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(UserCollectBeforeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserCollectBeforeDO::getId));
    }

}