后台服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WxMerchantBUserMapper.xml 7.4 KiB

преди 2 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.iformall.mapper.WxMerchantBUserMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantBUser">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  9. <result column="user_pwd" jdbcType="VARCHAR" property="userPwd"/>
  10. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  11. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  12. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  13. <result column="app_id" jdbcType="VARCHAR" property="appId"/>
  14. <result column="token" jdbcType="VARCHAR" property="token"/>
  15. <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
  16. <result column="name" jdbcType="VARCHAR" property="name"/>
  17. <result column="status" jdbcType="INTEGER" property="status"/>
  18. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  19. <result column="other_merchant" jdbcType="VARCHAR" property="otherMerchant"/>
  20. </resultMap>
  21. <sql id="allColumns">
  22. `id`,`tenant_id`,`parent_tenant_id`,`phone`,`user_pwd`,`merchant_id`,`create_date`,`update_date`,`app_id`,`token`,`expire_time`,`name`,`status`,`is_admin`,`other_merchant`
  23. </sql>
  24. <sql id="dynamicWhereConditions">
  25. where 1 = 1
  26. <if test=" null != id ">
  27. and `id` = #{id}
  28. </if>
  29. <if test=" null != tenantId and '' != tenantId">
  30. and `tenant_id` = #{tenantId}
  31. </if>
  32. <if test=" null != parentTenantId and '' != parentTenantId">
  33. and `parent_tenant_id` = #{parentTenantId}
  34. </if>
  35. <if test=" null != phone ">
  36. and `phone` = #{phone}
  37. </if>
  38. <if test=" null != phoneLike ">
  39. and `phone` like concat('%', #{phoneLike},'%')
  40. </if>
  41. <if test=" null != userPwd ">
  42. and `user_pwd` like concat('%', #{userPwd},'%')
  43. </if>
  44. <if test=" null != merchantId ">
  45. and `merchant_id` = #{merchantId}
  46. </if>
  47. <if test=" null != createDate ">
  48. and `create_date` = #{createDate}
  49. </if>
  50. <if test=" null != updateDate ">
  51. and `update_date` = #{updateDate}
  52. </if>
  53. <if test=" null != appId ">
  54. and `app_id` like concat('%', #{appId},'%')
  55. </if>
  56. <if test=" null != token ">
  57. and `token` like concat('%', #{token},'%')
  58. </if>
  59. <if test=" null != expireTime ">
  60. and `expire_time` = #{expireTime}
  61. </if>
  62. <if test=" null != name ">
  63. and `name` = #{name}
  64. </if>
  65. <if test=" null != status ">
  66. and `status` = #{status}
  67. </if>
  68. <if test=" null != isAdmin ">
  69. and `is_admin` = #{isAdmin}
  70. </if>
  71. <if test=" null != otherMerchantId and '' != otherMerchantId">
  72. and json_search(other_merchant, 'one', #{otherMerchantId}) IS NOT NULL;
  73. </if>
  74. <if test=" null != ids ">
  75. and id in
  76. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  77. #{idItem}
  78. </foreach>
  79. </if>
  80. <if test=" null != merchantIds ">
  81. and merchant_id in
  82. <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
  83. #{merchantIdItem}
  84. </foreach>
  85. </if>
  86. <if test=" null != sortColumns">order by ${sortColumns}</if>
  87. </sql>
  88. <select id="findList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultMap="BaseResultMap">
  89. select
  90. <include refid="allColumns"/>
  91. from wx_merchant_b_user
  92. <include refid="dynamicWhereConditions"/>
  93. </select>
  94. <select id="findMerchantIdListByIds" parameterType="com.iformall.domain.po.WxMerchantBUser" resultMap="BaseResultMap">
  95. select id, merchant_id
  96. from wx_merchant_b_user
  97. where `tenant_id` = #{tenantId}
  98. <if test=" null != ids ">
  99. and id in
  100. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  101. #{idItem}
  102. </foreach>
  103. </if>
  104. </select>
  105. <select id="findMerchantIdList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultType="Long">
  106. select distinct merchant_id
  107. from wx_merchant_b_user
  108. <include refid="dynamicWhereConditions"/>
  109. </select>
  110. <select id="findIdList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultType="Long">
  111. select id
  112. from wx_merchant_b_user
  113. <include refid="dynamicWhereConditions"/>
  114. </select>
  115. <select id="findSimpleList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultMap="BaseResultMap">
  116. select id,name,phone,merchant_id
  117. from wx_merchant_b_user
  118. where `tenant_id` = #{tenantId}
  119. <if test=" null != parentTenantId and '' != parentTenantId">
  120. and `parent_tenant_id` = #{parentTenantId}
  121. </if>
  122. <if test=" null != ids ">
  123. and id in
  124. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  125. #{idItem}
  126. </foreach>
  127. </if>
  128. </select>
  129. <select id="findSelMerchantList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultType="com.iformall.domain.vo.WxMerchantBuInfoVo">
  130. select
  131. mbu.tenant_id, mbu.parent_tenant_id, m.name tenant_name,
  132. mc.name merchant_name, mbu.id bu_user_id, mbu.merchant_id, mc.img_url
  133. from wx_merchant_b_user mbu, wx_merchant mc, wx_mall m
  134. <where> m.tenant_id = mbu.tenant_id
  135. and mbu.merchant_id = mc.id and mc.status = 1
  136. <if test=" null != appId ">
  137. and mbu.`app_id` = #{appId}
  138. </if>
  139. <if test=" null != phone ">
  140. and mbu.`phone` = #{phone}
  141. </if>
  142. <if test=" null != status ">
  143. and mbu.`status` = #{status}
  144. </if>
  145. </where>
  146. </select>
  147. <select id="findByToken" resultMap="BaseResultMap">
  148. select * from wx_merchant_b_user
  149. where `token` = #{token}
  150. </select>
  151. <update id="deleteOtherMerchant" parameterType="hashmap">
  152. update wx_merchant_b_user set other_merchant = JSON_REMOVE(other_merchant, replace(json_search(other_merchant, 'one', #{otherId}), '"', ''))
  153. where `tenant_id` = #{tenantId}
  154. and json_search(other_merchant, 'one', #{otherId}) IS NOT NULL;
  155. </update>
  156. <update id="addOtherMerchant" parameterType="hashmap">
  157. update wx_merchant_b_user set other_merchant = json_array_append(coalesce(other_merchant,'[]'), '$', #{otherId})
  158. where `tenant_id` = #{tenantId}
  159. and id in
  160. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  161. #{idItem}
  162. </foreach>
  163. and json_search(other_merchant, 'one', #{otherId}) IS NULL;
  164. </update>
  165. </mapper>