Bläddra i källkod

fix:曲目收藏和我的曲目展示是否收藏

liujunchi 3 år sedan
förälder
incheckning
a6e8155645

+ 7 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -280,9 +280,11 @@
         where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
         ,(select group_concat(s.name_) from subject s
         where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
+        ,if(mf.id_ is not null,1,0) as favorite
         from music_sheet t
         left join sys_user su on t.create_by_ = su.id_
         left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
+        left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
         <where>
             <include refid="QueryInfo"/>
             <if test="param.studentId != null">
@@ -321,19 +323,22 @@
         ,(select group_concat(mt.name_) from music_tag mt
         where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
         ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
+        ,if(mf.id_ is not null,1,0) as favorite
         from music_sheet t
         left join sys_user su on t.create_by_ = su.id_
+        left join music_sheet_practice_record mspr on mspr.music_sheet_id_ = t.id_
+        left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_
         <where>
             <include refid="QueryInfo"/>
             <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
-                and t.id_ in
+                and mspr.id_ in
                 <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
         </where>
         <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
-            order by field(t.id_,
+            order by field(mspr.id_,
             <foreach collection="practiceMusicIdList" item="item" separator=",">
                 #{item}
             </foreach>

+ 3 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetPracticeRecordMapper.xml

@@ -17,8 +17,8 @@
         </sql>
 
 	<select id="selectPracticeMusicIdPage" resultType="java.lang.Long">
-        select t.music_sheet_id_ from  (select mspr.music_sheet_id_,
-        max(mspr.create_time_) as create_time_
+        select t.id_ from  (select
+        max(mspr.id_) as id_
         from music_sheet_practice_record mspr
         left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
         <where>
@@ -33,6 +33,6 @@
             </if>
         </where>
         group by mspr.music_sheet_id_
-        ) t  order by t.create_time_ desc
+        ) t  order by t.id_ desc
     </select>
 </mapper>