Ver Fonte

修改登录人在族友圈,只能查看他的好友和族友的评论和点赞

Alex há 4 anos atrás
pai
commit
69c41a146e

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbMyProfileController.java

@@ -2,9 +2,11 @@ package com.ruoyi.web.controller.api;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Arrays;
 
+import com.ruoyi.app.domain.vo.AppMemberVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import com.ruoyi.common.utils.StringUtils;
@@ -97,6 +99,7 @@ public class TbMyProfileController extends BaseController {
     @Log(title = "个人详情" , businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody TbMyProfile tbMyProfile) {
+        tbMyProfile.setCreateTime(new Date());
         return toAjax(iTbMyProfileService.save(tbMyProfile) ? 1 : 0);
     }
 
@@ -108,6 +111,7 @@ public class TbMyProfileController extends BaseController {
     @Log(title = "个人详情" , businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TbMyProfile tbMyProfile) {
+        tbMyProfile.setUpdateTime(new Date());
         return toAjax(iTbMyProfileService.updateById(tbMyProfile) ? 1 : 0);
     }
 

+ 2 - 1
ruoyi-app/src/main/java/com/ruoyi/app/controller/MyPublishController.java

@@ -90,7 +90,8 @@ public class MyPublishController extends AppBaseController {
         if (id == null) {
             return AjaxResult.error("id不能为空");
         }
-        return AjaxResult.success(publishService.getPublish(id));
+        AppMemberVo user = getLoginUser().getUser();
+        return AjaxResult.success(publishService.getPublish(id,user.getUserId()));
     }
 
     @ApiOperation("上传图片")

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/app/service/ITbMyPublishService.java

@@ -20,6 +20,7 @@ public interface ITbMyPublishService extends IService<TbMyPublish> {
 
     List<TbMyPublish> pageList(TbMyPublish tbMyPublish);
     TbMyPublish getPublish(Long id);
+    TbMyPublish getPublish(Long id, Long appUserId);
     boolean delPublish(List<Long> ids);
     int getThumbs(Long publishId);
     int getComments(Long publishId);

+ 61 - 3
ruoyi-system/src/main/java/com/ruoyi/app/service/impl/TbMyPublishServiceImpl.java

@@ -117,12 +117,12 @@ public class TbMyPublishServiceImpl extends ServiceImpl<TbMyPublishMapper, TbMyP
     private ITbFamilyService familyService;
 
     /**
-     * 我的近况详情
+     * 我的近况详情(登录人只能看好友和族友的点赞、评论)
      * @param id
      * @return
      */
     @Override
-    public TbMyPublish getPublish(Long id) {
+    public TbMyPublish getPublish(Long id, Long appUserId) {
         TbMyPublish publish = this.getById(id);
         if (publish != null) {
             Long familyId = null;
@@ -137,7 +137,7 @@ public class TbMyPublishServiceImpl extends ServiceImpl<TbMyPublishMapper, TbMyP
                 }
             }
             // 只能看好友和族友的点赞、评论
-            List<Long> fids = getMyFrientIds(publish.getAppUserId(), familyId);
+            List<Long> fids = getMyFrientIds(appUserId, familyId);
 
             // 图片列表
             List<TbPublishImg> publishImgs = imgService.list(new LambdaQueryWrapper<TbPublishImg>()
@@ -179,6 +179,64 @@ public class TbMyPublishServiceImpl extends ServiceImpl<TbMyPublishMapper, TbMyP
         return publish;
     }
 
+    /**
+     * 会员的所有近况详情
+     * @param id
+     * @return
+     */
+    @Override
+    public TbMyPublish getPublish(Long id) {
+        TbMyPublish publish = this.getById(id);
+        if (publish != null) {
+            Long familyId = null;
+            TbFamilyMember member = memberService.getOne(new LambdaQueryWrapper<TbFamilyMember>()
+                    .eq(TbFamilyMember::getAppUserId,publish.getAppUserId())
+                    .last("limit 1")
+            );
+            if (member != null) {
+                TbFamily family = familyService.myFamily(member.getId());
+                if (family != null) {
+                    familyId = family.getId();
+                }
+            }
+            // 图片列表
+            List<TbPublishImg> publishImgs = imgService.list(new LambdaQueryWrapper<TbPublishImg>()
+                    .in(TbPublishImg::getPublishId, id)
+            );
+            // 点赞列表
+            List<TbPublishThumbs> thumbsList = thumbsService.selectList(new LambdaQueryWrapper<TbPublishThumbs>()
+                    .in(TbPublishThumbs::getPublishId, id)
+            );
+            // 评论列表
+            List<TbPublishComment> commentList = commentService.selectList(new LambdaQueryWrapper<TbPublishComment>()
+                    .in(TbPublishComment::getPublishId, id)
+            );
+            //点赞数
+            int thumbs = this.getThumbs(id);
+            //评论数
+            int comments = this.getComments(id);
+            TbAppUser userPublish = userService.getById(publish.getAppUserId());
+            if (userPublish != null) {
+                publish.setNickName(userPublish.getNickName());
+                publish.setAvatar(userPublish.getAvatar());
+            }
+            // 如果是留念人发表
+            if (publish.getMessageUserId() != null) {
+                TbAppUser user = userService.getById(publish.getMessageUserId());
+                if (user != null) {
+                    publish.setMessageUser(user.getNickName());
+                    publish.setMessageUserAvatar(user.getAvatar());
+                }
+            }
+            publish.setImgList(publishImgs);
+            publish.setCommentList(commentList);
+            publish.setThumbsList(thumbsList);
+            publish.setThumbs(thumbs);
+            publish.setComments(comments);
+        }
+        return publish;
+    }
+
     @Override
     public boolean delPublish(List<Long> ids){
         List<TbMyPublish> publishList = baseMapper.selectList(new LambdaQueryWrapper<TbMyPublish>()