<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.web.modules.news.mapper.AgriculturalCourseMapper">

    <resultMap type="com.ruoyi.web.modules.news.domain.AgriculturalCourseRow" id="AgriculturalCourseRowResult">
        <result property="id"                     column="id"/>
        <result property="title"                  column="title"/>
        <result property="introduction"           column="introduction"/>
        <result property="type"                   column="type"/>
        <result property="coverFileUrl"             column="cover_file_url"/>
        <result property="contentFileUrl"         column="content_file_url"/>
        <result property="publishTime"            column="publish_time"/>
        <result property="actualEnrolledCount"    column="actual_enrolled_count"/>
        <result property="plannedHeadCount"       column="planned_head_count"/>
        <result property="registrationStartTime"  column="registration_start_time"/>
        <result property="registrationEndTime"    column="registration_end_time"/>
        <result property="trainingTime"           column="training_time"/>
        <result property="expectedOutcome"        column="expected_outcome"/>
    </resultMap>

    <select id="selectAgriculturalCourseList" parameterType="com.ruoyi.web.modules.news.domain.AgriculturalCourseQuery"
            resultMap="AgriculturalCourseRowResult">
        select id, title, introduction, type, cover_file_url, content_file_url, publish_time,
               actual_enrolled_count, planned_head_count, registration_start_time, registration_end_time,
               training_time, expected_outcome
        from v_agricultural_course
        <where>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="title != null and title != ''">
                and title like concat('%', #{title}, '%')
            </if>
        </where>
        order by publish_time desc, id desc
    </select>
</mapper>
