package cn.iocoder.yudao.module.portal.dal.mysql.news;

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.portal.dal.dataobject.news.NewsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.portal.controller.admin.news.vo.*;

/**
 * 新闻 Mapper
 *
 * @author 篮智科技
 */
@Mapper
public interface NewsMapper extends BaseMapperX<NewsDO> {

    default PageResult<NewsDO> selectPage(NewsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NewsDO>()
                .eqIfPresent(NewsDO::getNewsTitle, reqVO.getNewsTitle())
                .eqIfPresent(NewsDO::getNewsDesc, reqVO.getNewsDesc())
                .eqIfPresent(NewsDO::getNewsContent, reqVO.getNewsContent())
                .eqIfPresent(NewsDO::getNewsPath, reqVO.getNewsPath())
                .eqIfPresent(NewsDO::getCoverImg, reqVO.getCoverImg())
                .eqIfPresent(NewsDO::getNewsTypeId, reqVO.getNewsTypeId())
                .betweenIfPresent(NewsDO::getPublishTime, reqVO.getPublishTime())
                .betweenIfPresent(NewsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(NewsDO::getId));
    }

}