Browse Source

超管菜单优化

wangliang 2 years ago
parent
commit
9540f8340f

+ 6 - 32
themis-business/src/main/resources/mapper/TBOrgMapper.xml

@@ -3,43 +3,17 @@
 <mapper namespace="com.qmth.themis.business.dao.TBOrgMapper">
 
     <select id="queryByPage" resultType="com.qmth.themis.business.dto.response.TBOrgDto">
-        select
-            t.id,
-            t.logo,
-            t.enableSimulate,
-            t.simulatePaperId,
-            t.enableMonitorRecord,
-            t.enableLiveness,
-            t.accessKey,
-            t.accessSecret,
-            t.name,
-            t.code,
-            t.enable,
-            t.contactName,
-            t.contactPhone,
-            if(t.updateName is not null,t.updateName,t.createName) as updateName,
-            if(t.updateTime is not null,t.updateTime,t.createTime) as updateTime
-            from
-            (
             select
                 tbo.id, tbo.logo, tbo.enable_simulate as enableSimulate, tbo.simulate_paper_id as simulatePaperId,
                 tbo.enable_monitor_record as enableMonitorRecord,tbo.enable_liveness as enableLiveness,
                 tbo.access_key as accessKey,tbo.access_secret as accessSecret,
-                tbo.name, tbo.code, tbo.enable, tbo.contact_name as contactName, tbo.contact_phone as contactPhone, (
-                select
-                    tbu.name
-                from
-                    t_b_user tbu
-                where
-                    tbu.id = tbo.create_id) as createName, tbo.create_time as createTime, (
-                select
-                    tbu.name
-                from
-                    t_b_user tbu
-                where
-                    tbu.id = tbo.update_id) as updateName, tbo.update_time as updateTime
+                tbo.name, tbo.code, tbo.enable, tbo.contact_name as contactName, tbo.contact_phone as contactPhone,
+                if(tbu2.name is not null,tbu2.name,tbu1.name) as updateName,
+                if(tbo.update_time is not null,tbo.update_time,tbo.create_time) as updateTime
             from
                 t_b_org tbo
+            left join t_b_user tbu1 on tbo.create_id = tbu1.id
+            left join t_b_user tbu2 on tbo.update_id = tbu2.id
             <where>
                 <if test="code != null and code != ''">
                     and tbo.code = #{code}
@@ -50,6 +24,6 @@
                 <if test="enable != null and enable != '' or enable == 0">
                     and tbo.enable = #{enable}
                 </if>
-            </where> ) t
+            </where>
     </select>
 </mapper>

+ 4 - 13
themis-business/src/main/resources/mapper/TBUserMapper.xml

@@ -18,21 +18,12 @@
             from
             (
             select
-                tbu.org_id as orgId,tbu.id, tbu.mobile_number as mobileNumber, tbu.login_name as loginName, tbu.name, group_concat(tbr.role_code) as roleCodeStr, group_concat(tbr.role_name) as roleNameStr, tbu.enable,tbo.name as orgName,(
-            select
-            t.name
-            from
-            t_b_user t
-            where
-            t.id = tbu.create_id) as createName, tbu.create_time as createTime, (
-            select
-            t.name
-            from
-            t_b_user t
-            where
-            t.id = tbu.update_id) as updateName, tbu.update_time as updateTime
+                tbu.org_id as orgId,tbu.id, tbu.mobile_number as mobileNumber, tbu.login_name as loginName, tbu.name, group_concat(tbr.role_code) as roleCodeStr, group_concat(tbr.role_name) as roleNameStr, tbu.enable,tbo.name as orgName,
+                tbu1.name as createName, tbu.create_time as createTime, tbu2.name as updateName, tbu.update_time as updateTime
             from
             t_b_user tbu
+            left join t_b_user tbu1 on tbu.create_id = tbu1.id
+            left join t_b_user tbu2 on tbu.update_id = tbu2.id
             left join t_b_user_role tbur on
             tbur.user_id = tbu.id
             left join t_b_role tbr on