فهرست منبع

酷乐秀曲目来源改为内容平台

zouxuan 1 سال پیش
والد
کامیت
adfa3af536

+ 7 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicSheetAccompaniment.java

@@ -37,6 +37,13 @@ public class MusicSheetAccompaniment extends BaseEntity {
     @ApiModelProperty(value = "声部")
     private String musicSubjectId;  //声部
 
+    @TableField("musical_instrument_id_")
+    @ApiModelProperty("声轨乐器")
+    private String musicalInstrumentId;
+
+    @ApiModelProperty("声轨乐器")
+    private String musicalInstrumentName;
+
     @TableField("audio_file_url_")
     @ApiModelProperty(value = "MP3原声音频文件URL")
     private String audioFileUrl;  //MP3原声音频文件URL

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/InstrumentService.java

@@ -47,6 +47,8 @@ public interface InstrumentService extends IService<Instrument>  {
 
     Map<Long,InstrumentWrapper.Instrument> getMapByIds(List<Long> instrumentIdList);
 
+    List<InstrumentWrapper.Instrument> getInstruments(List<Long> instrumentIdList);
+
     Map<Integer,List<InstrumentWrapper.Instrument>> getGroupBySubjectId(List<Integer> subjectIds, Boolean enableFlag);
 
     List<InstrumentWrapper.Instrument> getList(InstrumentWrapper.InstrumentQuery query);

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/InstrumentServiceImpl.java

@@ -14,7 +14,6 @@ import com.yonge.cooleshow.biz.dal.service.InstrumentService;
 import com.yonge.cooleshow.biz.dal.service.SubjectService;
 import com.yonge.cooleshow.biz.dal.wrapper.InstrumentWrapper;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -112,7 +111,8 @@ public class InstrumentServiceImpl extends ServiceImpl<InstrumentDao, Instrument
         return instrumentList.stream().collect(Collectors.toMap(InstrumentWrapper.Instrument::getId, Function.identity()));
     }
 
-    private List<InstrumentWrapper.Instrument> getInstruments(List<Long> instrumentIdList) {
+    @Override
+    public List<InstrumentWrapper.Instrument> getInstruments(List<Long> instrumentIdList) {
         instrumentIdList = instrumentIdList.stream().filter(Objects::nonNull).collect(Collectors.toList());
         Map<Long, Instrument> idImstrumentMap = this.lambdaQuery().in(Instrument::getId, instrumentIdList).list()
             .stream().collect(Collectors.toMap(Instrument::getId, Function.identity()));

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetAccompanimentServiceImpl.java

@@ -64,6 +64,7 @@ public class MusicSheetAccompanimentServiceImpl extends ServiceImpl<MusicSheetAc
             accompaniment.setSortNumber(sound.getSortNumber());
             accompaniment.setTrack(sound.getTrack());
             accompaniment.setMusicSheetId(musicSheetId);
+            accompaniment.setMusicalInstrumentId(sound.getMusicalInstrumentId());
             background.add(accompaniment);
         }
         return background;

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

@@ -117,6 +117,8 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
     @Resource
     private SubjectService subjectService;
     @Resource
+    private InstrumentService instrumentService;
+    @Resource
     private TeacherService teacherService;
     @Resource
     private CourseCoursewareService courseCoursewareService;
@@ -567,6 +569,32 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             throw new BizException("未找到曲目信息");
         }
         if(detailVo.getDelFlag()){
+            //获取乐器名称
+            List<MusicSheetAccompaniment> background = detailVo.getBackground();
+            if (CollectionUtils.isNotEmpty(background)) {
+                String instrumentIds = background.stream().map(e -> e.getMusicalInstrumentId()).filter(StringUtils::isNotEmpty).collect(Collectors.joining(","));
+                if (StringUtils.isNotEmpty(instrumentIds)) {
+                    List<Long> instrumentIsList = Arrays.stream(instrumentIds.split(",")).map(Long::valueOf).distinct().collect(Collectors.toList());
+                    List<InstrumentWrapper.Instrument> instruments = instrumentService.getInstruments(instrumentIsList);
+                    Map<Long,InstrumentWrapper.Instrument> instrumentMap =
+                            instruments.stream().collect(Collectors.toMap(InstrumentWrapper.Instrument::getId, o -> o, (o1, o2) -> o1));
+                    for (MusicSheetAccompaniment accompaniment : background) {
+                        if (StringUtils.isNotEmpty(accompaniment.getMusicalInstrumentId())){
+                            StringBuffer sb = new StringBuffer();
+                            for (String s : accompaniment.getMusicalInstrumentId().split(",")) {
+                                InstrumentWrapper.Instrument instrument = instrumentMap.get(Long.parseLong(s));
+                                if (instrument != null){
+                                    if(sb.length() > 0) {
+                                        sb.append(",");
+                                    }
+                                    sb.append(instrument.getName());
+                                }
+                            }
+                            accompaniment.setMusicalInstrumentName(sb.toString());
+                        }
+                    }
+                }
+            }
             return detailVo;
         }
         MusicSheetDetailVo detail = this.getCbsDetail(id);

+ 0 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/InstrumentWrapper.java

@@ -26,14 +26,10 @@ public class InstrumentWrapper {
     @AllArgsConstructor
     @ApiModel(" InstrumentQuery-乐器设置")
     public static class InstrumentQuery implements QueryInfo {
-
     	@ApiModelProperty("当前页")
         private Integer page;
-
         @ApiModelProperty("分页行数")
         private Integer rows;
-
-
         @ApiModelProperty("声部")
         private Integer subjectId;
         @ApiModelProperty("声部")
@@ -41,8 +37,6 @@ public class InstrumentWrapper {
         @ApiModelProperty("是否启用")
         private Boolean enableFlag;
 
-
-
         public String jsonString() {
             return JSON.toJSONString(this);
         }

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/MusicSheetAccompanimentWrapper.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.wrapper;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -47,7 +48,7 @@ public class MusicSheetAccompanimentWrapper {
         public static MusicSheetAccompanimentQuery from(String json) {
             return JSON.parseObject(json, MusicSheetAccompanimentQuery.class);
         }
-    }  
+    }
 
     @Data
     @Builder

+ 2 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetAccompanimentMapper.xml

@@ -7,6 +7,7 @@
 	     <id column="id_" jdbcType="BIGINT" property="id" />
 		 <result column="music_sheet_id_" jdbcType="BIGINT" property="musicSheetId" />
 		 <result column="music_subject_" jdbcType="VARCHAR" property="musicSubjectId" />
+		 <result column="musical_instrument_id_" jdbcType="VARCHAR" property="musicalInstrumentId" />
 		 <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl" />
 		 <result column="sort_number_" jdbcType="TINYINT" property="sortNumber" />
 		 <result column="speed_" jdbcType="TINYINT" property="speed" />
@@ -15,7 +16,7 @@
 	</resultMap>
 
 	<sql id="Base_Column_List">
-		id_, music_sheet_id_, music_subject_, audio_file_url_, sort_number_,speed_, create_time_, create_by_
+		id_, music_sheet_id_, music_subject_, audio_file_url_, sort_number_,speed_,musical_instrument_id_, create_time_, create_by_
 	</sql>
 
 	<delete id="delByMusicSheetId">

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

@@ -314,6 +314,7 @@
             ,msa.sort_number_ as accompanimentSortNumber
             ,msa.create_time_ as accompanimentCreateTime
             ,msa.track_ as track
+            ,msa.musical_instrument_id_ as musicalInstrumentId
             ,su.username_ as userName
             ,su.avatar_ as userAvatar
             ,(
@@ -398,6 +399,7 @@
             <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
             <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
             <result column="track" jdbcType="VARCHAR" property="track"/>
+            <result column="musicalInstrumentId" jdbcType="VARCHAR" property="musicalInstrumentId"/>
         </collection>
     </resultMap>