TaUserMapper.xml 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.yunzhi.marketing.center.taUser.mapper.TaUserMapper">
  4. <select id="getPageList" resultType="map">
  5. SELECT
  6. t.user_id AS userId,
  7. t.org_id AS orgId,
  8. t.user_name AS userName,
  9. t.login_name AS loginName,
  10. t.phone,
  11. t.avatar,
  12. t.create_date AS createDate,
  13. t.status,
  14. o.NAME AS orgName,
  15. o.address,
  16. o.logo,
  17. o.remark,
  18. m.miniapp_id AS miniappId,
  19. m.secret,
  20. m.token,
  21. m.NAME AS miniappName,
  22. m.qr_code AS qrCode,
  23. t.exp_date as expire_date,
  24. m.org_id
  25. FROM
  26. ta_user t
  27. LEFT JOIN ta_org o ON t.org_id = o.org_id
  28. LEFT JOIN ta_miniapp m ON o.org_id = m.org_id
  29. left join ta_channel_app_relation n on o.org_id = n.org_id
  30. left join ta_channel_proxy z on z.channel_id = n.channel_id
  31. WHERE
  32. t.is_admin =1 AND ifnull(t.not_show, 0) != 1
  33. <if test="channelId != null and channelId != ''">
  34. and n.channel_id = #{channelId}
  35. </if>
  36. <if test="miniAppName != null and miniAppName != ''">
  37. and m.name like CONCAT('%', #{miniAppName}, '%')
  38. </if>
  39. </select>
  40. <select id="getTagsList" resultType="com.yunzhi.marketing.center.taUser.entity.TaTags">
  41. SELECT
  42. t.*
  43. FROM
  44. ta_tag_user u
  45. LEFT JOIN ta_tags t ON u.tag_id = t.tag_id
  46. AND t.org_id = #{orgId}
  47. WHERE
  48. u.user_id = #{userId}
  49. </select>
  50. <select id="getUserList" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
  51. SELECT
  52. *
  53. FROM
  54. ta_user
  55. WHERE
  56. org_id = #{orgId}
  57. and phone = #{phone}
  58. </select>
  59. <select id="seleUserList" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
  60. SELECT
  61. t.*,
  62. b.building_id,
  63. d.person_id as consultant_person_id,
  64. if(d.person_id is not null,1,0) as mini_status
  65. FROM
  66. ta_user t
  67. LEFT JOIN ta_person_building b ON t.user_id = b.user_id
  68. LEFT JOIN ta_person d on t.user_id = d.user_id
  69. WHERE
  70. t.org_id = #{taUser.orgId} AND (t.is_admin != 1 or t.is_admin is null)
  71. <if test="taUser.userName != null and taUser.userName != ''">
  72. and t.user_name like CONCAT('%', #{taUser.userName}, '%')
  73. </if>
  74. <if test="taUser.phone != null and taUser.phone != ''">
  75. and t.phone like CONCAT('%', #{taUser.phone}, '%')
  76. </if>
  77. <if test="taUser.status != null and taUser.status != ''">
  78. and t.status = #{taUser.status}
  79. </if>
  80. <if test="taUser.jobNumber != null and taUser.jobNumber != ''">
  81. and t.job_number like CONCAT('%', #{taUser.jobNumber}, '%')
  82. </if>
  83. <if test="taUser.isConsultant != null">
  84. and t.is_consultant = #{taUser.isConsultant}
  85. </if>
  86. <if test="taUser.miniStatus == 0">
  87. and d.person_id is null
  88. </if>
  89. <if test="taUser.miniStatus != null and taUser.miniStatus != '' and taUser.miniStatus == 1">
  90. and d.person_id is not null
  91. </if>
  92. <if test="taUser.buildingId != null and taUser.buildingId != ''">
  93. and b.building_id = #{taUser.buildingId}
  94. </if>
  95. <if test="personBuildingList != null and personBuildingList.size > 0">
  96. AND b.building_id in
  97. <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
  98. #{personBuilding.buildingId}
  99. </foreach>
  100. </if>
  101. GROUP BY user_id
  102. order by t.weight desc, create_date desc
  103. </select>
  104. <select id="validateWeight" resultType="integer">
  105. select count(*) from ta_user t
  106. LEFT JOIN ta_person_building a on t.user_id = a.user_id
  107. where 1=1
  108. <if test="weight != null and weight != ''">
  109. and t.weight = #{weight}
  110. </if>
  111. <if test="buildingIds != null and buildingIds.size() > 0 ">
  112. and a.building_id in
  113. <foreach collection="buildingIds" item="item" index="index" open="(" close=")" separator=",">
  114. #{item}
  115. </foreach>
  116. </if>
  117. <if test="buildingId != null and buildingId != '' ">
  118. and a.building_id = #{buildingId}
  119. </if>
  120. <if test="userId != null and userId != ''">
  121. and t.user_id != #{userId}
  122. </if>
  123. </select>
  124. <select id="getAdminByAppID" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
  125. SELECT
  126. m.*
  127. FROM
  128. ta_miniapp t
  129. JOIN ta_user m USING (org_id)
  130. WHERE
  131. t.miniapp_id = #{appid}
  132. AND m.is_admin = 1
  133. </select>
  134. <select id="getBuildingIdsOf" resultType="java.lang.String">
  135. select building_id from ta_person_building
  136. where user_id = #{userId}
  137. <if test="buildingId != null and buildingId != ''">
  138. and building_id = #{buildingId}
  139. </if>
  140. </select>
  141. <select id="getUserByPerson" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
  142. SELECT
  143. t.*
  144. FROM
  145. ta_user t
  146. INNER JOIN ta_person s ON s.org_id = #{orgId} AND s.user_id = t.user_id
  147. WHERE
  148. t.org_id = #{orgId}
  149. AND s.person_id = #{personId}
  150. AND t.status &gt; -1
  151. Limit 1
  152. </select>
  153. <select id="selectPageList" resultType="com.yunzhi.marketing.center.taUser.entity.TaUserVO">
  154. SELECT
  155. s.person_id as user_id,
  156. t.user_id as real_user_id,
  157. t.*
  158. FROM
  159. ta_user t
  160. INNER JOIN ta_person s ON s.user_id = t.user_id
  161. where
  162. t.is_consultant = 1
  163. and t.status = 1
  164. <if test="idLists != null and idLists.size() > 0 ">
  165. and t.user_id in
  166. <foreach collection="idLists" item="item" index="index" open="(" close=")" separator=",">
  167. #{item}
  168. </foreach>
  169. </if>
  170. </select>
  171. </mapper>