Procházet zdrojové kódy

会员管理sql优化

lhm před 3 roky
rodič
revize
f65617748c

+ 7 - 9
kmall-admin/src/main/resources/mybatis/mapper/UserDao.xml

@@ -32,13 +32,11 @@
 
     <select id="queryList" resultType="com.kmall.admin.entity.UserEntity">
         SELECT DISTINCT
-        mall_user.*
-        ,mall_user_level.NAME levelName
-        FROM
-        mall_user
-        LEFT JOIN mall_user_level ON mall_user.user_level_id = mall_user_level.id
-        LEFT JOIN mall_merch_user mu ON mall_user.id = mu.user_id
-        LEFT JOIN mall_store s on mu.store_id = s.id
+            mu1.*
+            FROM
+            mall_store s
+        LEFT JOIN mall_merch_user mu ON s.id = mu.store_id
+        LEFT JOIN mall_user mu1 on mu1.id = mu.user_id
         WHERE 1=1
         <if test="storeId != null and storeId != ''">
             and mu.store_id = #{storeId}
@@ -50,10 +48,10 @@
             AND s.third_party_merch_code = #{thirdPartyMerchCode}
         </if>
         <if test="username != null and username.trim() != ''">
-            and mall_user.username like concat('%',#{username},'%')
+            and mu1.username like concat('%',#{username},'%')
         </if>
         <if test="mobile != null and mobile.trim() != ''">
-            and mall_user.mobile like concat('%',#{mobile},'%')
+            and mu1.mobile like concat('%',#{mobile},'%')
         </if>
         <choose>
             <when test="sidx != null and sidx.trim() != ''">