<?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="cn.com.ctop.oa.modules.mapper.WechatCheckinDataMapper">
    <select id="queryEntityByMap" resultType="cn.com.ctop.oa.modules.entity.WechatCheckinData">
        SELECT
        *
        FROM ctop_wechat_checkin_data
        <where>
            <if test="userId != null and userId != '' ">
                and user_id = #{userId}
            </if>
            <if test="departId != null and departId != '' ">
                and depart_id = #{departId}
            </if>
            <if test="checkinType != null">
                and checkin_type = #{checkinType}
            </if>
            <if test="checkinDate != null ">
                and checkin_time like concat(#{checkinDate},"%")
            </if>
        </where>
    </select>


    <select id="selectPageList" resultType="cn.com.ctop.oa.modules.entity.WechatCheckinSubData">
        SELECT
        ck.id,
        ck.depart_id,
        ck.user_id,
        us.user_name,
        dpt.depart_name,
        ck.group_name,
        ck.checkin_type,
        ck.exception_type,
        ck.checkin_time,
        ck.location_title,
        ck.location_detail,
        ck.wifiname,
        ck.notes,
        ck.wifimac,
        ck.mediaids,
        ck.lat,
        ck.lng,
        ck.deviceid,
        ck.overtime_or_not,
        ck.overtime,
        ck.create_time,
        ck.update_time
        FROM ctop_wechat_checkin_data as ck
        LEFT JOIN ctop_wechat_user_list as us ON ck.user_id = us.user_id
        LEFT JOIN ctop_wechat_department as dpt ON dpt.depart_id = us.depart_id
        where us.data_type = 0
        <if test="userId != null and userId != '' ">
            and ck.user_id = #{userId}
        </if>
        <if test="departId != null and departId != '' ">
            and ck.depart_id = #{departId}
        </if>
        <if test="userName != null ">
            and us.user_name like concat(#{userName},"%")
        </if>
        <if test="startTime != null">
            and ck.checkin_time &gt;= #{startTime}
        </if>
        <if test="stopTime != null ">
            and ck.checkin_time &lt;= #{stopTime}
        </if>
    </select>
</mapper>