package cn.iocoder.yudao.module.configure.dal.mysql.tracelinkitem;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.configure.dal.dataobject.tracelinkitem.TraceLinkItemDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.configure.controller.admin.tracelinkitem.vo.*;

/**
 * 溯源模板环节item Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TraceLinkItemMapper extends BaseMapperX<TraceLinkItemDO> {

    default PageResult<TraceLinkItemDO> selectPage(TraceLinkItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TraceLinkItemDO>()
                .eqIfPresent(TraceLinkItemDO::getTitle, reqVO.getTitle())
                .eqIfPresent(TraceLinkItemDO::getType, reqVO.getType())
                .eqIfPresent(TraceLinkItemDO::getContent, reqVO.getContent())
                .betweenIfPresent(TraceLinkItemDO::getAddTime, reqVO.getAddTime())
                .likeIfPresent(TraceLinkItemDO::getLinkName, reqVO.getLinkName())
                .eqIfPresent(TraceLinkItemDO::getLinkId, reqVO.getLinkId())
                .eqIfPresent(TraceLinkItemDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(TraceLinkItemDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(TraceLinkItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TraceLinkItemDO::getId));
    }

    default List<TraceLinkItemDO> selectList(TraceLinkItemExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TraceLinkItemDO>()
                .eqIfPresent(TraceLinkItemDO::getTitle, reqVO.getTitle())
                .eqIfPresent(TraceLinkItemDO::getType, reqVO.getType())
                .eqIfPresent(TraceLinkItemDO::getContent, reqVO.getContent())
                .betweenIfPresent(TraceLinkItemDO::getAddTime, reqVO.getAddTime())
                .likeIfPresent(TraceLinkItemDO::getLinkName, reqVO.getLinkName())
                .eqIfPresent(TraceLinkItemDO::getLinkId, reqVO.getLinkId())
                .eqIfPresent(TraceLinkItemDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(TraceLinkItemDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(TraceLinkItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TraceLinkItemDO::getId));
    }

}
