<?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.SmartSubjectMapper">
    <resultMap type="com.template.model.vo.TimeGroupVo" id="subjectsMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="cardNo" column="card_no"/>
        <result property="departmentId" column="department_id"/>
        <result property="headImage" column="head_image"/>
    </resultMap>
    <select id="queryGradeSubjects" resultType="com.template.model.vo.TimeGroupVo" resultMap="subjectsMap">
        select ss.id,ss.name from smart_subject ss
        <if test="grade != null and grade != ''">
        inner join smart_grade sg on sg.deleted = 0 and sg.name = #{grade} and FIND_IN_SET(ss.id,sg.subject_id)
        </if>
        where ss.deleted = 0
    </select>
</mapper>
