|
|
@@ -0,0 +1,116 @@
|
|
|
+package com.yonge.cooleshow.teacher.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.MusicSheetDto;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.search.MusicSheetSearch;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.AuditEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.ChargeTypeEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.StateEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
|
|
|
+import com.yonge.cooleshow.biz.dal.support.Condition;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.MusicSheetShareVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
|
|
|
+import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.common.page.PageInfo;
|
|
|
+import com.yonge.toolset.utils.string.StringUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 曲谱表 web 控制层
|
|
|
+ * @author yzp
|
|
|
+ * @date 2022-03-26 00:21:46
|
|
|
+ * @version v1.0
|
|
|
+ **/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/music/sheet")
|
|
|
+@Api(tags = "曲谱表 API接口")
|
|
|
+public class MusicSheetController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicSheetService musicSheetService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询单条
|
|
|
+ */
|
|
|
+ @GetMapping("/detail/{id}")
|
|
|
+ @ApiOperation(value = "详情", notes = "传入musicTag")
|
|
|
+ public HttpResponseResult<MusicSheetVo> detail(@ApiParam(value = "曲谱编号", required = true) @PathVariable("id") Long id) {
|
|
|
+ return succeed(musicSheetService.detail(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增", httpMethod="POST", consumes="application/json", produces="application/json")
|
|
|
+ @PostMapping(value="/create", consumes="application/json", produces="application/json")
|
|
|
+ public HttpResponseResult<Object> create(@Valid @RequestBody MusicSheetDto musicSheetDto) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ChargeTypeEnum.CHARGE.getCode().equals(musicSheetDto.getChargeType().getCode())
|
|
|
+ && musicSheetDto.getMusicPrice()==null){
|
|
|
+ return failed("此曲谱为收费曲谱,需要提供价格");
|
|
|
+ }
|
|
|
+
|
|
|
+ musicSheetDto.setUserId(sysUser.getId());
|
|
|
+ List<MusicSheetAccompaniment> list;
|
|
|
+ if (!musicSheetDto.getAudioType().equalsIgnoreCase("midi")){
|
|
|
+ list = musicSheetDto.getBackground();
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ return failed("mp3音频文件对应的主音或者伴奏文件没有提供");
|
|
|
+ }
|
|
|
+ musicSheetService.saveMp3AndAccompaniment(musicSheetDto,sysUser);
|
|
|
+ } else {
|
|
|
+ MusicSheet musicSheet = new MusicSheet();
|
|
|
+ BeanUtils.copyProperties(musicSheetDto, musicSheet);
|
|
|
+ musicSheet.setAuditStatus(AuditEnum.AUDITING);
|
|
|
+ musicSheet.setCreateBy(sysUser.getId());
|
|
|
+ musicSheet.setCreateTime(new Date());
|
|
|
+ musicSheet.setState(StateEnum.STOP);
|
|
|
+ musicSheetService.save(musicSheet);
|
|
|
+ }
|
|
|
+ return succeed("新增曲谱成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "分页查询", httpMethod="POST", consumes="application/json", produces="application/json")
|
|
|
+ @PostMapping(value="/list", consumes="application/json", produces="application/json")
|
|
|
+ public HttpResponseResult<PageInfo<MusicSheetVo>> list(@RequestBody MusicSheetSearch query) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
+ }
|
|
|
+ // 设置只查老师用户 状态为启用
|
|
|
+ query.setCreateBy(sysUser.getId());
|
|
|
+ query.setState(StateEnum.ENABLE);
|
|
|
+
|
|
|
+ IPage<MusicSheetVo> musicSheetVoIPage = musicSheetService.selectPage(Condition.getPage(query), query);
|
|
|
+ return succeed(Condition.pageInfo(musicSheetVoIPage));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "乐谱分享")
|
|
|
+ @GetMapping(value="/share")
|
|
|
+ public HttpResponseResult<MusicSheetShareVo> shareMusicSheet() {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
+ }
|
|
|
+ return succeed(musicSheetService.shareMusicSheet(sysUser));
|
|
|
+ }
|
|
|
+}
|