package co.yixiang.yshop.module.member.dal.mysql.burypoint;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.member.dal.dataobject.burypoint.BuryPointDO;
import co.yixiang.yshop.module.member.dal.dataobject.burypoint.TrendChartRespVO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.member.controller.admin.burypoint.vo.*;

/**
 * 埋点 Mapper
 *
 * @author admin
 */
@Mapper
public interface BuryPointMapper extends BaseMapperX<BuryPointDO> {

    default PageResult<BuryPointDO> selectPage(BuryPointPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BuryPointDO>()
                .eqIfPresent(BuryPointDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BuryPointDO::getEvent, reqVO.getEvent())
                .eqIfPresent(BuryPointDO::getEventParameter, reqVO.getEventParameter())
                .betweenIfPresent(BuryPointDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BuryPointDO::getIp, reqVO.getIp())
                .orderByDesc(BuryPointDO::getId));
    }

    default List<BuryPointDO> selectList(BuryPointExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BuryPointDO>()
                .eqIfPresent(BuryPointDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BuryPointDO::getEvent, reqVO.getEvent())
                .eqIfPresent(BuryPointDO::getEventParameter, reqVO.getEventParameter())
                .betweenIfPresent(BuryPointDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BuryPointDO::getIp, reqVO.getIp())
                .orderByDesc(BuryPointDO::getId));
    }

    List<TrendChartRespVO> getTrendChart();

}
