<?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.lyms.talkonlineweb.mapper.LymsDoctorWorktimeMapper">

    <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsDoctorWorkTime">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="did" column="did" jdbcType="INTEGER"/>
            <result property="startTime" column="start_time" jdbcType="VARCHAR"/>
            <result property="endTime" column="end_time" jdbcType="VARCHAR"/>
            <result property="status" column="status" jdbcType="INTEGER"/>
            <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
            <result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <select id = "selectDoctorChatCount" parameterType="java.lang.String" resultType="com.lyms.talkonlineweb.domain.DoctorChatCount">

        select
            d.did,
            d.dlogin,
            d.dpasswd,
            d.dname,
            d.mobile,
            d.gzopenid,
            c.count
        from
        lyms_doctor d,
        lyms_doctor_worktime w,
        v_doctor_chat_count c
        where d.did = w.did
        and d.did = c.did
        and w.start_time = #{startTime}
        and c.count > 0

    </select>

    <select id="selectDoctorChat" resultType="com.lyms.talkonlineweb.domain.DoctorChatCount">
        SELECT
	d.did,
	d.dlogin,
	d.dpasswd,
	d.dname,
	d.mobile,
	d.gzopenid,
	c.count
FROM
	lyms_doctor d
INNER JOIN lyms_doctor_worktime w ON d.did = w.did
INNER JOIN v_doctor_chat_count c ON d.did = c.did
AND c.count > 0
    </select>
</mapper>
