<?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.bk.TBkMapper">

  <!--备课列表-->
  <select id="listBks" resultType="java.util.Map">
    select b.bkid,b.lsbid,b.directorid,b.bktype,b.asktype,b.bktitle,b.duration,b.papernum,b.paperscore,b.votetype,b.inforsize,b.inforsuffix,b.bkjson,
    b.inforpath,b.inforpdf,b.imgpath,b.updatetime from t_bk b
    <if test="bk.directorid!=null and bk.directorid!='' and bk.directorid!='0'.toString() and bk.directorLeaf==0">
        left join t_director d on b.directorid=d.directorid
    </if>
    where b.createid=#{bk.createid}
    <if test="bk.bktype!=null and bk.bktype!=0">
      and b.bktype=#{bk.bktype}
    </if>
    <if test="bk.lsbid!=null and bk.lsbid!='' and bk.lsbid!='0'.toString()">
      and b.lsbid=#{bk.lsbid}
    </if>
    <if test="bk.directorid!=null and bk.directorid!='' and bk.directorid!='0'.toString() and bk.directorLeaf==1">
      and b.directorid=#{bk.directorid}
    </if>
    <if test="bk.directorid!=null and bk.directorid!='' and bk.directorid!='0'.toString() and bk.directorLeaf==0">
      and d.directorall like concat('%',#{bk.directorall},'%')
    </if>
    order by b.updatetime desc
  </select>
</mapper>