SmartVisitorMapper.xml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.template.mapper.SmartVisitorMapper">
  4. <resultMap type="com.template.model.vo.VisitorPageVo" id="visitorPageMap">
  5. <result property="id" column="id"/>
  6. <result property="userId" column="user_id"/>
  7. <result property="userName" column="user_name"/>
  8. <result property="createTime" column="create_time"/>
  9. <result property="statu" column="statu"/>
  10. <result property="visitorTime" column="visitor_time"/>
  11. <result property="visitReason" column="visit_reason"/>
  12. </resultMap>
  13. <select id="queryVisitorPage" resultType="com.template.model.vo.VisitorPageVo" resultMap="visitorPageMap">
  14. select sv.id,sv.user_id,su.name as user_name,sv.create_time,sv.statu,sv.visitor_time,sv.visit_reason from
  15. smart_visitor sv
  16. left join smart_user su on su.deleted = 0 and sv.user_id = su.id
  17. where sv.deleted = 0
  18. <if test="userId != null and userId != ''">
  19. and sv.user_id = #{userId}
  20. </if>
  21. <if test="statu != null and statu != ''">
  22. and sv.statu = #{statu}
  23. </if>
  24. </select>
  25. <select id="queryVisitorCount" resultType="java.lang.Integer">
  26. select Count(*) from smart_visitor
  27. where 1=1
  28. <if test="cardNo != null and cardNo != ''">
  29. and user_number = #{cardNo}
  30. </if>
  31. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  32. and (
  33. <if test="startTime != null and startTime != ''">
  34. (visitor_time &lt; #{startTime} and visitor_deadline &gt; #{startTime})
  35. </if>
  36. <if test="endTime != null and endTime != ''">
  37. or (visitor_time &lt; #{endTime} and visitor_deadline &gt; #{endTime})
  38. </if>
  39. )
  40. </if>
  41. and deleted = 0 and statu != 2
  42. </select>
  43. </mapper>