Ver código fonte

Merge branch 'feature/1108_audio' into develop-new

刘俊驰 5 meses atrás
pai
commit
914e6cbe39

+ 157 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/MusicSheetCbsController.java

@@ -0,0 +1,157 @@
+package com.yonge.cooleshow.student.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
+import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.dto.AppMusicSheetVo;
+import com.yonge.cooleshow.biz.dal.dto.search.MusicAlbumSearch;
+import com.yonge.cooleshow.biz.dal.dto.search.MusicSheetRelatedQueryInfo;
+import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
+import com.yonge.cooleshow.biz.dal.entity.Student;
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.MusicSortType;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum;
+import com.yonge.cooleshow.biz.dal.service.*;
+import com.yonge.cooleshow.biz.dal.vo.*;
+import com.yonge.cooleshow.biz.dal.wrapper.InstrumentWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.music.MusicCompareWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.common.enums.YesOrNoEnum;
+import com.yonge.toolset.base.exception.BizException;
+import com.yonge.toolset.base.page.PageInfo;
+import com.yonge.toolset.base.page.QueryInfo;
+import com.yonge.toolset.base.util.StringUtil;
+import com.yonge.toolset.mybatis.support.PageUtil;
+import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
+import io.swagger.annotations.*;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 曲谱表 web 控制层
+ * @author yzp
+ * @date 2022-03-26 00:21:46
+ * @version v1.0
+ **/
+@RestController
+@RequestMapping("${app-config.url.student:}/musicSheet")
+@Api(tags = "曲谱表 API接口")
+public class MusicSheetCbsController extends BaseController {
+    @Resource
+    private SysUserFeignService sysUserFeignService;
+
+	@Resource
+	private MusicSheetService musicSheetService;
+
+    @Resource
+    private AppVersionInfoService appVersionInfoService;
+
+    @Resource
+    private StudentService studentService;
+
+    @Autowired
+    private InstrumentService instrumentService;
+
+
+    /**
+     * 查询单条
+     *
+     * @param id 详情ID
+     * @return R<MusicSheetVo.MusicSheet>
+     */
+    @ApiOperation(value = "查询内容平台数据")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @GetMapping("/cbsDetail/{id}")
+    public R<MusicSheetVo.MusicSheetDetail> cbsDetail(@PathVariable("id") Long id) {
+
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null  || sysUser.getId() == null) {
+            sysUser = null;
+        }
+        CbsMusicSheetWrapper.MusicSheet musicSheet = musicSheetService.cbsDetail(id);
+        musicSheet.setBizId(id);
+
+        MusicSheetVo.MusicSheetDetail musicSheetDetail = JSON.parseObject(JSON.toJSONString(musicSheet), MusicSheetVo.MusicSheetDetail.class);
+        MusicSheetDetailVo detail = musicSheetService.detail(id.toString(), sysUser, ClientEnum.STUDENT, null);
+        if (detail == null) {
+//            musicSheetDetail.setBizMusicCategoryId(null);
+        } else {
+            // 设置曲目付费类型
+            musicSheetDetail.setPaymentType(detail.getPaymentType());
+            // 设置业务端曲目分类
+//            musicSheetDetail.setBizMusicCategoryId(detail.getCategoriesId() == null ? null : detail.getCategoriesId().longValue());
+            musicSheetDetail.setScoreType(detail.getScoreType());
+            musicSheetDetail.setIsConvertibleScore(detail.getNotation() ==YesOrNoEnum.YES);
+            musicSheetDetail.setPlay(detail.getPlay());
+            musicSheetDetail.setBuyed(detail.getBuyed());
+        }
+
+        // 如果是合奏 并且乐器ID = 2268
+        musicSheetDetail.setSpecialPercussionFlag(false);
+
+        // 设置乐器信息
+        if (StringUtils.isNotBlank(musicSheetDetail.getMusicalInstrumentIds())) {
+            List<Long> instrumentIds = Arrays.stream(musicSheetDetail.getMusicalInstrumentIds().split(","))
+                .map(Long::parseLong).collect(Collectors.toList());
+
+            if (CollectionUtils.isNotEmpty(instrumentIds) && CollectionUtils.isNotEmpty(musicSheetDetail.getMusicalInstruments())) {
+                Map<Long, InstrumentWrapper.Instrument> instrumentMap = instrumentService.getMapByIds(instrumentIds);
+                for (CbsMusicSheetWrapper.MusicalInstrument musicalInstrument : musicSheetDetail.getMusicalInstruments()) {
+                    InstrumentWrapper.Instrument instrument = instrumentMap.get(musicalInstrument.getId().longValue());
+                    if (instrument != null) {
+                        musicalInstrument.setOrientation(instrument.getOrientation());
+                    }
+
+                }
+            }
+        }
+        return R.from(musicSheetDetail);
+    }
+
+    @ApiOperation(value = "查询分页", notes = "曲谱表- 传入 MusicSheetVo.MusicSheetQuery")
+    @PostMapping("/page")
+    public HttpResponseResult<PageInfo<MusicSheetWrapper.MusicSheetCloud>> cloudPage(@RequestBody MusicSheetWrapper.MusicSheetCloudQuery query) {
+
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        Student student = studentService.getById(sysUser.getId());
+        if (student == null) {
+            return failed("用户信息获取失败");
+        }
+
+        // 检查app版本
+        YesOrNoEnum appAuditVersion = appVersionInfoService.getAppAuditVersion(query.getPlatform(), query.getVersion());
+        // 学生 只能看通过审核 并且 启用的 曲目
+        query.setDelFlag(false);
+        query.setVersionFlag(appAuditVersion == YesOrNoEnum.YES);
+        query.setStatus(true);
+
+        // 如果是机构学生
+        if (student.getTenantId() !=null && student.getTenantId()>0) {
+            query.setProviderType(SourceTypeEnum.TENANT);
+        } else {
+            query.setProviderType(SourceTypeEnum.PLATFORM);
+        }
+        IPage<MusicSheetWrapper.MusicSheetCloud> musicSheetCloudIPage = musicSheetService.cloudPage(query);
+        return HttpResponseResult.succeed(PageUtil.pageInfo(musicSheetCloudIPage));
+    }
+}