package co.yixiang.yshop.module.distributor.dal.mysql.distributordynamics;

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.distributor.dal.dataobject.distributordynamics.DistributorDynamicsDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.distributor.controller.admin.distributordynamics.vo.*;

/**
 * 分销商动态 Mapper
 *
 * @author admin
 */
@Mapper
public interface DistributorDynamicsMapper extends BaseMapperX<DistributorDynamicsDO> {

    default PageResult<DistributorDynamicsDO> selectPage(DistributorDynamicsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DistributorDynamicsDO>()
                .eqIfPresent(DistributorDynamicsDO::getType, reqVO.getType())
                .eqIfPresent(DistributorDynamicsDO::getDistributorId, reqVO.getDistributorId())
                .likeIfPresent(DistributorDynamicsDO::getDistributorName, reqVO.getDistributorName())
                .eqIfPresent(DistributorDynamicsDO::getContent, reqVO.getContent())
                .betweenIfPresent(DistributorDynamicsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributorDynamicsDO::getId));
    }

    default List<DistributorDynamicsDO> selectList(DistributorDynamicsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DistributorDynamicsDO>()
                .eqIfPresent(DistributorDynamicsDO::getType, reqVO.getType())
                .eqIfPresent(DistributorDynamicsDO::getDistributorId, reqVO.getDistributorId())
                .likeIfPresent(DistributorDynamicsDO::getDistributorName, reqVO.getDistributorName())
                .eqIfPresent(DistributorDynamicsDO::getContent, reqVO.getContent())
                .betweenIfPresent(DistributorDynamicsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributorDynamicsDO::getId));
    }

}
