Просмотр исходного кода

新需要-更新最新留言信息到-贴吧

wuweihao 3 лет назад
Родитель
Сommit
f53ce021aa

+ 13 - 3
gis_cms/src/main/java/com/gis/cms/entity/po/BbsEntity.java

@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 
 /**
  * 论坛表
@@ -42,9 +43,6 @@ public class BbsEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "浏览量")
     private Integer visit;
 
-    @TableField(exist  = false)
-    @ApiModelProperty(value = "回复")
-    private Integer reply;
 
     @ApiModelProperty(value = "主题类型:topic(发帖), reply(回帖) ")
     private String bbsType;
@@ -52,6 +50,18 @@ public class BbsEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "父级id")
     private Long parentId;
 
+    @TableField(exist  = false)
+    @ApiModelProperty(value = "回复数量")
+    private Integer reply;
+
+//    @TableField(exist = false)
+    @ApiModelProperty(value = "回复者名称")
+    private String replyName;
+
+//    @TableField(exist = false)
+    @ApiModelProperty(value = "最后回复日期")
+    private LocalDateTime replyTime;
+
 
 
 

+ 0 - 3
gis_cms/src/main/java/com/gis/cms/mapper/BbsMapper.java

@@ -3,11 +3,8 @@ package com.gis.cms.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.gis.cms.entity.dto.SortPageDto;
 import com.gis.cms.entity.po.BbsEntity;
-import com.gis.cms.entity.po.ImgEntity;
 import com.gis.cms.mapper.provider.BaseProvider;
-import com.gis.cms.mapper.provider.ImgProvider;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.SelectProvider;
 import org.apache.ibatis.annotations.Update;

+ 0 - 2
gis_cms/src/main/java/com/gis/cms/mapper/FileMapper.java

@@ -21,8 +21,6 @@ public interface FileMapper extends BaseMapper<FileEntity> {
     @Update("update tb_file set is_index = 0 , update_time = NOW() where is_delete = 0 and is_index = 1 and module = #{module} and module_id = #{moduleId}")
     void indexDisable(Long moduleId, String module);
 
-//    @Update("update tb_file set module_id = #{moduleId} , update_time = NOW() where is_delete = 0 and module = #{module} and id in ( ${fileIds} )")
-//    void addModuleIdToFile(String fileIds, Long moduleId, String module);
 
     @Select("select * from tb_file where is_delete = 0 and is_index = 1 and module = #{module} and module_id = #{moduleId} limit 1")
     List<FileEntity> findIndexByModule(Long moduleId, String module);

+ 22 - 1
gis_cms/src/main/java/com/gis/cms/service/impl/BbsServiceImpl.java

@@ -2,6 +2,7 @@ package com.gis.cms.service.impl;
 
 import cn.hutool.core.io.FileUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,6 +25,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.constraints.NotBlank;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -52,7 +55,6 @@ public class BbsServiceImpl extends ServiceImpl<BbsMapper, BbsEntity> implements
         IPage<BbsEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
 
         StringBuffer sql = new StringBuffer();
-//        sql.append("SELECT a.*, COUNT(case when b.status=2 and b.is_delete=0 then 1 end) reply  from tb_bbs a left join tb_bbs_message b on b.bbs_id=a.id where a.is_delete=0 ");
         sql.append("SELECT a.*, COUNT(case when b.status=2 and b.is_delete=0 and b.bbs_type='reply' then 1 end) reply  from tb_bbs a left join tb_bbs b on b.parent_id=a.id where a.is_delete=0 ");
         Integer status = param.getStatus();
         if (status!=null){
@@ -113,6 +115,25 @@ public class BbsServiceImpl extends ServiceImpl<BbsMapper, BbsEntity> implements
             throw new BaseRuntimeException("审核参数非法:" + status);
         }
         getBaseMapper().updateAudit(id, status);
+        // 审核通过,需要更新最新信息
+        if (status == 2){
+            updateTopic(id);
+        }
+    }
+
+
+    // 更新最新回复者信息
+    private void updateTopic(Long replayId){
+        BbsEntity entity = this.getById(replayId);
+        if (entity == null){
+            return;
+        }
+        LambdaUpdateWrapper<BbsEntity> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(BbsEntity::getReplyName, entity.getCreatorName());
+        updateWrapper.set(BbsEntity::getReplyTime, LocalDateTime.now());
+        updateWrapper.eq(BbsEntity::getId, entity.getParentId());
+        this.update(updateWrapper);
+
     }
 
     @Override