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

import cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO;
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.controller.admin.courseconfig.vo.CourseConfigPageReqVO;
import cn.iocoder.byzs.module.bjdx.dal.dataobject.course.CourseDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.*;

import java.util.List;

/**
 * 课程 Mapper
 *
 * @author lyb
 */
@Mapper
public interface CourseMapper extends BaseMapperX<CourseDO> {

    default PageResult<CourseDO> selectPage(CoursePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseDO>()
                .likeIfPresent(CourseDO::getCourseName, reqVO.getCourseName())
                .eqIfPresent(CourseDO::getCourseContentType, reqVO.getCourseContentType())
                .eqIfPresent(CourseDO::getCourseContent, reqVO.getCourseContent())
                .likeIfPresent(CourseDO::getCourseAuthor, reqVO.getCourseAuthor())
                .likeIfPresent(CourseDO::getCourseTeacher, reqVO.getCourseTeacher())
                .eqIfPresent(CourseDO::getCourseSize, reqVO.getCourseSize())
                .eqIfPresent(CourseDO::getCourseTime, reqVO.getCourseTime())
                .eqIfPresent(CourseDO::getCourseIsInspect, reqVO.getCourseIsInspect())
                .eqIfPresent(CourseDO::getCourseType, reqVO.getCourseType())
                .eqIfPresent(CourseDO::getCourseLabel, reqVO.getCourseLabel())
                .eqIfPresent(CourseDO::getCourseStatus, reqVO.getCourseStatus())
                .orderByAsc(CourseDO::getCourseLabel, CourseDO::getCourseOrder));
    }

    List<CoursePageReqVO> selectCoursePage(CoursePageReqVO reqVO);
}