Ver código fonte

服务代码优化

fangzhen 3 meses atrás
pai
commit
1a52155374

+ 4 - 3
ruoyi-admin/src/main/resources/application-druid.yml

@@ -6,9 +6,10 @@ spring:
         druid:
             # 主库数据源  47.122.10.161 121.4.140.159
             master:
-                url: jdbc:mysql://47.122.10.161:3306/ruoyi-community?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                username: root
-                password: fz,961202.
+                #url: jdbc:mysql://rm-bp12v02802jkd05j89o.mysql.rds.aliyuncs.com:3306/ruoyi-community?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://rm-bp12v02802jkd05j89o.mysql.rds.aliyuncs.com:3306/ruoyi-community?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                username: cysd
+                password: cysd123!@#
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭

+ 4 - 2
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -174,6 +174,7 @@ public class CommunityArticleController extends BaseController {
     @Transactional
     //@Anonymous
     public AjaxResult article(@RequestBody CommunityArticle communityArticle) {
+        System.out.println("communityArticle:" + communityArticle.toString());
         try {
             if (communityArticle.getClassIds().isEmpty()) {
                 return AjaxResult.error("板块不能为空");
@@ -207,6 +208,7 @@ public class CommunityArticleController extends BaseController {
     //@Anonymous
     public AjaxResult editArticle(@RequestBody CommunityArticle communityArticle) {
         try {
+            System.out.println("communityArticle:" + communityArticle);
             if (communityArticle.getClassIds().isEmpty()) {
                 return AjaxResult.error("板块不能为空");
             }
@@ -1296,10 +1298,10 @@ public class CommunityArticleController extends BaseController {
     @PostMapping("/articleAt")
     @Anonymous
     public AjaxResult articleAt(@RequestBody CommunityArticleAt communityArticleAt) {
-        if (Objects.isNull(communityArticleAt.getPeerId()) ) {
+        if (Objects.isNull(communityArticleAt.getPeerId())) {
             return AjaxResult.error("@人ID不能为空");
         }
-        Long  userId = SecurityUtils.getUserId();
+        Long userId = SecurityUtils.getUserId();
         try {
             communityArticleAt.setCreateBy(userId);
             communityArticleAt.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));

+ 14 - 16
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -753,10 +753,9 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
 
         // at 人插入at通知表 判断是不是草稿箱 草稿箱不需要通知
-        if (!communityArticle.getIsDraft()) {
+        if (communityArticle.getIsDraft() != null && !communityArticle.getIsDraft()) {
             //拿到需要At人的ID
             List<Long> atUserIds = communityArticle.getAtUserIds();
-
             if (atUserIds != null && !atUserIds.isEmpty()) {
                 List<CommunityArticleAt> communityArticleAts = new ArrayList<>();
                 CommunityArticleAt communityArticleAt = null;
@@ -806,20 +805,19 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
         //插入标签日志
         List<String> tags = communityArticle.getTags();
-
-        //不在本次更新的标签都传失效
-        communityArticleTagMapper.update(
-                null,
-                new UpdateWrapper<CommunityArticleTag>()
-                        .eq("article_id", communityArticle.getId())
-                        .notIn("tag_id", tags)
-                        .set("is_delete", true)
-                        .and((wrapper) -> {
-                            wrapper.ne("is_delete", 1).or().isNull("is_delete");
-                        })
-        );
-
         if (tags != null && !tags.isEmpty()) {
+            //不在本次更新的标签都传失效
+            communityArticleTagMapper.update(
+                    null,
+                    new UpdateWrapper<CommunityArticleTag>()
+                            .eq("article_id", communityArticle.getId())
+                            .notIn("tag_id", tags)
+                            .set("is_delete", true)
+                            .and((wrapper) -> {
+                                wrapper.ne("is_delete", 1).or().isNull("is_delete");
+                            })
+            );
+
             CommunityArticleTag tagLog = null;
             for (String tag : tags) {
 
@@ -936,7 +934,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
 
         // at 人插入at通知表 判断是不是草稿箱 草稿箱不需要通知
-        if (!communityArticle.getIsDraft()) {
+        if (communityArticle.getIsDraft() != null && !communityArticle.getIsDraft()) {
             //拿到需要At人的ID
             List<Long> atUserIds = communityArticle.getAtUserIds();