package cn.iocoder.yudao.module.system.dal.mysql.sys;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.sys.vo.NewsPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sys.NewsDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * 系统文章新闻 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface NewsMapper extends BaseMapperX<NewsDO> {

    default PageResult<NewsDO> selectPage(NewsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NewsDO>()
                .eqIfPresent(NewsDO::getTitle, reqVO.getTitle())
                .eqIfPresent(NewsDO::getArticleAbstract, reqVO.getArticleAbstract())
                .eqIfPresent(NewsDO::getType, reqVO.getType())
                .eqIfPresent(NewsDO::getPlatform, reqVO.getPlatform())
                .eqIfPresent(NewsDO::getStatus, reqVO.getStatus())
                .inIfPresent(NewsDO::getTenantId,reqVO.getTenantIds())
                .eqIfPresent(NewsDO::getOrgType,reqVO.getOrgType())
                .orderByDesc(NewsDO::getCreatedTime));
    }

}