package cn.iocoder.byzs.module.bjdx.dal.mysql.coursequestion;

import cn.iocoder.byzs.module.bjdx.controller.admin.coursequestion.vo.CourseQuestionPageReqVO;
import cn.iocoder.byzs.framework.common.pojo.PageResult;
import cn.iocoder.byzs.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.byzs.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.byzs.module.bjdx.dal.dataobject.coursequestion.CourseQuestionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.byzs.module.bjdx.controller.admin.coursequestion.vo.*;

/**
 * 课程-试题 Mapper
 *
 * @author lyb
 */
@Mapper
public interface CourseQuestionMapper extends BaseMapperX<CourseQuestionDO> {

    default PageResult<CourseQuestionDO> selectPage(CourseQuestionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseQuestionDO>()
                .likeIfPresent(CourseQuestionDO::getCqQuestion, reqVO.getCqQuestion())
                .likeIfPresent(CourseQuestionDO::getCqQuestAnalysis, reqVO.getCqQuestAnalysis())
                .eqIfPresent(CourseQuestionDO::getCqQuestType, reqVO.getCqQuestType())
                .eqIfPresent(CourseQuestionDO::getCqQuestScore, reqVO.getCqQuestScore())
                .eqIfPresent(CourseQuestionDO::getCqQuestAnswerId, reqVO.getCqQuestAnswerId())
                .orderByDesc(CourseQuestionDO::getId));
    }

}