1018653686@qq.com 1 年間 前
コミット
09592d01e7

+ 14 - 2
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/open/OpenProductController.java

@@ -1,7 +1,10 @@
 package com.fjhx.xmhjc.controller.open;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.file.entity.FileInfoVo;
+import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.xmhjc.entity.about.vo.AboutUsHonorVo;
+import com.fjhx.xmhjc.entity.carousel.vo.CarouselManagerVo;
 import com.fjhx.xmhjc.entity.product.dto.ProductInfoSelectDto;
 import com.fjhx.xmhjc.entity.product.vo.ProductCategoryVo;
 import com.fjhx.xmhjc.entity.product.vo.ProductInfoVo;
@@ -13,6 +16,8 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/open/product")
@@ -39,8 +44,15 @@ public class OpenProductController {
 
     @PostMapping("/info/{categoryId}/{subCategoryId}")
     public Page<ProductInfoVo> productInfoList(@PathVariable Long categoryId, @PathVariable Long subCategoryId, @RequestBody ProductInfoSelectDto dto) {
-        Page<ProductInfoVo> list = productInfoService.pageByOpen(categoryId, subCategoryId, dto);
-        return list;
+        Page<ProductInfoVo> page = productInfoService.pageByOpen(categoryId, subCategoryId, dto);
+        List<ProductInfoVo> list = page.getRecords();
+        List<Long> businessIdList = list.stream().map(ProductInfoVo::getId).collect(Collectors.toList());
+        Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(businessIdList, 1);
+        list.forEach(item -> {
+            item.setFileList(fileMap.get(item.getId()));
+        });
+        page.setRecords(list);
+        return page;
     }
 
     @PostMapping("/info/detail/{id}")

+ 17 - 5
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/open/OpenTopicController.java

@@ -73,20 +73,32 @@ public class OpenTopicController {
 
     @LoginValid
     @PostMapping("/detail/{topicId}")
-    public void detail(@RequestBody TopicRepliesDto topicRepliesDto, @PathVariable Long topicId) {
+    public OpenTopicContentVO detail(@RequestBody TopicRepliesSelectDto topicRepliesSelectDto, @PathVariable Long topicId) {
         TopicContent topicContent = topicContentService.getById(topicId);
         if (ObjectUtil.isNull(topicContent)) {
             throw new RuntimeException("主题不存在");
         }
         OpenTopicContentVO openTopicContentVO = BeanUtil.copyProperties(topicContent, OpenTopicContentVO.class);
+        openTopicContentVO.setAuthorName(getAuthorName(topicContent.getAuthor()));
         //分页查出楼层回复
         TopicRepliesSelectDto dto = new TopicRepliesSelectDto();
         Page<TopicRepliesVo> page = topicRepliesService.getPageByOpen(dto);
+        List<TopicRepliesVo> records = page.getRecords();
+        records.forEach(topicRepliesVo -> {
+            topicRepliesVo.setAuthorName(getAuthorName(topicRepliesVo.getAuthor()));
+            dto.setFloorId(topicRepliesVo.getId());
+            Page<TopicRepliesVo> floorPage = topicRepliesService.getPageByOpen(dto);
+            topicRepliesVo.setFloorPage(floorPage);
+        });
 
-        validateReply(topicRepliesDto, topicId);
-        WebsiteUsers loginWebsiteUser = WebsiteUserUtil.getLoginWebsiteUser();
-        topicRepliesDto.setAuthor(loginWebsiteUser.getId());
-        topicRepliesService.add(topicRepliesDto);
+        openTopicContentVO.setRepliesPage(page);
+
+        return openTopicContentVO;
+    }
+
+    private String getAuthorName(Long author) {
+        WebsiteUsers websiteUsers = websiteUsersService.getById(author);
+        return ObjectUtil.isNull(websiteUsers) ? "匿名" : websiteUsers.getUserName();
     }
 
     @LoginValid

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/product/vo/ProductInfoVo.java

@@ -1,5 +1,6 @@
 package com.fjhx.xmhjc.entity.product.vo;
 
+import com.fjhx.file.entity.FileInfoVo;
 import com.fjhx.xmhjc.entity.product.po.ProductInfo;
 import lombok.Getter;
 import lombok.Setter;
@@ -17,4 +18,5 @@ import java.util.List;
 public class ProductInfoVo extends ProductInfo {
 
     List<String> specList;
+    List<FileInfoVo> fileList;
 }

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/topic/dto/TopicRepliesSelectDto.java

@@ -15,4 +15,6 @@ import lombok.Setter;
 public class TopicRepliesSelectDto extends BaseSelectDto {
     private Long topicId;
 
+    private Long floorId;
+
 }

+ 3 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/topic/vo/OpenTopicContentVO.java

@@ -1,5 +1,6 @@
 package com.fjhx.xmhjc.entity.topic.vo;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.xmhjc.entity.topic.po.TopicContent;
 import lombok.Getter;
 import lombok.Setter;
@@ -12,4 +13,6 @@ import lombok.Setter;
 @Setter
 public class OpenTopicContentVO extends TopicContent {
     private String authorName;
+
+    Page<TopicRepliesVo> repliesPage;
 }

+ 6 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/topic/vo/TopicRepliesVo.java

@@ -1,5 +1,6 @@
 package com.fjhx.xmhjc.entity.topic.vo;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.xmhjc.entity.topic.po.TopicReplies;
 import lombok.Getter;
 import lombok.Setter;
@@ -13,5 +14,10 @@ import lombok.Setter;
 @Getter
 @Setter
 public class TopicRepliesVo extends TopicReplies {
+    /**
+     * 回复人名称
+     */
+    private String authorName;
 
+    private Page<TopicRepliesVo> floorPage;
 }

+ 1 - 1
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductSubCategoryServiceImpl.java

@@ -35,7 +35,7 @@ public class ProductSubCategoryServiceImpl extends ServiceImpl<ProductSubCategor
         IWrapper<ProductSubCategory> wrapper = getWrapper();
         wrapper.eq(ObjectUtil.isNotNull(dto.getCategoryId()), "parent_id", dto.getCategoryId());
         wrapper.eq(ObjectUtil.isNotNull(dto.getStatus()), "status", dto.getStatus());
-        wrapper.keyword(dto, new SqlField("pc", ProductCategory::getName));
+        wrapper.keyword(dto, new SqlField("psc", ProductCategory::getName));
         wrapper.orderByDesc("psc", ProductSubCategory::getId);
         Page<ProductSubCategoryVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/topic/impl/TopicRepliesServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fjhx.xmhjc.service.topic.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.fjhx.xmhjc.entity.topic.po.TopicReplies;
 import com.fjhx.xmhjc.mapper.topic.TopicRepliesMapper;
 import com.fjhx.xmhjc.service.topic.TopicRepliesService;
@@ -68,6 +69,7 @@ public class TopicRepliesServiceImpl extends ServiceImpl<TopicRepliesMapper, Top
         IWrapper<TopicReplies> wrapper = getWrapper();
         wrapper.orderByAsc("tr", TopicReplies::getId);
         wrapper.eq("tr", TopicReplies::getTopicId, dto.getTopicId());
+        wrapper.eq(ObjectUtil.isNotNull(dto.getFloorId()), "floor_id", dto.getFloorId());
         Page<TopicRepliesVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
     }