package cn.newfeifan.mall.module.trade.dal.mysql.messagelog;

import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.module.trade.controller.admin.messagelog.vo.MessageLogPageReqVO;
import cn.newfeifan.mall.module.trade.dal.dataobject.messagelog.MessageLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 微信消息记录 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface MessageLogMapper extends BaseMapperX<MessageLogDO> {

    default PageResult<MessageLogDO> selectPage(MessageLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MessageLogDO>()
                .eqIfPresent(MessageLogDO::getOpenid, reqVO.getOpenid())
                .eqIfPresent(MessageLogDO::getMemberUserId, reqVO.getMemberUserId())
                .eqIfPresent(MessageLogDO::getSystemUserId, reqVO.getSystemUserId())
                .eqIfPresent(MessageLogDO::getWechatMsgTemplateId, reqVO.getWechatMsgTemplateId())
                .eqIfPresent(MessageLogDO::getWechatMsgTemplateParams, reqVO.getWechatMsgTemplateParams())
                .eqIfPresent(MessageLogDO::getObjectId, reqVO.getObjectId())
                .betweenIfPresent(MessageLogDO::getSendTime, reqVO.getSendTime())
                .eqIfPresent(MessageLogDO::getSendStatus, reqVO.getSendStatus())
                .eqIfPresent(MessageLogDO::getResponseResult, reqVO.getResponseResult())
                .betweenIfPresent(MessageLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MessageLogDO::getId));
    }

}
