<?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.ssj.service.mapper.SSJPeiyouBookMapper" >

    <select id="findUnitBySelective" resultType="com.ssj.service.conch.parents.dto.GetPeiyouBookUnitDto">
        select id unitId,
               unit unitName
        from ssj_peiyou_book
        where 1=1
        <if test="grade != null and grade!=''">
            and grade = #{grade}
        </if>
        <if test="courseName != null and courseName!=''">
            and course_name = #{courseName}
        </if>
        <if test="bookName != null and bookName!=''">
            and book_name = #{bookName}
        </if>
        GROUP BY unit
    </select>

    <select id="findSecondUnitBySelective" resultType="com.ssj.service.conch.parents.dto.GetSecondUnitInfoDto">
        select id secondUnitId,
               second_unit secondUnitName
        from ssj_peiyou_book
        where 1=1
        <if test="grade != null and grade!=''">
            and grade = #{grade}
        </if>
        <if test="courseName != null and courseName!=''">
            and course_name = #{courseName}
        </if>
        <if test="bookName != null and bookName!=''">
            and book_name = #{bookName}
        </if>
        <if test="unit != null and unit!=''">
            and unit = #{unit}
        </if>
        GROUP BY second_unit
    </select>

</mapper>