fangqing 2 ماه پیش
والد
کامیت
1280e6d411
1فایلهای تغییر یافته به همراه35 افزوده شده و 6 حذف شده
  1. 35 6
      ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityTagController.java

+ 35 - 6
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityTagController.java

@@ -90,7 +90,7 @@ public class CommunityTagController extends BaseController {
     @GetMapping("/createdTags")
     @Transactional
     //@Anonymous
-    public AjaxResult createdTags(String tagName,Long userId) {
+    public AjaxResult createdTags(Long userId) {
         if (userId == null) {
             userId = SecurityUtils.getUserId();
         }
@@ -102,7 +102,6 @@ public class CommunityTagController extends BaseController {
                                 .or()
                                 .isNull("is_delete");
                     })
-                    .like("tag_name", tagName)
                     .eq("create_by", userId)
                     .orderByDesc("tag_hot")).getRecords();
         } catch (Exception e) {
@@ -163,7 +162,7 @@ public class CommunityTagController extends BaseController {
     @GetMapping("/likeTags")
     @Transactional
     //@Anonymous
-    public AjaxResult likeTags(String tagName,Long userId) {
+    public AjaxResult likeTags(Long userId) {
         if (userId == null) {
             userId = SecurityUtils.getUserId();
         }
@@ -176,6 +175,10 @@ public class CommunityTagController extends BaseController {
                             .eq("is_delete", 0));
 
             List<Long> tagList = userTags.stream().map(CommunityUserTag::getTagId).collect(Collectors.toList());
+            if (tagList.size() == 0){
+                return AjaxResult.success(communityTags);
+            }
+
             communityTags= communityTagMapper.selectList(new QueryWrapper<CommunityTag>()
                     .in("id", tagList)
                     .and((wrapper) -> {
@@ -198,8 +201,8 @@ public class CommunityTagController extends BaseController {
     @GetMapping("/tagsTakeBlock")
     @Transactional
     //@Anonymous
-    public AjaxResult tagsTakeBlock(String tagName) {
-        List<CommunityTagVo> communityTagVos = new ArrayList<>();
+    public AjaxResult tagsTakeBlock(Long userId) {
+       /* List<CommunityTagVo> communityTagVos = new ArrayList<>();
         try {
             Page<CommunityTag> page = new Page<>(1, 10);
             List<CommunityTag> communityTags = communityTagService.page(page, new QueryWrapper<CommunityTag>().and((wrapper) -> {
@@ -239,10 +242,36 @@ public class CommunityTagController extends BaseController {
             System.out.println(e.getMessage());
             throw new ProjectException();
         }
+*/
+        if (userId == null) {
+            userId = SecurityUtils.getUserId();
+        }
+        List<CommunityTag> communityTags = null;
+        try {
+            //获取关注的圈子ID
+            List<CommunityTagBlock> userTags = communityTagBlockMapper
+                    .selectList(new QueryWrapper<CommunityTagBlock>()
+                            .eq("user_id", userId)
+                            .eq("is_block", 1));
 
+            List<Long> tagList = userTags.stream().map(CommunityTagBlock::getTagId).collect(Collectors.toList());
+            if (tagList.size() == 0){
+                return AjaxResult.success(communityTags);
+            }
+
+            communityTags= communityTagMapper.selectList(new QueryWrapper<CommunityTag>()
+                    .in("id", tagList)
+                    .and((wrapper) -> {
+                        wrapper.ne("is_delete", 1).or().isNull("is_delete");
+                    }));
 
 
-        return AjaxResult.success(communityTagVos);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            throw new ProjectException();
+        }
+
+        return AjaxResult.success(communityTags);
     }
 
     /**