he2802 4 жил өмнө
parent
commit
4e5566fadd

+ 1 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/TestController.java

@@ -4,6 +4,7 @@ import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

+ 7 - 19
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -20,30 +20,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <select id="selectList" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"  resultMap="UserStudyRecordResult">
-        SELECT
-        bak.course_id,
-        bak.course_name,
-        bak.cover_url
-        FROM
-        (
-        SELECT
-        us.record_id,
-        c.course_id,
+        SELECT DISTINCT
+        temp.course_id,
         c.cover_url,
         c.course_name
         FROM
-        user_study_record us
-        LEFT JOIN course c ON us.course_id = c.course_id
-        WHERE
-        1 = 1
+        ( SELECT course_id FROM user_study_record WHERE 1 = 1
         <if test="userId != null and userId != ''">
-            AND  us.user_id = #{userId}
+            AND  user_id = #{userId}
         </if>
-        ORDER BY
-        us.record_id DESC
-        ) bak
-        GROUP BY
-        bak.course_id
+        ORDER BY record_id DESC LIMIT 30 ) temp
+        LEFT JOIN course c ON temp.course_id = c.course_id
+
 
     </select>
 </mapper>