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

[fix]
游记话题的接口增加浏览量字段

chenchen 1 месяц назад
Родитель
Сommit
26204ec1ce

+ 22 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/TravelNotesCommentController.java

@@ -290,7 +290,28 @@ public class TravelNotesCommentController {
         return ResponseResult.success();
     }
     //删除评论接口
-    //1.删除自己写的评论;2.删除自己写的游记的评论
+    //1.删除自己写的评论;
+
+    /**
+     * 删除自己写的评论。
+     *
+     * @param commentId 评论id。
+     * @return 应答结果对象,包含新增对象主键Id。
+     */
+    @OperationLog(type = SysOperationLogType.ADD)
+    @PostMapping("/myCommentDel")
+    public ResponseResult<Void> myCommentDel(@RequestBody Long commentId){
+        //先校验评论id是否为自己的评论
+        TourTravelNotesComment tourTravelNotesComment = tourTravelNotesCommentService.getById(commentId);
+        //是自己的评论,直接进行删除
+        if(tourTravelNotesComment.getCommentUserId().equals(TokenData.takeFromRequest().getUserId())){
+            tourTravelNotesCommentService.remove(commentId);
+        }else{
+            return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST,"不是自己的评论,无法删除");
+        }
+        return ResponseResult.success();
+    }
+    // 2.删除自己写的游记的评论
     //群聊详情接口
     //举报评论接口
 

+ 7 - 0
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebSiteTourismTravelNotesPublishController.java

@@ -453,6 +453,13 @@ public class WebSiteTourismTravelNotesPublishController {
         myOrderParam.add(new MyOrderParam.OrderInfo("hotValue", false, null));
         List<TourTravelNotesTopic> tourTravelNotesTopicList = tourTravelNotesTopicService.getTourTravelNotesTopicList(tourTravelNotesTopic,orderBy);
         List<TourTravelNotesTopicVo> tourTravelNotesTopicVoList = MyModelUtil.copyCollectionTo(tourTravelNotesTopicList, TourTravelNotesTopicVo.class);
+
+        List<Long> topicIdList = tourTravelNotesTopicVoList.stream().map(TourTravelNotesTopicVo::getId).map(Long::valueOf).collect(Collectors.toList());
+        Map<Long, Integer> viewCountListTopicByName = tourTravelNotesTopicService.getViewCountListTopicByName(topicIdList);
+        //放入浏览量的数值
+        tourTravelNotesTopicVoList.stream().forEach(item->{
+            item.setViewCount(viewCountListTopicByName.get(Long.valueOf(item.getId())));
+        });
         return ResponseResult.success(tourTravelNotesTopicVoList);
     }
 

+ 7 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dao/TourTravelNotesTopicMapper.java

@@ -44,6 +44,13 @@ public interface TourTravelNotesTopicMapper extends BaseDaoMapper<TourTravelNote
      *
      * @return 查询结果集。
      */
+    Map<Long, Integer> getViewCountListTopicByName(List<Long> idList);
+
+    /**
+     * 根据游记话题名称查询话题浏览量
+     *
+     * @return 查询结果集。
+     */
     Integer getCommentCountTopicByName(String name,String titleName);
 
     /**

+ 23 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dao/mapper/TourTravelNotesTopicMapper.xml

@@ -89,6 +89,29 @@
             and ttn.project_title LIKE CONCAT('%', #{titleName}, '%');
         </if>
     </select>
+    <resultMap id="viewCountMap" type="java.util.Map">
+        <id property="id" column="id" />
+        <result property="totalPageViews" column="total_page_views"/>
+    </resultMap>
+
+    <select id="getViewCountListTopicByName" resultMap="viewCountMap" parameterType="java.util.List">
+        SELECT
+        ttnr.id AS id,
+        SUM(ttn.page_view_count) AS total_page_views
+        FROM
+        tour_travel_notes_topic_relation ttnr
+        JOIN
+        tour_tourism_project_travel_notes_writer ttn
+        ON ttnr.travel_notes_id = ttn.id
+        WHERE
+        ttnr.id IN
+        <foreach collection="idList" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        AND ttn.data_state = 1
+        GROUP BY
+        ttnr.id
+    </select>
 
     <select id="getCommentCountTopicByName" resultType="Integer" parameterType="String">
         SELECT

+ 8 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/service/TourTravelNotesTopicService.java

@@ -73,6 +73,14 @@ public interface TourTravelNotesTopicService extends IBaseService<TourTravelNote
      */
     Integer getViewCountTopicByName(String name,String titleName);
 
+
+    /**
+     * 根据游记话题名称查询话题浏览量
+     *
+     * @return 查询结果集。
+     */
+    Map<Long, Integer> getViewCountListTopicByName(List<Long> idList);
+
     /**
      * 根据游记话题名称查询话题评论数
      *

+ 10 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/service/impl/TourTravelNotesTopicServiceImpl.java

@@ -109,6 +109,16 @@ public class TourTravelNotesTopicServiceImpl extends BaseService<TourTravelNotes
         return tourTravelNotesTopicMapper.getViewCountTopicByName(name,titleName);
     }
 
+
+    /**
+     * 根据游记话题名称查询话题浏览量
+     *
+     * @return 查询结果集。
+     */
+    @Override
+    public Map<Long, Integer> getViewCountListTopicByName(List<Long> idList){
+        return tourTravelNotesTopicMapper.getViewCountListTopicByName(idList);
+    }
     /**
      * 根据游记话题名称查询话题浏览量
      *

+ 6 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/vo/TourTravelNotesTopicVo.java

@@ -46,4 +46,10 @@ public class TourTravelNotesTopicVo extends BaseVo {
      */
     @Schema(description = "enable 常量字典关联数据")
     private Map<String, Object> enableDictMap;
+
+    /**
+     * 浏览量。
+     */
+    @Schema(description = "浏览量")
+    private Integer viewCount;
 }