<?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.sapi.mapper.itemtool.ReadDateMapper">
    <!--根据阅读id删除阅读开放时间-->
    <delete id="deleteByReadId">
        delete from t_read_date where readid=#{readid}
    </delete>
    <!--根据阅读id获取阅读开放时间-->
    <select id="listByReadId" resultType="com.xhkjedu.sapi.model.itemtool.TReadDate">
        select weeknum,begintime,endtime
        ,(case when weeknum=DATE_FORMAT(CURDATE(),'%w') and CURRENT_TIME() between begintime
        and concat(endtime,':59') then 1 else 0 end)readable
        from t_read_date where readid=#{readid}
        order by weeknum,begintime,endtime
    </select>
</mapper>
