tjf преди 4 месеца
родител
ревизия
711e33c58e

+ 6 - 11
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java

@@ -1,15 +1,5 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.Map;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.controller.BaseController;
@@ -23,6 +13,11 @@ import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.MimeTypeUtils;
 import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Map;
 
 /**
  * 个人信息 业务处理
@@ -87,7 +82,7 @@ public class SysProfileController extends BaseController
      * 重置密码
      */
     @Log(title = "个人信息", businessType = BusinessType.UPDATE)
-    @PostMapping("/put/updatePwd")
+    @PostMapping("/updatePwd")
     public AjaxResult updatePwd(@RequestBody Map<String, String> params)
     {
         String oldPassword = params.get("oldPassword");

+ 4 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java

@@ -140,7 +140,7 @@ public class SysRoleController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
-    @PostMapping("/put/dataScope")
+    @PostMapping("/dataScope/put")
     public AjaxResult dataScope(@RequestBody SysRole role)
     {
         roleService.checkRoleAllowed(role);
@@ -153,7 +153,7 @@ public class SysRoleController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
-    @PostMapping("/put/changeStatus")
+    @PostMapping("/changeStatus/put")
     public AjaxResult changeStatus(@RequestBody SysRole role)
     {
         roleService.checkRoleAllowed(role);
@@ -223,7 +223,7 @@ public class SysRoleController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.GRANT)
-    @PostMapping("/put/authUser/cancelAll")
+    @PostMapping("/authUser/cancelAll/put")
     public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
     {
         return toAjax(roleService.deleteAuthUsers(roleId, userIds));
@@ -234,7 +234,7 @@ public class SysRoleController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.GRANT)
-    @PostMapping("/put/authUser/selectAll")
+    @PostMapping("/authUser/selectAll/put")
     public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
     {
         roleService.checkRoleDataScope(roleId);

+ 13 - 19
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -1,21 +1,5 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.List;
-import java.util.stream.Collectors;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang3.ArrayUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -31,6 +15,16 @@ import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysPostService;
 import com.ruoyi.system.service.ISysRoleService;
 import com.ruoyi.system.service.ISysUserService;
+import org.apache.commons.lang3.ArrayUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 用户信息
@@ -191,7 +185,7 @@ public class SysUserController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
-    @PostMapping("/put/resetPwd")
+    @PostMapping("/resetPwd")
     public AjaxResult resetPwd(@RequestBody SysUser user)
     {
         userService.checkUserAllowed(user);
@@ -206,7 +200,7 @@ public class SysUserController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:user:edit')")
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
-    @PostMapping("/put/changeStatus")
+    @PostMapping("/changeStatus")
     public AjaxResult changeStatus(@RequestBody SysUser user)
     {
         userService.checkUserAllowed(user);
@@ -235,7 +229,7 @@ public class SysUserController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:user:edit')")
     @Log(title = "用户管理", businessType = BusinessType.GRANT)
-    @PostMapping("/put/authRole")
+    @PostMapping("/authRole/put")
     public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
     {
         userService.checkUserDataScope(userId);

+ 43 - 23
ruoyi-system/src/main/java/com/ruoyi/system/domain/communityNews/CommentIndex.java

@@ -1,7 +1,5 @@
 package com.ruoyi.system.domain.communityNews;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
@@ -61,6 +59,14 @@ public class CommentIndex extends BaseEntity
     /** 所回复目标评论的头像地址 */
     @Excel(name = "所回复目标评论的头像地址")
     private String toAvatar;
+    /**
+     * 是否是二级回复的回复 Y:是 N:否
+     */
+    private String toRoot;
+    /**
+     * 是否是自己的评论
+     */
+    private String isMyself;
 
     /** 内容id */
     @Excel(name = "内容id")
@@ -73,6 +79,22 @@ public class CommentIndex extends BaseEntity
     /** 逻辑删除(Y:已删除,N:未删除) */
     private String delFlag;
 
+    public String getIsMyself() {
+        return isMyself;
+    }
+
+    public void setIsMyself(String isMyself) {
+        this.isMyself = isMyself;
+    }
+
+    public String getToRoot() {
+        return toRoot;
+    }
+
+    public void setToRoot(String toRoot) {
+        this.toRoot = toRoot;
+    }
+
     public String getCommunityTitle() {
         return communityTitle;
     }
@@ -210,26 +232,24 @@ public class CommentIndex extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("commentId", getCommentId())
-            .append("communityId", getCommunityId())
-            .append("communityType", getCommunityType())
-            .append("isRoot", getIsRoot())
-            .append("parentId", getParentId())
-            .append("userId", getUserId())
-            .append("nickName", getNickName())
-            .append("avatar", getAvatar())
-            .append("toUserId", getToUserId())
-            .append("toNickName", getToNickName())
-            .append("toAvatar", getToAvatar())
-            .append("contentId", getContentId())
-            .append("commentContent", getCommentContent())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return "CommentIndex{" +
+                "commentId=" + commentId +
+                ", communityId=" + communityId +
+                ", communityTitle='" + communityTitle + '\'' +
+                ", communityType='" + communityType + '\'' +
+                ", isRoot=" + isRoot +
+                ", parentId=" + parentId +
+                ", userId=" + userId +
+                ", nickName='" + nickName + '\'' +
+                ", avatar='" + avatar + '\'' +
+                ", toUserId=" + toUserId +
+                ", toNickName='" + toNickName + '\'' +
+                ", toAvatar='" + toAvatar + '\'' +
+                ", toRoot='" + toRoot + '\'' +
+                ", isMyself='" + isMyself + '\'' +
+                ", contentId=" + contentId +
+                ", commentContent='" + commentContent + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                '}';
     }
 }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/domain/communityNews/CommunityNews.java

@@ -31,8 +31,8 @@ public class CommunityNews extends BaseEntity
     @Excel(name = "社区资讯内容")
     private String communityContent;
 
-    /** 社区资讯状态(0正常 1关闭) */
-    @Excel(name = "社区资讯状态", readConverterExp = "0=正常,1=关闭")
+    /** 社区资讯状态(1正常 2关闭) */
+    @Excel(name = "社区资讯状态", readConverterExp = "1=正常,2=关闭")
     private String status;
 
     /** 发布时间 */

+ 26 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/communityNews/vo/CommentChildrenVo.java

@@ -77,6 +77,30 @@ public class CommentChildrenVo implements Serializable {
      * 当前人员是否点赞
      */
     private String isLike;
+    /**
+     * 是否是二级回复的回复 Y:是 N:否
+     */
+    private String toRoot;
+    /**
+     * 是否是自己的评论 Y:是 N:否
+     */
+    private String isMyself;
+
+    public String getIsMyself() {
+        return isMyself;
+    }
+
+    public void setIsMyself(String isMyself) {
+        this.isMyself = isMyself;
+    }
+
+    public String getToRoot() {
+        return toRoot;
+    }
+
+    public void setToRoot(String toRoot) {
+        this.toRoot = toRoot;
+    }
 
     public Long getId() {
         return id;
@@ -144,6 +168,8 @@ public class CommentChildrenVo implements Serializable {
                 ", createTime=" + createTime +
                 ", likeCount=" + likeCount +
                 ", isLike='" + isLike + '\'' +
+                ", toRoot='" + toRoot + '\'' +
+                ", isMyself='" + isMyself + '\'' +
                 '}';
     }
 }

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/communityNews/vo/CommentIndexVo.java

@@ -80,6 +80,19 @@ public class CommentIndexVo implements Serializable {
      */
     private  Integer childrenListCount;
 
+    /**
+     * 是否是自己的评论
+     */
+    private String isMyself;
+
+    public String getIsMyself() {
+        return isMyself;
+    }
+
+    public void setIsMyself(String isMyself) {
+        this.isMyself = isMyself;
+    }
+
     public Integer getChildrenListCount() {
         return childrenListCount;
     }
@@ -155,6 +168,7 @@ public class CommentIndexVo implements Serializable {
                 ", createTime=" + createTime +
                 ", childrenList=" + childrenList +
                 ", childrenListCount=" + childrenListCount +
+                ", isMyself='" + isMyself + '\'' +
                 '}';
     }
 }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/domain/partyNews/PartyNews.java

@@ -31,8 +31,8 @@ public class PartyNews extends BaseEntity
     @Excel(name = "党建资讯内容")
     private String partyContent;
 
-    /** 党建资讯状态(0正常 1关闭) */
-    @Excel(name = "党建资讯状态", readConverterExp = "0=正常,1=关闭")
+    /** 党建资讯状态(1正常 2关闭) */
+    @Excel(name = "党建资讯状态", readConverterExp = "1=正常,2=关闭")
     private String status;
 
     /** 发布时间 */

+ 20 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommentIndexServiceImpl.java

@@ -4,7 +4,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.communityNews.CommentContent;
 import com.ruoyi.system.domain.communityNews.CommentIndex;
 import com.ruoyi.system.domain.communityNews.vo.CommentChildrenVo;
@@ -21,7 +20,8 @@ import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 
-import static com.ruoyi.common.constant.Constants.*;
+import static com.ruoyi.common.constant.Constants.COMMUNITY_COMMENT_COUNT;
+import static com.ruoyi.common.constant.Constants.TWO_MY_LIKE;
 
 /**
  * 社区资讯评论Service业务层处理
@@ -139,6 +139,7 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int deleteCommentIndexByCommentId(Long commentId) {
+        //todo 管理员能删除评论
         //只能删除自己的评论
         CommentIndex commentIndex = commentIndexMapper.selectCommentIndexByCommentId(commentId);
         int result = 0;
@@ -154,7 +155,7 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
             //如果是根评论删除,删除所有子评论
             if (1 == commentIndex.getIsRoot()) {
                 //查找出所有parent_id = commentId的commentId
-                commentIdList = commentIndexMapper.selectCommentIdListByCommentId(commentId);
+                //commentIdList = commentIndexMapper.selectCommentIdListByCommentId(commentId);
                 int i = commentIndexMapper.updateCommentIndexByParentId(commentId);
                 result = result + i;
                 //删除评论内容表子集数据
@@ -171,7 +172,7 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                 }
                 redisCache.setCacheObject(communityCommentCountKey, communityCommentCount);
             }
-            //删除该资讯点赞的数量需要知道所有评论的id
+/*            //删除该资讯点赞的数量需要知道所有评论的id
             //首先获取该文章资讯的总点赞数量
             Integer likeCount = redisCache.getCacheObject(ONE_LIKE_COUNT + communityId);
             //再获取删除的评论的点赞数量
@@ -187,12 +188,18 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                     }
                 }
             }
+            if (commentLikeCount == null){
+                commentLikeCount = 0;
+            }
+            if (likeCount == null){
+                likeCount = 0;
+            }
             //把删除后点赞数量写入到redis
             likeCount = likeCount - commentLikeCount - commentLikeChildrenCount;
             if (likeCount < 0){
                 likeCount = 0;
             }
-            redisCache.setCacheObject(ONE_LIKE_COUNT + communityId, likeCount);
+            redisCache.setCacheObject(ONE_LIKE_COUNT + communityId, likeCount);*/
             //todo 删除后还需要减少未读互动的数据
         }
         return result;
@@ -219,6 +226,10 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                     if (communityIdList.contains(commentChildrenVo.getId())) {
                         commentChildrenVo.setIsLike("Y");
                     }
+                    //是否是自己的评论
+                    if (commentChildrenVo.getCommentUser().getId().equals(userId)){
+                        commentChildrenVo.setIsMyself("Y");
+                    }
                 }
             }
         }
@@ -245,6 +256,10 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                     if (communityIdList.contains(commentIndexVo.getId())) {
                         commentIndexVo.setIsLike("Y");
                     }
+                    //是否是自己的评论
+                   if (commentIndexVo.getCommentUser().getId().equals(userId)){
+                       commentIndexVo.setIsMyself("Y");
+                   }
                 }
             }
         }

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommentLikesServiceImpl.java

@@ -291,6 +291,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             if (userIdListValue.size() == 0){
                 redisCache.deleteObject(likeOneKey);
             }else {
+                redisCache.deleteObject(likeOneKey);
                 // 社区资讯文章点赞的人员集合中删除该用户
                 redisCache.setCacheList(likeOneKey, userIdListValue);
             }
@@ -302,6 +303,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             if (communityIdListValue.size() == 0){
                 redisCache.deleteObject(myLikeOneKey);
             }else {
+                redisCache.deleteObject(myLikeOneKey);
                 redisCache.setCacheList(myLikeOneKey, communityIdListValue);
             }
             // ---------点赞数量操作------------------
@@ -331,6 +333,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             if (userIdListValue.size() == 0){
                 redisCache.deleteObject(likeTwoKey);
             }else {
+                redisCache.deleteObject(likeTwoKey);
                 // 社区资讯文章评论的人员集合中删除该用户
                 redisCache.setCacheList(likeTwoKey, userIdListValue);
             }
@@ -341,6 +344,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             if (communityIdListValue.size() == 0){
                 redisCache.deleteObject(myLikeTwoKey);
             }else {
+                redisCache.deleteObject(myLikeTwoKey);
                 redisCache.setCacheList(myLikeTwoKey, communityIdListValue);
             }
             // ---------点赞数量操作------------------

+ 18 - 6
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommentStarsServiceImpl.java

@@ -3,11 +3,11 @@ package com.ruoyi.system.service.impl;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.communityNews.CommentStars;
 import com.ruoyi.system.mapper.CommentStarsMapper;
 import com.ruoyi.system.mapper.CommunityNewsMapper;
 import com.ruoyi.system.service.ICommentStarsService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -120,6 +120,7 @@ public class CommentStarsServiceImpl implements ICommentStarsService {
                 if (userIdList.size() == 0) {
                     redisCache.deleteObject(starsCommunityKey);
                 } else {
+                    redisCache.deleteObject(starsCommunityKey);
                     redisCache.setCacheList(starsCommunityKey, userIdList);
                 }
                 //收藏数量-1
@@ -172,7 +173,7 @@ public class CommentStarsServiceImpl implements ICommentStarsService {
         String partyKey = STARS_PARTY_NEWS + userId;
         List<Long> partyIdList = redisCache.getCacheList(partyKey);
         int starsCount = 0;
-        String starsPartyNewsCount = redisCache.getCacheObject(STARS_PARTY_NEWS_COUNT + targetId);
+        Object starsPartyNewsCount = redisCache.getCacheObject(STARS_PARTY_NEWS_COUNT + targetId);
         if (partyIdList != null && partyIdList.size() > 0) {
             if (partyIdList.contains(targetId)) {
                 //说明该党建资讯该用户收藏过     取消收藏
@@ -180,11 +181,12 @@ public class CommentStarsServiceImpl implements ICommentStarsService {
                 if (partyIdList.size() == 0) {
                     redisCache.deleteObject(partyKey);
                 } else {
+                    redisCache.deleteObject(partyKey);
                     redisCache.setCacheList(partyKey, partyIdList);
                 }
                 commentStarsMapper.updateCommentStarsByUserIdAndCommunityId(commentStars);
-                if (StringUtils.isNotBlank(starsPartyNewsCount)) {
-                    starsCount = Integer.parseInt(starsPartyNewsCount) - 1;
+                if (ObjectUtils.isNotEmpty(starsPartyNewsCount)) {
+                    starsCount = Integer.parseInt(starsPartyNewsCount.toString()) - 1;
                     if (starsCount < 0) {
                         starsCount = 0;
                     }
@@ -197,11 +199,21 @@ public class CommentStarsServiceImpl implements ICommentStarsService {
                 //收藏表新增数据
                 commentStarsMapper.insertCommentStars(commentStars);
                 //收藏数量+1
-                if (StringUtils.isNotBlank(starsPartyNewsCount)) {
-                    starsCount = Integer.parseInt(starsPartyNewsCount) + 1;
+                if (ObjectUtils.isNotEmpty(starsPartyNewsCount)) {
+                    starsCount = Integer.parseInt(starsPartyNewsCount.toString()) + 1;
                     redisCache.setCacheObject(STARS_PARTY_NEWS_COUNT + targetId, starsCount);
                 }
             }
+        } else {
+            partyIdList = new ArrayList<>();
+            //则第一个收藏
+            partyIdList.add(targetId);
+            redisCache.setCacheList(partyKey, partyIdList);
+            //收藏表新增数据
+            commentStarsMapper.insertCommentStars(commentStars);
+            //收藏数量+1
+            redisCache.setCacheObject(STARS_PARTY_NEWS_COUNT + targetId, 1);
+
         }
         return AjaxResult.success();
     }

+ 38 - 30
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PartyNewsServiceImpl.java

@@ -3,10 +3,10 @@ package com.ruoyi.system.service.impl;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.partyNews.PartyNews;
 import com.ruoyi.system.mapper.PartyNewsMapper;
 import com.ruoyi.system.service.IPartyNewsService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -17,13 +17,12 @@ import static com.ruoyi.common.constant.Constants.STARS_PARTY_NEWS_COUNT;
 
 /**
  * 党建资讯Service业务层处理
- * 
+ *
  * @author boman
  * @date 2025-02-14
  */
 @Service
-public class PartyNewsServiceImpl implements IPartyNewsService 
-{
+public class PartyNewsServiceImpl implements IPartyNewsService {
     @Autowired
     private PartyNewsMapper partyNewsMapper;
 
@@ -32,45 +31,58 @@ public class PartyNewsServiceImpl implements IPartyNewsService
 
     /**
      * 查询党建资讯
-     * 
+     *
      * @param partyId 党建资讯主键
      * @return 党建资讯
      */
     @Override
-    public PartyNews selectPartyNewsByPartyId(Long partyId)
-    {
+    public PartyNews selectPartyNewsByPartyId(Long partyId) {
         PartyNews partyNews = partyNewsMapper.selectPartyNewsByPartyId(partyId);
         //观看次数+1
         Long viewCount = partyNews.getViewCount();
-        partyNews.setViewCount(viewCount+1);
+        partyNews.setViewCount(viewCount + 1);
         partyNewsMapper.updatePartyNews(partyNews);
+        String partyKey = STARS_PARTY_NEWS + SecurityUtils.getUserId();
+        List<Long> partyIdList = redisCache.getCacheList(partyKey);
+
+        partyNews.setIsStars("N");
+        Long partyIdNews = partyNews.getPartyId();
+        if (partyIdList.contains(partyIdNews)) {
+            partyNews.setIsStars("Y");
+        }
+        //插入收藏数量
+        partyNews.setStarsCount(0);
+        Object startCount = redisCache.getCacheObject(STARS_PARTY_NEWS_COUNT + partyId);
+        if (ObjectUtils.isNotEmpty(startCount)) {
+            partyNews.setStarsCount(Integer.parseInt(startCount.toString()));
+        }
+
         return partyNews;
     }
 
     /**
      * 查询党建资讯列表
-     * 
+     *
      * @param partyNews 党建资讯
      * @return 党建资讯
      */
     @Override
-    public List<PartyNews> selectPartyNewsList(PartyNews partyNews)
-    {
+    public List<PartyNews> selectPartyNewsList(PartyNews partyNews) {
         List<PartyNews> partyNewsList = partyNewsMapper.selectPartyNewsList(partyNews);
-        if (partyNewsList != null && partyNewsList.size() > 0){
-            String partyKey = STARS_PARTY_NEWS+ SecurityUtils.getUserId();
+        if (partyNewsList != null && partyNewsList.size() > 0) {
+            String partyKey = STARS_PARTY_NEWS + SecurityUtils.getUserId();
             List<Long> partyIdList = redisCache.getCacheList(partyKey);
             for (PartyNews news : partyNewsList) {
                 news.setIsStars("N");
                 Long partyId = news.getPartyId();
-                if (partyIdList.contains(partyId)){
+                if (partyIdList.contains(partyId)) {
                     news.setIsStars("Y");
                 }
                 //插入收藏数量
-                partyNews.setStarsCount(0);
-                String startCount = redisCache.getCacheObject(STARS_PARTY_NEWS_COUNT + partyId);
-                if (StringUtils.isNotBlank(startCount)){
-                    partyNews.setStarsCount(Integer.parseInt(startCount));
+                news.setStarsCount(0);
+                Object startCount = redisCache.getCacheObject(STARS_PARTY_NEWS_COUNT + partyId);
+                if (ObjectUtils.isNotEmpty(startCount)) {
+                    news.setStarsCount(Integer.parseInt(startCount.toString()));
                 }
             }
         }
@@ -79,51 +91,47 @@ public class PartyNewsServiceImpl implements IPartyNewsService
 
     /**
      * 新增党建资讯
-     * 
+     *
      * @param partyNews 党建资讯
      * @return 结果
      */
     @Override
-    public int insertPartyNews(PartyNews partyNews)
-    {
+    public int insertPartyNews(PartyNews partyNews) {
         partyNews.setCreateTime(DateUtils.getNowDate());
         return partyNewsMapper.insertPartyNews(partyNews);
     }
 
     /**
      * 修改党建资讯
-     * 
+     *
      * @param partyNews 党建资讯
      * @return 结果
      */
     @Override
-    public int updatePartyNews(PartyNews partyNews)
-    {
+    public int updatePartyNews(PartyNews partyNews) {
         partyNews.setUpdateTime(DateUtils.getNowDate());
         return partyNewsMapper.updatePartyNews(partyNews);
     }
 
     /**
      * 批量删除党建资讯
-     * 
+     *
      * @param partyIds 需要删除的党建资讯主键
      * @return 结果
      */
     @Override
-    public int deletePartyNewsByPartyIds(Long[] partyIds)
-    {
+    public int deletePartyNewsByPartyIds(Long[] partyIds) {
         return partyNewsMapper.deletePartyNewsByPartyIds(partyIds);
     }
 
     /**
      * 删除党建资讯信息
-     * 
+     *
      * @param partyId 党建资讯主键
      * @return 结果
      */
     @Override
-    public int deletePartyNewsByPartyId(Long partyId)
-    {
+    public int deletePartyNewsByPartyId(Long partyId) {
         return partyNewsMapper.deletePartyNewsByPartyId(partyId);
     }
 }

+ 8 - 4
ruoyi-system/src/main/resources/mapper/system/CommentIndexMapper.xml

@@ -17,6 +17,7 @@
         <result property="toUserId" column="to_user_id"/>
         <result property="toNickName" column="to_nick_name"/>
         <result property="toAvatar" column="to_avatar"/>
+        <result property="toRoot" column="to_root"/>
         <result property="contentId" column="content_id"/>
         <result property="commentContent" column="comment_content"/>
         <result property="delFlag" column="del_flag"/>
@@ -63,6 +64,7 @@
         <result property="likeCount" column="cl_like_count"/>
         <result property="isLike" column="cl_is_like"/>
         <result property="createTime" column="cl_create_time"/>
+        <result property="toRoot" column="cl_to_root"/>
         <association property="commentUser" javaType="com.ruoyi.system.domain.communityNews.vo.CommentUser"
                      resultMap="CommentUserTwoResult"/>
         <association property="targetUser" javaType="com.ruoyi.system.domain.communityNews.vo.TargetUser"
@@ -100,6 +102,7 @@
                to_user_id,
                to_nick_name,
                to_avatar,
+               to_root,
                content_id,
                comment_content,
                del_flag,
@@ -186,6 +189,7 @@
         i.to_user_id AS tu_id,
         i.to_nick_name AS tu_nick_name,
         i.to_avatar AS tu_avatar,
+        i.to_root AS cl_to_root,
         i.create_time AS cl_create_time,
         c.comment_content AS cl_content,
         c.like_count AS cl_like_count
@@ -257,6 +261,7 @@
             <if test="toUserId != null">to_user_id,</if>
             <if test="toNickName != null">to_nick_name,</if>
             <if test="toAvatar != null">to_avatar,</if>
+            <if test="toRoot != null">to_root,</if>
             <if test="contentId != null">content_id,</if>
             <if test="commentContent != null">comment_content,</if>
             <if test="delFlag != null">del_flag,</if>
@@ -278,6 +283,7 @@
             <if test="toUserId != null">#{toUserId},</if>
             <if test="toNickName != null">#{toNickName},</if>
             <if test="toAvatar != null">#{toAvatar},</if>
+            <if test="toRoot != null">#{toRoot},</if>
             <if test="contentId != null">#{contentId},</if>
             <if test="commentContent != null">#{commentContent},</if>
             <if test="delFlag != null">#{delFlag},</if>
@@ -321,13 +327,11 @@
         where comment_id = #{commentId}
     </delete>
     <update id="updateCommentIndexByCommentId" parameterType="CommentIndex">
-        update set delFlag = 'Y'
-        from comment_index
+        update comment_index set del_flag = 'Y'
         where comment_id = #{commentId}
     </update>
     <update id="updateCommentIndexByParentId" parameterType="CommentIndex">
-        update set delFlag = 'Y'
-        from comment_index
+        update comment_index set del_flag = 'Y'
         where parent_id = #{commentId}
     </update>
 

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/CommunityNewsMapper.xml

@@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userLikes != null  and userLikes != ''"> and user_likes = #{userLikes}</if>
             <if test="userStars != null  and userStars != ''"> and user_stars = #{userStars}</if>
         </where>
+        order by publish_time DESC
     </select>
     
     <select id="selectCommunityNewsByCommunityId" parameterType="Long" resultMap="CommunityNewsResult">