Ver Fonte

曲目列表接口优化

zouxuan há 4 meses atrás
pai
commit
b40a715da1

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

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.ClientTypeEnum;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
+import com.ym.mec.biz.dal.wrapper.MusicSheetWrapper;
 import com.ym.mec.biz.service.SysMusicScoreService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.biz.service.TeacherService;
@@ -53,7 +54,7 @@ public class SysMusicScoreController extends BaseController {
 
     @ApiOperation(value = "分页查询简化")
     @GetMapping("/queryPageSimple")
-    public HttpResponseResult<PageInfo<SysMusicScore>> queryPageSimple(SysExamSongQueryInfo queryInfo) {
+    public HttpResponseResult<PageInfo<MusicSheetWrapper.MusicSheetSimpleDto>> queryPageSimple(SysExamSongQueryInfo queryInfo) {
         //判断用户是否可以访问云练习
         Integer userId = sysUserService.getUserId();
         Teacher teacher = teacherDao.get(userId);

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicScoreDao.java

@@ -9,6 +9,7 @@ import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface SysMusicScoreDao extends BaseDAO<Integer, SysMusicScore> {
 
@@ -35,4 +36,8 @@ public interface SysMusicScoreDao extends BaseDAO<Integer, SysMusicScore> {
     SysMusicScore getCbsId(@Param("cbsMusicSheetId") Long cbsMusicSheetId);
 
     List<MusicSheetWrapper.CategoryMusicNumStat> getNumByCategoryIds(@Param("categoryIds") List<Integer> categoryIds);
+
+    List<MusicSheetWrapper.MusicSheetSimpleDto> queryPageSimple(@Param("params") Map<String, Object> params);
+
+    int findCountSimple(@Param("params") Map<String, Object> params);
 }

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

@@ -539,15 +539,15 @@ public class MusicSheetWrapper {
         @ApiModelProperty("主键")
         private Long id;
 
+        @ApiModelProperty("内容平台曲目ID")
+        private String cbsMusicSheetId;
+
         @ApiModelProperty("曲目封面图")
         private String titleImg;
 
         @ApiModelProperty("曲目名称")
         private String name;
 
-        @ApiModelProperty("曲目类型(SINGLE:单曲 CONCERT:合奏)")
-        private EMusicSheetType musicSheetType;
-
         @ApiModelProperty("音频文件")
         private String audioFileUrl;
     }

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

@@ -41,7 +41,7 @@ public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore
     
     PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo);
 
-    PageInfo<SysMusicScore> queryMusicScorePageInfoSimple(SysExamSongQueryInfo queryInfo);
+    PageInfo<MusicSheetWrapper.MusicSheetSimpleDto> queryMusicScorePageInfoSimple(SysExamSongQueryInfo queryInfo);
 
     Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds);
 

+ 15 - 35
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java

@@ -409,7 +409,7 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         return pageInfo;
     }
     @Override
-    public PageInfo<SysMusicScore> queryMusicScorePageInfoSimple(SysExamSongQueryInfo queryInfo) {
+    public PageInfo<MusicSheetWrapper.MusicSheetSimpleDto> queryMusicScorePageInfoSimple(SysExamSongQueryInfo queryInfo) {
         this.initCategoryIds(queryInfo);
         if(queryInfo.getSubjectId() != null){
             if(queryInfo.getSubjectId() == 5){
@@ -430,48 +430,28 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         MapUtil.populateMap(params, queryInfo);
 
         List<MusicSheetWrapper.MusicSheetSimpleDto> dataList = null;
-        int count = this.findCount(params);
+        int count = sysMusicScoreDao.findCountSimple(params);
         if (count > 0) {
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
-            dataList = this.getDAO().queryPage(params);
+            dataList = sysMusicScoreDao.queryPageSimple(params);
+            List<String> cbsMusicSheetIds = dataList.stream().map(MusicSheetWrapper.MusicSheetSimpleDto::getCbsMusicSheetId).collect(Collectors.toList());
+            List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> applications = this.queryCbsMusicSheetApplicationSimple(cbsMusicSheetIds);
+            if(CollectionUtils.isNotEmpty(applications)){
+                Map<Long, CbsMusicSheetWrapper.MusicSheetApplicationSimple> musicSheetApplicationMap = applications
+                        .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplicationSimple::getId, Function.identity()));
+                for (MusicSheetWrapper.MusicSheetSimpleDto record : dataList) {
+                    CbsMusicSheetWrapper.MusicSheetApplicationSimple simple = musicSheetApplicationMap.get(Long.parseLong(record.getCbsMusicSheetId()));
+                    record.setAudioFileUrl(simple.getAudioFileUrl());
+                    record.setName(simple.getName());
+                    record.setTitleImg(simple.getTitleImg());
+                }
+            }
         }
         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;
     }
 

+ 39 - 0
mec-biz/src/main/resources/config/mybatis/SysMusicScoreMapper.xml

@@ -357,4 +357,43 @@
         and del_flag_ = 0 and cbs_music_sheet_id_ is not null GROUP BY cbs_music_categories_id_
 
     </select>
+	<select id="queryPageSimple" resultType="com.ym.mec.biz.dal.wrapper.MusicSheetWrapper$MusicSheetSimpleDto">
+		SELECT ses.cbs_music_sheet_id_ cbsMusicSheetId,ses.id_ id
+		FROM sys_music_score ses
+		<include refid="queryPageSqlSimple"/>
+		order by ses.sort_group_, ses.sort_num_, ses.sort_num2_, ses.alias_
+		<include refid="global.limit"/>
+	</select>
+	<select id="findCountSimple" resultType="java.lang.Integer">
+		SELECT COUNT(0) FROM sys_music_score ses
+		<include refid="queryPageSqlSimple"/>
+	</select>
+
+
+	<sql id="queryPageSqlSimple">
+		<where>
+			ses.del_flag_ = 0 AND ses.cbs_music_sheet_id_ IS NOT NULL
+			<if test="categoriesIdList != null">
+				AND ses.cbs_music_categories_id_ IN
+				<foreach collection="categoriesIdList" separator="," item="item" open="(" close=")">
+					#{item}
+				</foreach>
+			</if>
+			<if test="search != null and search != ''">
+				AND (ses.cbs_music_sheet_id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
+			</if>
+			<if test="clientFlag != null and clientFlag == true">
+				AND ses.client_show_flag_ = true AND ses.show_flag_ = true
+			</if>
+			<if test="subjectIds != null and subjectIds != ''">
+				AND (INTE_ARRAY(#{subjectIds},ses.subject_ids_) OR ses.subject_ids_ IS NULL OR ses.subject_ids_ = '' OR ses.is_all_subject_)
+			</if>
+			<if test="clientType != null">
+				AND ses.client_type_ = #{clientType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+			</if>
+			<if test="type != null and type == 'COMMON'">
+				AND ses.type_ = #{type}
+			</if>
+		</where>
+	</sql>
 </mapper>