Browse Source

曲目列表接口优化

zouxuan 2 months ago
parent
commit
3566a9a1fb

+ 1 - 1
mec-application/src/main/java/com/ym/mec/teacher/controller/SysMusicScoreController.java

@@ -67,6 +67,6 @@ public class SysMusicScoreController extends BaseController {
         queryInfo.setType("COMMON");
         queryInfo.setClientFlag(true);
         queryInfo.setClientType(ClientTypeEnum.SMART_PRACTICE);
-        return succeed(sysMusicScoreService.queryMusicScorePageInfo(queryInfo));
+        return succeed(sysMusicScoreService.queryMusicScorePageInfoSimple(queryInfo));
     }
 }

+ 14 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/MusicSheetWrapper.java

@@ -534,12 +534,21 @@ public class MusicSheetWrapper {
     }
 
     @Data
-    public static class MusicSheetSimpleQuery extends com.ym.mec.common.page.QueryInfo {
+    public static class MusicSheetSimpleDto{
 
-        @ApiModelProperty(value = "声部",required = true)
-        private Integer subjectId;
+        @ApiModelProperty("主键")
+        private Long id;
+
+        @ApiModelProperty("曲目封面图")
+        private String titleImg;
+
+        @ApiModelProperty("曲目名称")
+        private String name;
+
+        @ApiModelProperty("曲目类型(SINGLE:单曲 CONCERT:合奏)")
+        private EMusicSheetType musicSheetType;
 
-        @ApiModelProperty(value = "曲库分类",required = true)
-        private String categoriesId;
+        @ApiModelProperty("音频文件")
+        private String audioFileUrl;
     }
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicScoreService.java

@@ -24,10 +24,14 @@ public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore
 
     List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
 
+    List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> queryCbsMusicSheetApplicationSimple(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
+
     PageInfo<CbsMusicSheetWrapper.MusicSheetAccApplication> queryCbsMusicSheetSoundApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
 
     List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<String> cbsMusicSheetIds);
 
+    List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> queryCbsMusicSheetApplicationSimple(List<String> cbsMusicSheetIds);
+
     //获取乐器名称
     List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> queryMusicalInstrument(List<Integer> musicalInstrumentIds);
 
@@ -37,6 +41,8 @@ public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore
     
     PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo);
 
+    PageInfo<SysMusicScore> queryMusicScorePageInfoSimple(SysExamSongQueryInfo queryInfo);
+
     Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds);
 
     Boolean stateList(ReasonDto reasonDto);

+ 89 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java

@@ -130,6 +130,20 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
     }
 
     @Override
+    public List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> queryCbsMusicSheetApplicationSimple(CbsMusicSheetWrapper.MusicSheetApplicationQuery query) {
+        R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplicationSimple>> pageInfoR =
+                musicFeignClientService.musicSheetPageByApplicationSimple(query);
+        if(pageInfoR.getCode() != 200){
+            throw new BizException("获取曲目信息失败");
+        }
+        com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplicationSimple> pageInfo = pageInfoR.getData();
+        if(pageInfo != null && CollectionUtils.isNotEmpty(pageInfo.getRows())){
+            return pageInfo.getRows();
+        }
+        return new ArrayList<>();
+    }
+
+    @Override
     public PageInfo<CbsMusicSheetWrapper.MusicSheetAccApplication> queryCbsMusicSheetSoundApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery query) {
         R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetAccApplication>> pageInfoR =
                 musicFeignClientService.musicSheetAccPageByApplication(query);
@@ -148,6 +162,14 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         return this.queryCbsMusicSheetApplication(query);
     }
 
+    @Override
+    public List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> queryCbsMusicSheetApplicationSimple(List<String> cbsMusicSheetIds){
+        CbsMusicSheetWrapper.MusicSheetApplicationQuery query = this.getMusicSheetApplicationQuery();
+        query.setMusicSheetIds(cbsMusicSheetIds.stream().map(Long::parseLong).collect(Collectors.toList()));
+        query.setRows(cbsMusicSheetIds.size());
+        return this.queryCbsMusicSheetApplicationSimple(query);
+    }
+
     //获取乐器名称
     @Override
     public List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> queryMusicalInstrument(List<Integer> musicalInstrumentIds){
@@ -164,6 +186,7 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         return infoR.getData().getRows();
     }
 
+
     private void dealMusicScoreData(List<SysMusicScore> records){
         if (CollectionUtils.isNotEmpty(records)) {
             List<String> cbsMusicSheetIds = records.stream().map(SysMusicScore::getCbsMusicSheetId).collect(Collectors.toList());
@@ -385,6 +408,72 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         }
         return pageInfo;
     }
+    @Override
+    public PageInfo<SysMusicScore> queryMusicScorePageInfoSimple(SysExamSongQueryInfo queryInfo) {
+        this.initCategoryIds(queryInfo);
+        if(queryInfo.getSubjectId() != null){
+            if(queryInfo.getSubjectId() == 5){
+                queryInfo.setSubjectId(null);
+                queryInfo.setSubjectIds("6");
+            }else if(queryInfo.getSubjectId() == 122){
+                queryInfo.setSubjectId(null);
+                queryInfo.setSubjectIds("122,121,113,23");
+            }else {
+                queryInfo.setSubjectIds(queryInfo.getSubjectId().toString());
+            }
+        }
+        if(CollectionUtils.isEmpty(queryInfo.getCategoriesIdList())){
+            return new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        }
+        PageInfo<MusicSheetWrapper.MusicSheetSimpleDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<MusicSheetWrapper.MusicSheetSimpleDto> dataList = null;
+        int count = this.findCount(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = this.getDAO().queryPage(params);
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        Map<String,SysMusicScore> cbsMusicSheetIds = rows.stream().collect(Collectors.toMap(SysMusicScore::getCbsMusicSheetId, Function.identity()));
+        List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> applications = this.queryCbsMusicSheetApplicationSimple(cbsMusicSheetIds);
+        if(CollectionUtils.isNotEmpty(applications)){
+
+        }
+        dealMusicScoreData(rows);
+
+        // 根据用户会员判断是否锁定,免费曲目为试用
+        List<Integer> categoryIds = new ArrayList<>();
+        if (queryInfo.getUserType()!=null && ClientEnum.STUDENT==queryInfo.getUserType()) {
+            // 查询有效的会员
+            List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(queryInfo.getUserId());
+
+            // 获取会员的曲目分类
+            List<MemberRankCategoryMapper> categoryMapperList = memberRankCategoryMapperService.getByMemberRankId(activationVipIds);
+            if (CollectionUtils.isEmpty(categoryMapperList)) {
+                categoryMapperList = new ArrayList<>();
+            }
+            categoryIds = categoryMapperList.stream().map(MemberRankCategoryMapper::getCategoryId).distinct().collect(Collectors.toList());
+
+        }
+
+        // 判断曲目是否在分类中
+        for (SysMusicScore row : rows) {
+            if (StringUtils.isBlank(row.getRankIds())) {
+                row.setUseStatus("FREE");
+            } else if (categoryIds.contains(row.getCbsMusicCategoriesId())) {
+                row.setUseStatus("UNLOCK");
+            } else {
+                row.setUseStatus("LOCK");
+            }
+        }
+        return pageInfo;
+    }
 
     @Override
     public Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds) {

+ 1 - 1
pom.xml

@@ -26,7 +26,7 @@
 		<docker.registry.repository>127.0.0.1:5000</docker.registry.repository>
 		<docker.maven.plugin.version>1.2.2</docker.maven.plugin.version>
 		<com.microsvc.toolkit.version>1.0.8-RC1</com.microsvc.toolkit.version>
-		<cbs.version>1.0.23</cbs.version>
+		<cbs.version>1.0.26</cbs.version>
 	</properties>
 
 	<dependencyManagement>