|
|
@@ -1,24 +1,34 @@
|
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import javax.validation.Valid;
|
|
|
+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.auth.api.enums.SysUserType;
|
|
|
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.AudioTypeEnum;
|
|
|
+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.vo.MusicSheetDetailVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.support.PageUtil;
|
|
|
+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.web.bind.annotation.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
|
|
|
-import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -38,6 +48,20 @@ public class MusicSheetController extends BaseController {
|
|
|
@Autowired
|
|
|
private MusicSheetService musicSheetService;
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询单条
|
|
|
+ */
|
|
|
+ @GetMapping("/detail/{id}")
|
|
|
+ @ApiOperation(value = "详情", notes = "传入musicTag")
|
|
|
+ public HttpResponseResult<MusicSheetDetailVo> detail(@ApiParam(value = "曲谱编号", required = true) @PathVariable("id") Long id) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
+ }
|
|
|
+ return succeed(musicSheetService.detail(id, sysUser, SysUserType.SYSTEM));
|
|
|
+ }
|
|
|
+
|
|
|
@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) {
|
|
|
@@ -46,32 +70,34 @@ public class MusicSheetController extends BaseController {
|
|
|
return failed("用户信息获取失败");
|
|
|
}
|
|
|
|
|
|
- if (musicSheetDto.getChargeType()==2 && musicSheetDto.getMusicPrice()==null){
|
|
|
+ if (ChargeTypeEnum.CHARGE.getCode().equals(musicSheetDto.getChargeType().getCode())
|
|
|
+ && musicSheetDto.getMusicPrice()==null){
|
|
|
return failed("此曲谱为收费曲谱,需要提供价格");
|
|
|
}
|
|
|
+ if (StringUtil.isEmpty(musicSheetDto.getMusicSubject())) {
|
|
|
+ return failed("曲目声部不能为空");
|
|
|
+ }
|
|
|
|
|
|
- List<MusicSheetAccompaniment> list = null;
|
|
|
- if (!musicSheetDto.getAudioType().equalsIgnoreCase("midi")){
|
|
|
+ musicSheetDto.setUserId(0L);
|
|
|
+ List<MusicSheetAccompaniment> list;
|
|
|
+ if (!AudioTypeEnum.MIDI.getCode().equals(musicSheetDto.getAudioType().getCode())){
|
|
|
list = musicSheetDto.getBackground();
|
|
|
- if (list.isEmpty()){
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
return failed("mp3音频文件对应的主音或者伴奏文件没有提供");
|
|
|
}
|
|
|
+ musicSheetService.saveMp3AndAccompaniment(musicSheetDto,sysUser);
|
|
|
} else {
|
|
|
MusicSheet musicSheet = new MusicSheet();
|
|
|
BeanUtils.copyProperties(musicSheetDto, musicSheet);
|
|
|
- musicSheet.setAuditStatus(0);
|
|
|
+ musicSheet.setAuditStatus(AuditEnum.AUDITING);
|
|
|
musicSheet.setCreateBy(sysUser.getId());
|
|
|
- musicSheet.setUserId(sysUser.getId());
|
|
|
musicSheet.setCreateTime(new Date());
|
|
|
+ musicSheet.setState(StateEnum.STOP);
|
|
|
musicSheetService.save(musicSheet);
|
|
|
}
|
|
|
|
|
|
- boolean result = musicSheetService.saveMp3AndAccompaniment(musicSheetDto,sysUser);
|
|
|
- if (result) {
|
|
|
- return succeed("新增曲谱成功");
|
|
|
- } else {
|
|
|
- return failed("新增曲谱失败");
|
|
|
- }
|
|
|
+ return succeed("新增曲谱成功");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除", httpMethod="POST", consumes="application/json", produces="application/json")
|
|
|
@@ -113,38 +139,26 @@ public class MusicSheetController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "分页查询", httpMethod="POST", consumes="application/json", produces="application/json")
|
|
|
@PostMapping(value="/list", consumes="application/json", produces="application/json")
|
|
|
- public HttpResponseResult<Object> list(@RequestBody MusicSheetDto musicSheetDto) {
|
|
|
+ public HttpResponseResult<PageInfo<MusicSheetVo>> list(@RequestBody MusicSheetSearch query) {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
if (sysUser == null) {
|
|
|
return failed("用户信息获取失败");
|
|
|
}
|
|
|
|
|
|
- int pageNo;
|
|
|
- int pageSize;
|
|
|
+ IPage<MusicSheetVo> musicSheetVoIPage = musicSheetService.selectPage(PageUtil.getPage(query), query);
|
|
|
+ return succeed(PageUtil.pageInfo(musicSheetVoIPage));
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- if (musicSheetDto.getPageNo() ==null || musicSheetDto.getPageNo() ==0) {
|
|
|
- pageNo = 1;
|
|
|
- } else {
|
|
|
- pageNo = musicSheetDto.getPageNo();
|
|
|
- }
|
|
|
- if (musicSheetDto.getPageSize() ==null || musicSheetDto.getPageSize() ==0) {
|
|
|
- pageSize = 10;
|
|
|
- } else {
|
|
|
- pageSize = musicSheetDto.getPageSize();
|
|
|
- }
|
|
|
|
|
|
- LambdaQueryWrapper<MusicSheet> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
- lambdaQueryWrapper.or().like(MusicSheet::getMusicSheetName , musicSheetDto.getSearch());
|
|
|
- lambdaQueryWrapper.or().like(MusicSheet::getComposer , musicSheetDto.getSearch());
|
|
|
- lambdaQueryWrapper.or().like(MusicSheet::getMusicTag , musicSheetDto.getSearch());
|
|
|
- lambdaQueryWrapper.or().like(MusicSheet::getMusicSubject , musicSheetDto.getSearch());
|
|
|
-
|
|
|
- Page<MusicSheet> page = new Page<>(pageNo,pageSize);
|
|
|
- return succeed(musicSheetService.page(page, lambdaQueryWrapper));
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return HttpResponseResult.failed(e.getMessage());
|
|
|
+ /**
|
|
|
+ * 启用/停用
|
|
|
+ */
|
|
|
+ @PostMapping("/state")
|
|
|
+ @ApiOperation(value = "启用/停用", notes = "传入id")
|
|
|
+ public HttpResponseResult<Boolean> state(@ApiParam(value = "曲目编号", required = true) @RequestParam Long id) {
|
|
|
+ if (StringUtil.isEmpty(id)) {
|
|
|
+ return failed("参数不能为空");
|
|
|
}
|
|
|
+ return status(musicSheetService.state(id));
|
|
|
}
|
|
|
}
|