소스 검색

bug修复,新增回复置顶

1018653686@qq.com 1 년 전
부모
커밋
6d83389bff

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

@@ -57,7 +57,7 @@ public class OpenProductController {
 
     @PostMapping("/info/detail/{id}")
     public ProductInfoVo productInfoList(@PathVariable Long id) {
-        ProductInfoVo detail = productInfoService.detail(id);
+        ProductInfoVo detail = productInfoService.detailByOpen(id);
         return detail;
     }
 }

+ 10 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/open/OpenTopicController.java

@@ -50,6 +50,16 @@ public class OpenTopicController {
         Page<TopicContentVo> page = topicContentService.contentPage(dto, sortType);
         page.getRecords().forEach(topicContentVo -> {
             topicContentVo.setAuthorName(websiteUsersService.getAuthorName(topicContentVo.getAuthor()));
+            //获取置顶回复,或者是最新回复
+            TopicReplies topReplies = topicRepliesService.getTopReplies(topicContentVo.getId());
+            if(ObjectUtil.isNotNull(topReplies) && topReplies.getId() != null){
+                topicContentVo.setOutline(topReplies.getContent());
+            }else{
+                TopicReplies newReplies = topicRepliesService.getNewReplies(topicContentVo.getId());
+                if(ObjectUtil.isNotNull(newReplies) && newReplies.getId() != null){
+                    topicContentVo.setOutline(newReplies.getContent());
+                }
+            }
         });
         return page;
     }

+ 9 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/topic/TopicRepliesController.java

@@ -93,4 +93,13 @@ public class TopicRepliesController {
     public void deleteAndChild(@RequestBody BaseSelectDto dto) {
         topicRepliesService.deleteAndChild(dto.getId());
     }
+
+
+    /**
+     * 置顶回复
+     */
+    @PostMapping("/topingReplys")
+    public void topingReplys(@RequestBody TopicRepliesDto topicRepliesDto) {
+        topicRepliesService.topingReplys(topicRepliesDto);
+    }
 }

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/topic/po/TopicReplies.java

@@ -30,4 +30,6 @@ public class TopicReplies extends BasePo {
     private Long author;
 
     private Long citeAuthor;
+
+    private String toping;
 }

+ 4 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/column/impl/ColumnArticleServiceImpl.java

@@ -30,6 +30,7 @@ import com.fjhx.xmhjc.entity.column.dto.ColumnArticleSelectDto;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.fjhx.xmhjc.entity.column.dto.ColumnArticleDto;
 import cn.hutool.core.bean.BeanUtil;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
@@ -152,10 +153,13 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
     }
 
     @Override
+    @Transactional
     public void delete(Long id) {
         homeSettingService.checkDelete(id);
         carouselManagerService.checkDelete(id);
         this.removeById(id);
+        //删除主题
+        topicContentService.delete(id);
     }
 
     @Override

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductInfoService.java

@@ -50,4 +50,6 @@ public interface ProductInfoService extends BaseService<ProductInfo> {
     void delete(Long id);
 
     Page<ProductInfoVo> pageByOpen(Long categoryId, Long subCategoryId, ProductInfoSelectDto dto);
+
+    ProductInfoVo detailByOpen(Long id);
 }

+ 28 - 9
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductInfoServiceImpl.java

@@ -83,13 +83,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         }
         result.setSpecList(specList);
         //获取图片
-        List<Long> businessIdList = new ArrayList<>();
-        businessIdList.add(result.getId());
-        Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(businessIdList, 1);
-        result.setFileList(fileMap.get(result.getId()));
-
-        Map<Long, List<FileInfoVo>> contentImgMap = ObsFileUtil.getFileMap(businessIdList, 2);
-        result.setContentImgList(contentImgMap.get(result.getId()));
+        buildFile(result);
         return result;
     }
 
@@ -101,8 +95,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         this.save(productInfoDto);
         // 保存图片
         ObsFileUtil.saveFile(productInfoDto.getCoverUrlList(), productInfoDto.getId(), 1);
-
-
         ObsFileUtil.saveFile(productInfoDto.getContentImgList(), productInfoDto.getId(), 2);
     }
 
@@ -137,4 +129,31 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         Page<ProductInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
     }
+
+
+    @Override
+    public ProductInfoVo detailByOpen(Long id) {
+        ProductInfo productInfo = this.getById(id);
+        ProductInfoVo result = BeanUtil.toBean(productInfo, ProductInfoVo.class);
+        Map<String, String> dictMap = DictUtilsByOpen.getDictMap("product_spec");
+        List<String> specList = new ArrayList<>();
+        if(StringUtils.isNotBlank(productInfo.getSpec())){
+            specList = Arrays.stream(productInfo.getSpec().split(",")).map(dictMap::get).collect(Collectors.toList());
+        }
+        result.setSpecList(specList);
+        //获取图片
+        buildFile(result);
+        return result;
+    }
+
+    private void buildFile(ProductInfoVo result) {
+        List<Long> businessIdList = new ArrayList<>();
+        businessIdList.add(result.getId());
+        Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(businessIdList, 1);
+        result.setFileList(fileMap.get(result.getId()));
+        Map<Long, List<FileInfoVo>> contentImgMap = ObsFileUtil.getFileMap(businessIdList, 2);
+        result.setContentImgList(contentImgMap.get(result.getId()));
+    }
+
+
 }

+ 6 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/topic/TopicRepliesService.java

@@ -60,4 +60,10 @@ public interface TopicRepliesService extends BaseService<TopicReplies> {
     void deleteAndChild(Long id);
 
     Page<TopicRepliesVo> getFloorPageByOpen(TopicRepliesSelectDto dto);
+
+    TopicReplies getTopReplies(Long topicId);
+
+    TopicReplies getNewReplies(Long topicId);
+
+    void topingReplys(TopicRepliesDto topicRepliesDto);
 }

+ 10 - 4
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/topic/impl/TopicContentServiceImpl.java

@@ -53,7 +53,10 @@ public class TopicContentServiceImpl extends ServiceImpl<TopicContentMapper, Top
         if(StringUtils.isNotEmpty(dto.getToping())){
             wrapper.eq("tc", TopicContent::getToping,dto.getToping());
         }
-
+        if(StringUtils.isNotEmpty(dto.getType())){
+            wrapper.eq("tc", TopicContent::getType,dto.getType());
+        }
+        wrapper.orderByAsc("tc", TopicContent::getType);
         wrapper.orderByDesc("tc", TopicContent::getId);
         wrapper.keyword(dto, new SqlField("tc", TopicContent::getTitle));
         Page<TopicContentVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
@@ -104,11 +107,14 @@ public class TopicContentServiceImpl extends ServiceImpl<TopicContentMapper, Top
     @Override
     public void extracted(ColumnArticleDto columnArticleDto) {
         TopicContent topicContent = getById(columnArticleDto.getId());
+        TopicContentDto topicContentDto = new TopicContentDto();
+        topicContentDto.setType("2");
+        topicContentDto.setId(columnArticleDto.getId());
+        topicContentDto.setTitle(columnArticleDto.getTitle());
         if (ObjectUtil.isNull(topicContent)){
-            TopicContentDto topicContentDto = new TopicContentDto();
-            topicContentDto.setType("2");
-            topicContentDto.setId(columnArticleDto.getId());
             add(topicContentDto);
+        }else {
+            edit(topicContentDto);
         }
     }
 }

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

@@ -130,4 +130,26 @@ public class TopicRepliesServiceImpl extends ServiceImpl<TopicRepliesMapper, Top
         Page<TopicRepliesVo> page = this.baseMapper.getFloorPageByOpen(dto.getPage(), dto);
         return page;
     }
+
+    @Override
+    public TopicReplies getTopReplies(Long topicId) {
+        TopicReplies topReplies = lambdaQuery().eq(TopicReplies::getTopicId, topicId).eq(TopicReplies::getToping, "1").one();
+        return topReplies;
+    }
+
+    @Override
+    public TopicReplies getNewReplies(Long topicId) {
+        TopicReplies topReplies = lambdaQuery().eq(TopicReplies::getTopicId, topicId).orderByDesc(TopicReplies::getId).last("limit 1").one();
+        return topReplies;
+    }
+
+    @Override
+    @Transactional
+    public void topingReplys(TopicRepliesDto topicRepliesDto) {
+        if (StrUtil.equals(topicRepliesDto.getToping(), "1")) {
+            //置顶前先把其他的置顶取消
+            lambdaUpdate().eq(TopicReplies::getTopicId, topicRepliesDto.getTopicId()).set(TopicReplies::getToping, "0").update();
+        }
+        updateById(topicRepliesDto);
+    }
 }

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/website/impl/WebsiteUsersServiceImpl.java

@@ -7,6 +7,7 @@ import com.fjhx.xmhjc.mapper.website.WebsiteUsersMapper;
 import com.fjhx.xmhjc.service.website.WebsiteUsersService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.utils.sign.Md5Utils;
+import com.ruoyi.common.utils.wrapper.SqlField;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.xmhjc.entity.website.vo.WebsiteUsersVo;
@@ -42,6 +43,7 @@ public class WebsiteUsersServiceImpl extends ServiceImpl<WebsiteUsersMapper, Web
     public Page<WebsiteUsersVo> getPage(WebsiteUsersSelectDto dto) {
         IWrapper<WebsiteUsers> wrapper = getWrapper();
         wrapper.orderByDesc("wu", WebsiteUsers::getId);
+        wrapper.keyword(dto, new SqlField("wu", WebsiteUsers::getUserName));
         Page<WebsiteUsersVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
     }

+ 6 - 3
hx-xmhjc/src/main/resources/mapper/topic/TopicRepliesMapper.xml

@@ -30,7 +30,8 @@
             tr.update_user,
             tr.update_time,
             tr.author,
-            tr.cite_author
+            tr.cite_author,
+            tr.toping
         from topic_replies tr
             ${ew.customSqlSegment}
     </select>
@@ -48,7 +49,8 @@
             tr.update_time,
             tr.author,
             tr.cite_author,
-            IFNULL(trr.num ,0) as num
+            IFNULL(trr.num ,0) as num,
+            tr.toping
         from topic_replies tr
             left join (select count(1) num, trr.floor_id fid from topic_replies trr where trr.topic_id = #{dto.topicId} and floor_id is not null   group by trr.floor_id) trr on trr.fid = tr.id
         WHERE
@@ -59,6 +61,7 @@
             <if test="dto.sortType != null and dto.sortType != ''">
                 num desc,
             </if>
-            tr.floor_id DESC
+            tr.floor_id desc,
+            tr.id DESC
     </select>
 </mapper>