<?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.xhkjedu.sstudy.mapper.subjectbook.VersionMapper">

    <!-- 根据阶段获取册别 -->
    <select id="listVersions" resultType="com.xhkjedu.sstudy.model.subjectbook.TVersion">
        select v.versionid,v.versionname,v.versionorder,v.createid,v.createtime,v.belong,u.username createname
        from t_version v left join t_user u on u.userid=v.createid
        where (v.belong=1
        <if test="version.schoolid!=null">
            or v.schoolid=#{version.schoolid}
        </if>)
        order by v.versionorder asc
    </select>

    <!--查找使用版本的模块-->
    <select id="findUseModule" resultType="java.lang.String">
        select (case when count(*)>0 then ',教材' else '' end) from t_subject_book where versionid=#{versionid}
    </select>

</mapper>
