|
@@ -4,19 +4,21 @@ package com.project.hyb.biz.controller;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.project.hyb.biz.domain.dto.ArtArtworksDto;
|
|
|
|
-import com.project.hyb.biz.domain.entity.ArtArtworks;
|
|
|
|
|
|
+import com.project.hyb.biz.domain.dto.MbArtArtworksDto;
|
|
|
|
+import com.project.hyb.biz.domain.entity.MbArtArtworks;
|
|
import com.project.hyb.biz.domain.entity.SysAttachments;
|
|
import com.project.hyb.biz.domain.entity.SysAttachments;
|
|
import com.project.hyb.biz.domain.request.ArtArtworksPageRequest;
|
|
import com.project.hyb.biz.domain.request.ArtArtworksPageRequest;
|
|
-import com.project.hyb.biz.service.ArtArtworksService;
|
|
|
|
|
|
+import com.project.hyb.biz.service.MbArtArtworksService;
|
|
import com.project.hyb.biz.service.SysAttachmentsService;
|
|
import com.project.hyb.biz.service.SysAttachmentsService;
|
|
import com.project.hyb.common.response.PageInfo;
|
|
import com.project.hyb.common.response.PageInfo;
|
|
import com.project.hyb.common.response.R;
|
|
import com.project.hyb.common.response.R;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -31,18 +33,18 @@ import java.util.stream.Collectors;
|
|
*/
|
|
*/
|
|
@Api(tags = "藏品")
|
|
@Api(tags = "藏品")
|
|
@RestController
|
|
@RestController
|
|
-@RequestMapping("/hyb/artArtworks")
|
|
|
|
|
|
+@RequestMapping("/artArtworks")
|
|
public class ArtArtworksController {
|
|
public class ArtArtworksController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private ArtArtworksService artArtworksService;
|
|
|
|
|
|
+ private MbArtArtworksService artArtworksService;
|
|
@Autowired
|
|
@Autowired
|
|
private SysAttachmentsService sysAttachmentsService;
|
|
private SysAttachmentsService sysAttachmentsService;
|
|
|
|
|
|
@ApiOperation("首页藏品接口")
|
|
@ApiOperation("首页藏品接口")
|
|
@GetMapping("index/page")
|
|
@GetMapping("index/page")
|
|
- public R<PageInfo<ArtArtworksDto>> indexPage(ArtArtworksPageRequest request){
|
|
|
|
- PageInfo<ArtArtworksDto> artArtworksDtoPageInfo = artArtworksService.pageArtArtworks(request);
|
|
|
|
|
|
+ public R<PageInfo<MbArtArtworksDto>> indexPage(ArtArtworksPageRequest request){
|
|
|
|
+ PageInfo<MbArtArtworksDto> artArtworksDtoPageInfo = artArtworksService.pageArtArtworks(request);
|
|
if(CollUtil.isNotEmpty(artArtworksDtoPageInfo.getPageData())){
|
|
if(CollUtil.isNotEmpty(artArtworksDtoPageInfo.getPageData())){
|
|
return R.ok(artArtworksDtoPageInfo);
|
|
return R.ok(artArtworksDtoPageInfo);
|
|
}
|
|
}
|
|
@@ -52,52 +54,8 @@ public class ArtArtworksController {
|
|
|
|
|
|
@ApiOperation("藏品列表")
|
|
@ApiOperation("藏品列表")
|
|
@GetMapping("list")
|
|
@GetMapping("list")
|
|
- public R<List<ArtArtworksDto>> list(ArtArtworksPageRequest request){
|
|
|
|
- List<ArtArtworks> list = artArtworksService.listArtArtworks(request);
|
|
|
|
- if(CollUtil.isEmpty(list)){
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
- List<String> uuids = list.stream().map(v -> v.getArtworkUuid()).collect(Collectors.toList());
|
|
|
|
- List<SysAttachments> attachs = sysAttachmentsService.list(
|
|
|
|
- new LambdaQueryWrapper<SysAttachments>()
|
|
|
|
- .eq(SysAttachments::getModules, "artwork")
|
|
|
|
- .in(SysAttachments::getRecordid, uuids));
|
|
|
|
-
|
|
|
|
- Map<String, List<SysAttachments>> map = new HashMap<>();
|
|
|
|
- attachs.stream().forEach(v->{
|
|
|
|
- List<SysAttachments> sysAttachments = map.get(v.getRecordid());
|
|
|
|
- if(sysAttachments == null){
|
|
|
|
- sysAttachments = new ArrayList<>();
|
|
|
|
- map.put(v.getRecordid(), sysAttachments);
|
|
|
|
- }
|
|
|
|
- sysAttachments.add(v);
|
|
|
|
- });
|
|
|
|
- List<ArtArtworksDto> artArtworksDtos = BeanUtil.copyToList(list, ArtArtworksDto.class);
|
|
|
|
- artArtworksDtos.stream().forEach(v->{
|
|
|
|
- List<SysAttachments> sysAttachments = map.get(v.getArtworkUuid());
|
|
|
|
- Set<Integer> categorys = new HashSet<>();
|
|
|
|
- if(CollUtil.isNotEmpty(sysAttachments)){
|
|
|
|
- for (SysAttachments sysAttachment : sysAttachments) {
|
|
|
|
- categorys.add(sysAttachment.getCategory());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(categorys.size() == 0){
|
|
|
|
- v.setDim(0);
|
|
|
|
- }else if(categorys.size() == 2){
|
|
|
|
- v.setDim(3);
|
|
|
|
- }else{
|
|
|
|
- if(categorys.contains(6)){
|
|
|
|
- v.setDim(2);
|
|
|
|
- }else{
|
|
|
|
- v.setDim(1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- if(request.getDim() == 3){
|
|
|
|
- return R.ok(artArtworksDtos);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(artArtworksDtos.stream().filter(v->v.getDim().equals(request.getDim())).collect(Collectors.toList()));
|
|
|
|
|
|
+ public R<List<MbArtArtworksDto>> list(ArtArtworksPageRequest request){
|
|
|
|
+ return R.ok(artArtworksService.listArtWork(request));
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation("获取分类列表")
|
|
@ApiOperation("获取分类列表")
|
|
@@ -108,7 +66,7 @@ public class ArtArtworksController {
|
|
|
|
|
|
@ApiOperation("根据id获取")
|
|
@ApiOperation("根据id获取")
|
|
@GetMapping("{id}")
|
|
@GetMapping("{id}")
|
|
- public R<ArtArtworksDto> getById(@PathVariable Long id){
|
|
|
|
|
|
+ public R<MbArtArtworksDto> getById(@PathVariable Long id){
|
|
return R.ok(artArtworksService.getArtArtworkById(id));
|
|
return R.ok(artArtworksService.getArtArtworkById(id));
|
|
}
|
|
}
|
|
|
|
|