VisitMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.dayou.mapper.VisitMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.Visit">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="customer_id" property="customerId" />
  11. <result column="visit_type" property="visitType" />
  12. <result column="visit_time" property="visitTime" />
  13. <result column="spot" property="spot" />
  14. <result column="content" property="content" />
  15. <result column="user_id" property="userId" />
  16. </resultMap>
  17. <!-- 通用查询结果列 -->
  18. <sql id="Base_Column_List">
  19. v.id,
  20. v.deleted,
  21. v.created,
  22. v.modified,
  23. v.customer_id, v.visit_type, v.visit_time, v.spot, v.content,v.user_id
  24. </sql>
  25. <sql id="pageOrList">
  26. select
  27. <include refid="Base_Column_List"/>,c.name as customerName,u.name as userName,c.section as customerSection,
  28. c.department as customerDepartment,c.position as customerPosition,c.level as customerLevel
  29. from visit v left join customer c on v.customer_id = c.id left join user u on u.id = v.user_id
  30. where v.deleted = 0 and c.deleted = 0
  31. <if test="visit!=null and visit.visitType!=null and visit.visitType!='' ">
  32. and v.visit_type = #{visit.visitType}
  33. </if>
  34. <if test="keyword!=null and keyword!='' ">
  35. and(
  36. c.name like concat ('%',#{keyword},'%')
  37. or c.level like concat('%',#{keyword},'%')
  38. or c.department like concat('%',#{keyword},'%')
  39. or c.position like concat('%',#{keyword},'%')
  40. or c.section like concat('%',#{keyword},'%')
  41. )
  42. </if>
  43. <if test="visit!=null and visit.userName!=null and visit.userName!='' " >
  44. and u.name like concat ('%',#{visit.userName},'%')
  45. </if>
  46. <if test="visit!=null and visit.userIds!=null and visit.userIds.size!=0">
  47. and v.user_id in
  48. <foreach collection="visit.userIds" open="(" close=")" separator="," item="userId">
  49. #{userId}
  50. </foreach>
  51. </if>
  52. order by v.id DESC
  53. </sql>
  54. <select id="page" parameterType="com.dayou.vo.VisitVO" resultType="com.dayou.vo.VisitVO">
  55. <include refid="pageOrList"/>
  56. </select>
  57. <select id="detail" parameterType="java.lang.Long" resultType="com.dayou.vo.VisitVO">
  58. select
  59. <include refid="Base_Column_List"/>,c.name as customerName,u.name as userName,c.section as customerSection,
  60. c.department as customerDepartment,c.position as customerPosition,c.level as customerLevel
  61. from visit v left join customer c on v.customer_id = c.id left join user u on u.id = v.user_id
  62. where v.deleted = 0 and c.deleted = 0 and v.id = #{id}
  63. </select>
  64. <select id="getList" resultType="com.dayou.vo.VisitVO">
  65. <include refid="pageOrList"/>
  66. </select>
  67. </mapper>