<?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.template.mapper.SmartClassMapper">

    <select id="getSchoolClassIdList" resultType="com.template.model.vo.SmartClassVo">
        SELECT sc.id     as id,
               sc.name   as className,
               sg.`name` as gradeName
        FROM `smart_class` sc
                 LEFT JOIN smart_grade sg ON sc.grade_id = sg.id
        where sc.deleted=0
        <if test="className != null and className != ''">
            AND sc.`name` like '%' #{className} '%'
        </if>

    </select>
    <select id="getSchoolClassId" resultType="com.template.model.vo.SmartClassVo">
        SELECT sc.id     as id,
               sc.name   as className,
               sg.`name` as gradeName
        FROM `smart_class` sc
                 LEFT JOIN smart_grade sg ON sc.grade_id = sg.id
        WHERE sc.id = #{schoolClass} and sc.deleted=0
        <if test="className != null and className != ''">
            AND sc.`name` like '%' #{className} '%'
        </if>
    </select>
    <select id="getClassId" resultType="com.template.model.vo.SchoolClassVo">
        SELECT sc.id     as classId,
               sc.name   as className,
               sg.id   as gradeId,
               sg.`name` as gradeName
        FROM `smart_class` sc
                 LEFT JOIN smart_grade sg ON sc.grade_id = sg.id
        WHERE sc.id = #{schoolClass} and sc.deleted=0
    </select>

</mapper>
