刘俊驰 4 miesięcy temu
rodzic
commit
c11bb2acbd

+ 40 - 10
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -51,6 +51,7 @@ import com.yonge.toolset.mybatis.support.PageUtil;
 import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.Nullable;
 import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -950,15 +951,8 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
     public void initMusicSheetVos(List<MusicSheetVo> records,SourceTypeEnum sourceTypeEnum) {
         if(CollectionUtils.isNotEmpty(records)){
             List<Long> cbsMusicSheetIds = records.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
-            CbsMusicSheetWrapper.MusicSheetApplicationQuery query = this.getMusicSheetApplicationQuery(sourceTypeEnum);
-            query.setRows(cbsMusicSheetIds.size());
-            query.setMusicSheetIds(cbsMusicSheetIds);
-            List<CbsMusicSheetWrapper.MusicSheetApplication> rows = this.queryCbsMusicSheetApplication(query);
-            if(CollectionUtils.isEmpty(rows)){
-                return;
-            }
-            Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = rows
-                    .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
+            Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = getMusicSheetApplicationMapByCbsIds(sourceTypeEnum, cbsMusicSheetIds);
+            if (musicSheetApplicationMap == null) return;
             for (MusicSheetVo record : records) {
                 CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(record.getCbsMusicSheetId());
                 if(musicSheetApplication != null){
@@ -969,6 +963,20 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
 
     }
 
+    @Nullable
+    private Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> getMusicSheetApplicationMapByCbsIds(SourceTypeEnum sourceTypeEnum, List<Long> cbsMusicSheetIds) {
+        CbsMusicSheetWrapper.MusicSheetApplicationQuery query = this.getMusicSheetApplicationQuery(sourceTypeEnum);
+        query.setRows(cbsMusicSheetIds.size());
+        query.setMusicSheetIds(cbsMusicSheetIds);
+        List<CbsMusicSheetWrapper.MusicSheetApplication> rows = this.queryCbsMusicSheetApplication(query);
+        if(CollectionUtils.isEmpty(rows)){
+            return null;
+        }
+        Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = rows
+                .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
+        return musicSheetApplicationMap;
+    }
+
     @Override
     public IPage<MusicSheetVo> selectStudentPage(IPage<MusicSheetVo> page, StudentMusicSheetSearch query, ClientEnum clientType) {
         List<MusicSheetVo> records = baseMapper.selectStudentMusicPage(page, query, clientType);
@@ -2602,7 +2610,29 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
 
     @Override
     public IPage<MusicSheetWrapper.MusicSheetCloud> cloudPage(MusicSheetWrapper.MusicSheetCloudQuery query) {
-        return musicSheetDao.cloudPage(QueryInfo.getPage(query),query);
+        IPage<MusicSheetWrapper.MusicSheetCloud> musicSheetCloudIPage = musicSheetDao.cloudPage(QueryInfo.getPage(query), query);
+        List<MusicSheetWrapper.MusicSheetCloud> records = musicSheetCloudIPage.getRecords();
+        if (CollectionUtils.isEmpty(records)) {
+            return musicSheetCloudIPage;
+        }
+        List<Long> musicSheetIds = records.stream()
+                .map(MusicSheetWrapper.MusicSheetCloud::getCbsMusicSheetId)
+                .map(Long::parseLong)
+                .collect(Collectors.toList());
+
+        Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMapByCbsIds = getMusicSheetApplicationMapByCbsIds(query.getProviderType(), musicSheetIds);
+        if (musicSheetApplicationMapByCbsIds == null) {
+            return musicSheetCloudIPage;
+        }
+        records = records.stream().map(o->{
+            CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMapByCbsIds.get(Long.parseLong(o.getCbsMusicSheetId()));
+            if (musicSheetApplication != null) {
+                o.setTitleImg(musicSheetApplication.getMusicCover());
+            }
+            return o;
+        }).collect(Collectors.toList());
+        musicSheetCloudIPage.setRecords(records);
+        return musicSheetCloudIPage;
     }
 
     private Map<Long,MusicSheet> getMapByCbsIds(List<Long> cbsMusicSheetIds) {