he2802 2 jaren geleden
bovenliggende
commit
50ac46277f

+ 9 - 6
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml

@@ -1253,12 +1253,15 @@
         ccs.sort,
         cs.section_id AS id,
         #{courseId} AS course_id,
-        ( SELECT u.realname FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
-        and u.user_id = #{userId}
-    </if>  ) AS realname,
-        ( SELECT u.user_id FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
-        and u.user_id = #{userId}
-    </if>  ) AS user_id,
+        <if test="userId != null and userId !='' ">
+            (SELECT u.realname FROM `user` u where 1=1
+            and u.user_id = #{userId}
+            ) as realname,
+        </if>
+
+        <if test="userId != null and userId !='' ">
+            #{userId} as user_id,
+        </if>
         cs.NAME AS type_name,
         cs.duration_time,
         cs.section_type,