<?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.platform.permission.dao.master.AppointmentMapper">
<resultMap id="BaseResultMap" type="com.lyms.platform.pojo.AppointmentModel">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="vccardNo" column="vccardNo" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="sex" column="sex" jdbcType="VARCHAR"/>
<result property="age" column="age" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="idCard" column="idCard" jdbcType="VARCHAR"/>
<result property="dept" column="dept" jdbcType="VARCHAR"/>
<result property="bhNum" column="bhNum" jdbcType="VARCHAR"/>
<result property="doctor" column="doctor" jdbcType="VARCHAR"/>
<result property="pinyin" column="pinyin" jdbcType="VARCHAR"/>
<result property="created" column="created" jdbcType="TIMESTAMP"/>
<result property="checkTime" column="checkTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="orderAndLimit">
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</sql>
<select id="queryAppointment" resultMap="BaseResultMap" parameterType="com.lyms.platform.permission.model.AppointmentQuery">
select * from appointment
where
1=1
<if test="doctor!=null">
and doctor=#{doctor}
</if>
<if test="idCard!=null">
and idCard=#{idCard}
</if>
<if test="name!=null">
and (name like concat('%',#{name},'%') or pinyin like concat('%',#{name},'%'))
</if>
<if test="dept!=null">
and (dept like concat(#{dept},'%') or (dept like concat("产后",'%') and dept !='产后服务部'))
</if>
<if test="deptName!=null">
and dept=#{deptName}
</if>
and <![CDATA[checkTime>=#{startTime}]]>
and <![CDATA[checkTime<=#{endTime}]]>
<include refid="orderAndLimit"/>
</select>
<select id="queryAppointmentCount" resultType="int" parameterType="com.lyms.platform.permission.model.AppointmentQuery">
select count(id) from appointment
where
1=1
<if test="doctor!=null">
and doctor=#{doctor}
</if>
<if test="idCard!=null">
and idCard=#{idCard}
</if>
<if test="name!=null">
and (name like concat('%',#{name},'%') or pinyin like concat('%',#{name},'%'))
</if>
<if test="dept!=null">
and (dept like concat(#{dept},'%') or (dept like concat("产后",'%') and dept !='产后服务部'))
</if>
and <![CDATA[checkTime>=#{startTime}]]>
and <![CDATA[checkTime<=#{endTime}]]>
</select>
</mapper>