Bladeren bron

代码优化

fangzhen 5 maanden geleden
bovenliggende
commit
ad2ff61ade

+ 48 - 24
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -20,7 +20,6 @@ import com.ruoyi.generator.vo.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.logging.log4j.util.Strings;
-import org.apache.poi.xssf.usermodel.XSSFPivotTable;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -85,7 +84,7 @@ public class CommunityArticleController extends BaseController {
     private CommunityCollectionMapper communityCollectionMapper;
 
     @Autowired
-    private  CommunityTagMapper communityTagMapper;
+    private CommunityTagMapper communityTagMapper;
 
     @Autowired
     private CommunityCircleExpandMapper communityCircleExpandMapper;
@@ -118,6 +117,7 @@ public class CommunityArticleController extends BaseController {
             rspData.setMsg("查询成功");
             rspData.setRows(list);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return rspData;
@@ -137,6 +137,7 @@ public class CommunityArticleController extends BaseController {
             }
             communityArticleService.insertCommunityArticle(communityArticle);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success("文章发布成功!");
@@ -161,6 +162,7 @@ public class CommunityArticleController extends BaseController {
                 return success("删除成功!");
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return error("删除失败!");
@@ -175,6 +177,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityClasses = communityClassMapper.selectList(new QueryWrapper<CommunityClass>());
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success(communityClasses);
@@ -196,22 +199,23 @@ public class CommunityArticleController extends BaseController {
                 oneObject.put("oneName", circleName);
                 oneObject.put("oneId", communityCircleExpand.getId());
                 JSONArray twoArray = new JSONArray();
-                List<CommunityCircle> classNameByCircleId = communityClassCircleMapper.getClassNameByCircleId(userId,id);
+                List<CommunityCircle> classNameByCircleId = communityClassCircleMapper.getClassNameByCircleId(userId, id);
                 // 将 List<CommunityCircle> 转换为 JSONArray
                 for (CommunityCircle communityCircle : classNameByCircleId) {
                     JSONObject twoObject = new JSONObject();
                     twoObject.put("twoId", communityCircle.getId());
                     twoObject.put("twoName", communityCircle.getCircleName());
                     twoObject.put("twoImg", communityCircle.getImageUrl());
-                    twoObject.put("isCare",communityCircle.getIsCare());
-                    twoObject.put("heat",communityCircle.getHeat());
+                    twoObject.put("isCare", communityCircle.getIsCare());
+                    twoObject.put("heat", communityCircle.getHeat());
                     twoArray.add(twoObject);
                 }
                 oneObject.put("one", twoArray);
                 sumArray.add(oneObject); // 添加到 sumArray
             }
         } catch (Exception e) {
-             throw new ProjectException();
+            System.out.println(e.getMessage());
+            throw new ProjectException();
         }
 
         return AjaxResult.success(sumArray);
@@ -236,6 +240,7 @@ public class CommunityArticleController extends BaseController {
             //新增评论
             communityArticleService.sendComment(communityArticleComment);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success();
@@ -254,6 +259,7 @@ public class CommunityArticleController extends BaseController {
             //删除评论
             communityArticleService.deleteComment(articleComment);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success();
@@ -293,6 +299,7 @@ public class CommunityArticleController extends BaseController {
                 return AjaxResult.error(message);
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -343,6 +350,7 @@ public class CommunityArticleController extends BaseController {
                 return AjaxResult.error(message);
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -381,6 +389,7 @@ public class CommunityArticleController extends BaseController {
                 return AjaxResult.error(message);
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -434,6 +443,7 @@ public class CommunityArticleController extends BaseController {
                 message = "取消点赞";
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -452,6 +462,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityCircles = communityArticleService.selectCommunityCircleList(classId);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success(communityCircles);
@@ -484,7 +495,7 @@ public class CommunityArticleController extends BaseController {
             }
 
             //为空返回空值
-            if (communityCircles == null){
+            if (communityCircles == null) {
                 return AjaxResult.success("圈子为空");
             }
 
@@ -500,6 +511,7 @@ public class CommunityArticleController extends BaseController {
 
 
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -546,6 +558,7 @@ public class CommunityArticleController extends BaseController {
                 msg = "已取关";
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -575,6 +588,7 @@ public class CommunityArticleController extends BaseController {
                 msg = "已关注";
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -591,6 +605,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(userId);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success(communityUserInfoVo);
@@ -623,6 +638,7 @@ public class CommunityArticleController extends BaseController {
             }
         } catch (Exception e) {
             // e.printStackTrace();
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -669,6 +685,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityUserLikeVos = communityArticleService.selectUserFansList(SecurityUtils.getLoginUser().getUserId());
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -682,6 +699,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityUserLikeVos = communityArticleService.selectMutualAttention(SecurityUtils.getLoginUser().getUserId());
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -717,6 +735,7 @@ public class CommunityArticleController extends BaseController {
             communityUserInfo.setBackImage(backImage);
             communityUserInfoMapper.updateById(communityUserInfo);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success("背景图片上传成功!");
@@ -742,13 +761,11 @@ public class CommunityArticleController extends BaseController {
 
         List<CommunityCollectionVo> communityCollectionVos = null;
         try {
-          communityCollectionVos = communityCollectionService.selectUserCollection(userId, articleId);
+            communityCollectionVos = communityCollectionService.selectUserCollection(userId, articleId);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
-
-
-
         return AjaxResult.success(communityCollectionVos);
     }
 
@@ -792,6 +809,7 @@ public class CommunityArticleController extends BaseController {
             communityCollection.setDelete(false);
             communityCollectionService.save(communityCollection);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -814,6 +832,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityCollectionService.deleteCollectionById(collectionId);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success("删除成功!");
@@ -900,6 +919,7 @@ public class CommunityArticleController extends BaseController {
             collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
             communityCollectionService.addArticleToCollection(collectionArticle);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -923,6 +943,7 @@ public class CommunityArticleController extends BaseController {
         try {
             communityCollectionService.deleteArticleToCollection(collectionId, articleId);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success("文章删除成功!");
@@ -936,15 +957,16 @@ public class CommunityArticleController extends BaseController {
      */
     @ApiOperation("查询用户合集")
     @GetMapping("/getCollection")
-    public AjaxResult getCollection(Long collectionId,Long  searchType) {
+    public AjaxResult getCollection(Long collectionId, Long searchType) {
         if (Objects.isNull(collectionId)) {
             return AjaxResult.error("合集不存在!");
         }
         List<CommunityCollectionArticleVo> collectionArticleVos = null;
         JSONArray jsonArray;
         try {
-           jsonArray = communityCollectionService.selectArticleInfoInCollection(collectionId,searchType);
+            jsonArray = communityCollectionService.selectArticleInfoInCollection(collectionId, searchType);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success(jsonArray);
@@ -952,6 +974,7 @@ public class CommunityArticleController extends BaseController {
 
     /**
      * 搜索关键字
+     *
      * @param content
      * @return 内容
      * fangqing
@@ -964,13 +987,15 @@ public class CommunityArticleController extends BaseController {
         try {
             trendingTops = communityArticleMapper.selectTrendingTopByContent(content);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
-        return AjaxResult.success("获取成功!",trendingTops);
+        return AjaxResult.success("获取成功!", trendingTops);
     }
 
     /**
      * 订阅/取订合集
+     *
      * @param collectionUser
      * @return 内容
      * fangqing
@@ -980,7 +1005,7 @@ public class CommunityArticleController extends BaseController {
     @Transactional
     //@Anonymous
     public AjaxResult subscribeCollection(@RequestBody CommunityCollectionUser collectionUser) {
-        if (Objects.isNull(collectionUser.getCollectionId()) ) {
+        if (Objects.isNull(collectionUser.getCollectionId())) {
             return AjaxResult.error("参数异常!");
         }
 
@@ -988,10 +1013,11 @@ public class CommunityArticleController extends BaseController {
         try {
             communityCollectionUser = communityCollectionUserService.subscribeCollection(collectionUser);
 
-            if (communityCollectionUser == null){
+            if (communityCollectionUser == null) {
                 return AjaxResult.success("不能关注自己创建的合集/传参有误");
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -1003,21 +1029,19 @@ public class CommunityArticleController extends BaseController {
     @GetMapping("/userPrompt")
     public AjaxResult userPrompt() {
 
-        Long  userId = SecurityUtils.getLoginUser().getUserId();
+        Long userId = SecurityUtils.getLoginUser().getUserId();
 
         CommunityUserPrompt communityUserPrompt = null;
         try {
-        communityUserPrompt = communityUserPromptMapper.selectOne(new QueryWrapper<CommunityUserPrompt>()
-                  .eq("create_by",userId));
+            communityUserPrompt = communityUserPromptMapper.selectOne(new QueryWrapper<CommunityUserPrompt>()
+                    .eq("create_by", userId));
 
-          System.out.println(communityUserPrompt);
+            System.out.println(communityUserPrompt);
         } catch (Exception e) {
-           e.printStackTrace();
+            System.out.println(e.getMessage());
+            throw new ProjectException();
         }
         return AjaxResult.success(communityUserPrompt);
     }
 
-
-
-
 }

+ 5 - 3
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -8,7 +8,6 @@ import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.user.ProjectException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
-import com.ruoyi.generator.domain.Community.CommunityArticle;
 import com.ruoyi.generator.domain.Community.CommunityUserBlock;
 import com.ruoyi.generator.mapper.community.CommunityUserBlockMapper;
 import com.ruoyi.system.domain.CommunityChatMsg;
@@ -112,8 +111,8 @@ public class CommunityChatMsgController extends BaseController {
                 chatMsgVos.add(chatMsgVo);
             }
         } catch (Exception e) {
-            e.printStackTrace();
-            //throw new ProjectException();
+            System.out.println(e.getMessage());
+            throw new ProjectException();
         }
 
 
@@ -131,6 +130,7 @@ public class CommunityChatMsgController extends BaseController {
         try {
             sysUserChatVos = communityChatMsgService.getChatListWithLatestMessage(userId, type);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success(sysUserChatVos);
@@ -151,6 +151,7 @@ public class CommunityChatMsgController extends BaseController {
             hasUnreadMessages = sysUserChatVos.stream()
                     .anyMatch(vo -> Objects.equals(vo.getReceiverId(), userId) && !vo.isReceiverIsRead());
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success(hasUnreadMessages);
@@ -185,6 +186,7 @@ public class CommunityChatMsgController extends BaseController {
                             })
             );
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
         return AjaxResult.success("清空聊天记录成功");

+ 4 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityCommentController.java

@@ -126,6 +126,7 @@ public class CommunityCommentController extends BaseController {
                 vo.setReply(false);
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -176,6 +177,7 @@ public class CommunityCommentController extends BaseController {
                 replyVos.add(replyVo);
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -207,6 +209,7 @@ public class CommunityCommentController extends BaseController {
             communityCommentReply.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
             communityCommentReplyService.save(communityCommentReply);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -239,6 +242,7 @@ public class CommunityCommentController extends BaseController {
             communityCommentReply.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
             communityCommentReplyService.updateById(communityCommentReply);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 

+ 2 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityReportController.java

@@ -56,6 +56,7 @@ public class CommunityReportController extends BaseController {
                 }
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -76,6 +77,7 @@ public class CommunityReportController extends BaseController {
         try {
             communityReportService.save(communityReport);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 

+ 4 - 6
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunitySettingsController.java

@@ -3,10 +3,8 @@ package com.ruoyi.generator.controller;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.exception.user.ProjectException;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.generator.domain.Community.CommunityArticle;
 import com.ruoyi.generator.domain.Community.CommunityUserNotification;
 import com.ruoyi.generator.domain.Community.CommunityUserPrivacy;
-import com.ruoyi.generator.service.ICommunityArticleService;
 import com.ruoyi.generator.service.ICommunityNotificationService;
 import com.ruoyi.generator.service.ICommunityPrivacyService;
 import com.ruoyi.generator.vo.CommunityUserNotificationVo;
@@ -50,6 +48,7 @@ public class CommunitySettingsController {
         try {
             communityUserNotificationVos = communityNotificationService.selectUserNotification(SecurityUtils.getLoginUser().getUserId());
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -68,6 +67,7 @@ public class CommunitySettingsController {
         try {
             communityUserNotificationVos = communityNotificationService.modifyUserNotification(communityUserNotification);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -91,6 +91,7 @@ public class CommunitySettingsController {
         try {
             communityUserPrivacyVos = communityPrivacyService.selectUserPrivacy(userId);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -109,13 +110,10 @@ public class CommunitySettingsController {
         try {
             communityUserPrivacyVos = communityPrivacyService.modifyUserPrivacy(communityUserPrivacy);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
         return AjaxResult.success(communityUserPrivacyVos);
     }
-
-
-
-
 }

+ 4 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityTagController.java

@@ -60,6 +60,7 @@ public class CommunityTagController extends BaseController {
                     .like("tag_name", tagName)
                     .orderByDesc("tag_hot")).getRecords();
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -108,6 +109,7 @@ public class CommunityTagController extends BaseController {
                 }
             }
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -144,6 +146,7 @@ public class CommunityTagController extends BaseController {
             System.out.println("communityTag: " + communityTag);
             communityTagService.save(communityTag);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }
 
@@ -166,6 +169,7 @@ public class CommunityTagController extends BaseController {
         try {
             communityTagBlock = communityTagService.blockTag(tagBlock);
         } catch (Exception e) {
+            System.out.println(e.getMessage());
             throw new ProjectException();
         }