MatchmakerMapper.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.zhentao.mapper.MatchmakerMapper">
  4. <!-- 红娘VO结果映射 -->
  5. <resultMap id="MatchmakerVOMap" type="com.zhentao.vo.MatchmakerVO">
  6. <id column="matchmaker_id" property="matchmakerId"/>
  7. <result column="real_name" property="realName"/>
  8. <result column="phone" property="phone"/>
  9. <result column="email" property="email"/>
  10. <result column="gender" property="gender"/>
  11. <result column="birth_date" property="birthDate"/>
  12. <result column="avatar_url" property="avatarUrl"/>
  13. <result column="matchmaker_type" property="matchmakerType"/>
  14. <result column="level" property="level"/>
  15. <result column="success_couples" property="successCouples"/>
  16. <result column="address_detail" property="addressDetail"/>
  17. <result column="profile" property="profile"/>
  18. <result column="status" property="status"/>
  19. <result column="created_at" property="createdAt"/>
  20. <result column="province_name" property="provinceName"/>
  21. <result column="city_name" property="cityName"/>
  22. <result column="area_name" property="areaName"/>
  23. </resultMap>
  24. <!-- 分页查询红娘列表 -->
  25. <select id="selectMatchmakerPage" resultMap="MatchmakerVOMap">
  26. SELECT
  27. m.matchmaker_id,
  28. m.real_name,
  29. m.phone,
  30. m.email,
  31. m.gender,
  32. m.birth_date,
  33. m.avatar_url,
  34. m.matchmaker_type,
  35. m.level,
  36. m.success_couples,
  37. m.address_detail,
  38. m.profile,
  39. m.status,
  40. m.created_at,
  41. p.name AS province_name,
  42. c.name AS city_name,
  43. a.name AS area_name
  44. FROM matchmakers m
  45. LEFT JOIN province p ON m.province_id = p.id
  46. LEFT JOIN city c ON m.city_id = c.id
  47. LEFT JOIN area a ON m.area_id = a.id
  48. WHERE 1=1
  49. <if test="matchmakerType != null">
  50. AND m.matchmaker_type = #{matchmakerType}
  51. </if>
  52. <if test="level != null">
  53. AND m.level = #{level}
  54. </if>
  55. <if test="provinceId != null">
  56. AND m.province_id = #{provinceId}
  57. </if>
  58. <if test="cityId != null">
  59. AND m.city_id = #{cityId}
  60. </if>
  61. <if test="keyword != null and keyword != ''">
  62. AND (m.real_name LIKE CONCAT('%', #{keyword}, '%')
  63. OR m.phone LIKE CONCAT('%', #{keyword}, '%'))
  64. </if>
  65. <choose>
  66. <when test="orderBy == 'level'">
  67. ORDER BY m.level ${orderType}, m.success_couples DESC
  68. </when>
  69. <otherwise>
  70. ORDER BY m.success_couples ${orderType}, m.level DESC
  71. </otherwise>
  72. </choose>
  73. </select>
  74. <!-- 查询红娘详情 -->
  75. <select id="selectMatchmakerDetail" resultMap="MatchmakerVOMap">
  76. SELECT
  77. m.matchmaker_id,
  78. m.real_name,
  79. m.phone,
  80. m.email,
  81. m.gender,
  82. m.birth_date,
  83. m.avatar_url,
  84. m.matchmaker_type,
  85. m.level,
  86. m.success_couples,
  87. m.address_detail,
  88. m.profile,
  89. m.status,
  90. m.created_at,
  91. p.name AS province_name,
  92. c.name AS city_name,
  93. a.name AS area_name
  94. FROM matchmakers m
  95. LEFT JOIN province p ON m.province_id = p.id
  96. LEFT JOIN city c ON m.city_id = c.id
  97. LEFT JOIN area a ON m.area_id = a.id
  98. WHERE m.matchmaker_id = #{matchmakerId}
  99. </select>
  100. </mapper>