CustomerMapper.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.CustomerMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.Customer">
  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="name" property="name" />
  11. <result column="city" property="city" />
  12. <result column="county" property="county" />
  13. <result column="department" property="department" />
  14. <result column="position" property="position" />
  15. <result column="section" property="section" />
  16. <result column="mobile" property="mobile" />
  17. <result column="wechat_no" property="wechatNo" />
  18. <result column="QQ" property="qq" />
  19. <result column="level" property="level" />
  20. <result column="address" property="address" />
  21. <result column="user_id" property="userId" />
  22. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. id,
  26. deleted,
  27. created,
  28. modified,
  29. name, city, county, department, position, section, mobile, wechat_no, QQ, level, address,user_id
  30. </sql>
  31. <select id="getPage" parameterType="com.dayou.dto.CustomerDTO" resultType="com.dayou.dto.CustomerDTO">
  32. select c.*,u.name as userName
  33. from customer c left join user u on c.user_id = u.id
  34. <where>
  35. and c.deleted = 0 and u.deleted = 0
  36. <if test="customer!=null and customer.name!=null and customer.name!='' ">
  37. and c.name like concat ('%',#{customer.name},'%')
  38. </if>
  39. <if test="customer!=null and customer.level!=null and customer.level!='' ">
  40. and c.level = #{customer.level}
  41. </if>
  42. <if test="customer!=null and customer.userIds!=null and customer.userIds.size!=0">
  43. and c.user_id in
  44. <foreach collection="customer.userIds" open="(" close=")" separator="," item="userId">
  45. #{userId}
  46. </foreach>
  47. </if>
  48. </where>
  49. </select>
  50. </mapper>