|
@@ -1,12 +1,15 @@
|
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
import com.yonge.cooleshow.admin.io.request.TenantAlbumVo;
|
|
|
-import com.yonge.cooleshow.api.feign.dto.TenantWrapper;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbum;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbumRef;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantAlbumRefService;
|
|
@@ -21,14 +24,16 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -62,70 +67,55 @@ public class TenantAlbumController {
|
|
|
*/
|
|
|
@PostMapping("/page")
|
|
|
@ApiOperation(value = "查询分页", notes = "tenantAlbum")
|
|
|
- //@PreAuthorize("@pcs.hasPermissions('tenantAlbum/page')")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantAlbum/page')")
|
|
|
public HttpResponseResult<PageInfo<TenantAlbumWrapper.TenantAlbum>> page(@RequestBody TenantAlbumWrapper.TenantAlbumQuery query) {
|
|
|
-
|
|
|
-
|
|
|
IPage<TenantAlbumWrapper.TenantAlbum> pages = tenantAlbumService.selectPage(QueryInfo.getPage(query), query);
|
|
|
return HttpResponseResult.succeed(PageUtil.pageInfo(pages));
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询详情
|
|
|
- * @param query 详情ID
|
|
|
+ *
|
|
|
+ * @param id 详情ID
|
|
|
* @return TenantAlbum
|
|
|
*/
|
|
|
@PostMapping("/detail")
|
|
|
@ApiOperation(value = "查询详情", notes = "detail")
|
|
|
- //@PreAuthorize("@pcs.hasPermissions('tenantAlbum/detail')")
|
|
|
- public HttpResponseResult<TenantAlbumVo.TenantAlbum> detail(@RequestBody TenantAlbumVo.TenantAlbum query) {
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detail')")
|
|
|
+ public HttpResponseResult<TenantAlbumWrapper.TenantAlbum> detail(@RequestParam("id") Long id) {
|
|
|
+ TenantAlbum tenantAlbum = tenantAlbumService.detail(id);
|
|
|
+ if (tenantAlbum == null) {
|
|
|
+ throw new BizException("专辑信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(tenantAlbum),
|
|
|
+ TenantAlbumWrapper.TenantAlbum.class);
|
|
|
|
|
|
- TenantAlbumVo.TenantAlbum vo = new TenantAlbumVo.TenantAlbum();
|
|
|
- Long id = query.getId();
|
|
|
- TenantAlbum tenantAlbum= tenantAlbumService.detail(id);
|
|
|
//查关联表
|
|
|
- TenantAlbumRef ref = tenantAlbumRefService.getBytenantAlbumId(id);
|
|
|
- vo.setTenantId(ref.getTenantId());
|
|
|
- //查询机构专辑表
|
|
|
- vo.setName(tenantAlbum.getName());
|
|
|
- vo.setDescribe(tenantAlbum.getDescribe());
|
|
|
- vo.setCoverImg(tenantAlbum.getCoverImg());
|
|
|
- vo.setPurchaseCycle(tenantAlbum.getPurchaseCycle());
|
|
|
- vo.setSalePrice(tenantAlbum.getSalePrice());
|
|
|
+ TenantAlbumRef one = tenantAlbumRefService.lambdaQuery().eq(TenantAlbumRef::getTenantAlbumId, id)
|
|
|
+ .last("limit").one();
|
|
|
+ vo.setTenantId(one.getTenantId());
|
|
|
//查询曲目表
|
|
|
|
|
|
- List<TenantAlbumVo.MusicSheetData> data = query.getMusicSheetData();
|
|
|
-
|
|
|
- List<TenantAlbumMusic> tenantAlbumMusics = query.getMusicSheetData().stream().map(next -> {
|
|
|
+ List<TenantAlbumMusic> tenantAlbumMusics = tenantAlbumMusicService.lambdaQuery()
|
|
|
+ .eq(TenantAlbumMusic::getTenantAlbumId, id)
|
|
|
+ .eq(TenantAlbumMusic::getDelFlag, false)
|
|
|
+ .list();
|
|
|
|
|
|
- AtomicInteger sort = new AtomicInteger(0);
|
|
|
- return next.getMusicSheetIdList().stream().map(tenantAlbumMusic -> {
|
|
|
+ Map<SubjectTypeEnum, List<TenantAlbumMusic>> groupByType =
|
|
|
+ tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
|
|
|
|
|
|
- TenantAlbumMusic tenantAlbumMusic1 = new TenantAlbumMusic();
|
|
|
- //tenantAlbumMusic1.setId(tenantAlbumMusic);
|
|
|
- tenantAlbumMusic1.setSubjectType(next.getSubjectType());
|
|
|
- tenantAlbumMusic1.setTenantId(query.getTenantId());
|
|
|
- tenantAlbumMusic1.setMusicSheetId(tenantAlbumMusic);
|
|
|
- tenantAlbumMusic1.setDelFlag(true);
|
|
|
- tenantAlbumMusic1.setTenantAlbumId(tenantAlbum.getId());
|
|
|
- tenantAlbumMusic1.setSortNumber(sort.getAndIncrement());
|
|
|
- return tenantAlbumMusic1;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ List<TenantAlbumWrapper.MusicSheetData> musicSheetData = vo.getMusicSheetData();
|
|
|
+ groupByType.forEach((key, value) -> {
|
|
|
+ value.sort(Comparator.comparing(TenantAlbumMusic::getSortNumber));
|
|
|
+ TenantAlbumWrapper.MusicSheetData sheetData = new TenantAlbumWrapper.MusicSheetData();
|
|
|
+ sheetData.setSubjectType(key);
|
|
|
+ sheetData.setMusicSheetList(value);
|
|
|
+ musicSheetData.add(sheetData);
|
|
|
|
|
|
- }).flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
+ });
|
|
|
|
|
|
-
|
|
|
- vo.setTenantAlbumMusics(tenantAlbumMusics);
|
|
|
-
|
|
|
-/* List<TenantAlbumVo.MusicSheetData> dataList = query.getMusicSheetData();
|
|
|
- TenantAlbumVo.MusicSheetData data = dataList.get(0);
|
|
|
- List<Long> list = data.getMusicSheetIdList();
|
|
|
- data.getSubjectType();
|
|
|
- Long musicId = list.get(0);
|
|
|
-
|
|
|
- tenantAlbumMusicService.detail(musicId);*/
|
|
|
return HttpResponseResult.succeed(vo);
|
|
|
}
|
|
|
|
|
@@ -133,13 +123,25 @@ public class TenantAlbumController {
|
|
|
/**
|
|
|
* 新增专辑
|
|
|
*/
|
|
|
- @PostMapping("/insert")
|
|
|
+ @PostMapping("/save")
|
|
|
@ApiOperation(value = "新增专辑", notes = "新增专辑")
|
|
|
- //@PreAuthorize("@pcs.hasPermissions('tenantAlbum/insert')")
|
|
|
- public HttpResponseResult<Boolean> insertTenantAlbum( @RequestBody TenantAlbumWrapper.TenantAlbumVo album) {
|
|
|
-
|
|
|
-
|
|
|
- return HttpResponseResult.succeed(tenantAlbumService.insertTenantAlbum(album));
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantAlbum/save')")
|
|
|
+ public HttpResponseResult<Boolean> save(@Validated @RequestBody TenantAlbumVo.TenantAlbum album) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ TenantInfo tenantInfo = tenantInfoService.lambdaQuery().eq(TenantInfo::getUserId, sysUser.getId())
|
|
|
+ .last("limit 1").one();
|
|
|
+ if (tenantInfo == null) {
|
|
|
+ throw new BizException("非法请求");
|
|
|
+ }
|
|
|
+
|
|
|
+ TenantAlbum tenantAlbum = JSON.parseObject(album.jsonString(), TenantAlbum.class);
|
|
|
+ List<TenantAlbumVo.MusicSheetData> musicSheetData = album.getMusicSheetData();
|
|
|
+
|
|
|
+ List<TenantAlbumWrapper.MusicSheetData> musicSheetDataList = musicSheetData.stream().map(next ->
|
|
|
+ JSON.parseObject(JSON.toJSONString(next), TenantAlbumWrapper.MusicSheetData.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ tenantAlbumService.insertTenantAlbum(tenantInfo.getId(), tenantAlbum, musicSheetDataList);
|
|
|
+ return HttpResponseResult.succeed();
|
|
|
}
|
|
|
|
|
|
|