|
@@ -2,6 +2,8 @@ package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.MusicSheetAccompanimentService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -13,6 +15,7 @@ import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
|
|
|
import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
|
|
|
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 曲谱表 web 控制层
|
|
@@ -30,18 +33,41 @@ public class MusicSheetController extends BaseController {
|
|
|
@Autowired
|
|
|
private MusicSheetService musicSheetService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MusicSheetAccompanimentService musicSheetAccompanimentService;
|
|
|
+
|
|
|
@ApiOperation(value = "新增曲谱")
|
|
|
- @PostMapping("/create")
|
|
|
+ @RequestMapping(value = "/create", method = RequestMethod.POST, consumes="application/json", produces="application/json")
|
|
|
public Object create(@Valid @RequestBody MusicSheet musicSheet) {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
if (sysUser == null) {
|
|
|
return failed("用户信息获取失败");
|
|
|
}
|
|
|
|
|
|
+ List<MusicSheetAccompaniment> list = null;
|
|
|
+ if (!musicSheet.getAudioType().equalsIgnoreCase("midi")){
|
|
|
+ list = musicSheet.getBackground();
|
|
|
+ if (list.isEmpty()){
|
|
|
+ return failed("mp3音频文件对应的主音或者伴奏文件没有提供");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
musicSheet.setCreateBy(sysUser.getId());
|
|
|
musicSheet.setCreateTime(new Date());
|
|
|
musicSheetService.insert(musicSheet);
|
|
|
- return succeed();
|
|
|
+
|
|
|
+ Long sheetId = musicSheet.getId();
|
|
|
+ if (!musicSheet.getAudioType().equalsIgnoreCase("midi")) {
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ MusicSheetAccompaniment musicSheetAccompaniment = list.get(i);
|
|
|
+ musicSheetAccompaniment.setCreateBy(sysUser.getId());
|
|
|
+ musicSheetAccompaniment.setCreateTime(new Date());
|
|
|
+ musicSheetAccompaniment.setMusicSheetId(sheetId);
|
|
|
+ musicSheetAccompanimentService.insert(musicSheetAccompaniment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return succeed("曲谱创建成功");
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除曲谱")
|