fangzhen hace 6 meses
padre
commit
40a76a608b

+ 6 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java

@@ -12,6 +12,7 @@ import com.ruoyi.common.utils.sign.Base64;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.generator.util.SendSms;
 import com.ruoyi.system.service.ISysConfigService;
+import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.FastByteArrayOutputStream;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -99,7 +100,7 @@ public class CaptchaController {
             return AjaxResult.error("手机号不正确!");
         }
 
-        if (StringUtils.isEmpty(smsType)) {
+        if (StringUtils.isBlank(smsType)) {
             return AjaxResult.error("参数异常!");
         }
 
@@ -119,6 +120,10 @@ public class CaptchaController {
                 break;
         }
 
+        if (Strings.isBlank(verifyKey)) {
+            return AjaxResult.error("参数异常!");
+        }
+
         //2.发送验证码
         SendSms.sendMsg("次元时代App", "SMS_474845159", phoneNumber, String.valueOf(code));
         //3.存入redis

+ 43 - 36
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -270,40 +270,44 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
         communityArticleMapper.insert(communityArticle);
         //插入标签日志
         List<String> tags = communityArticle.getTags();
-        CommunityArticleTag tagLog = null;
-        for (String tag : tags) {
-            tagLog = new CommunityArticleTag();
-            tagLog.setArticleId(communityArticle.getId());
-            tagLog.setTagId(Long.parseLong(tag));
-            tagLog.setUpdateBy(userId);
-            tagLog.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
-            tagLog.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
-            tagLog.setCreateBy(userId);
-            articleTagMapper.insert(tagLog);
-
-            //标签热度自增
-            CommunityTag communityTag = communityTagMapper.selectById(Long.parseLong(tag));
-            communityTag.setTagHot(Objects.isNull(communityTag.getTagHot()) ? 1 : communityTag.getTagHot() + 1);
-            communityTag.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
-            communityTag.setUpdateBy(userId);
-            communityTagMapper.updateById(communityTag);
+        if (tags != null && !tags.isEmpty()) {
+            CommunityArticleTag tagLog = null;
+            for (String tag : tags) {
+                tagLog = new CommunityArticleTag();
+                tagLog.setArticleId(communityArticle.getId());
+                tagLog.setTagId(Long.parseLong(tag));
+                tagLog.setUpdateBy(userId);
+                tagLog.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
+                tagLog.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+                tagLog.setCreateBy(userId);
+                articleTagMapper.insert(tagLog);
+
+                //标签热度自增
+                CommunityTag communityTag = communityTagMapper.selectById(Long.parseLong(tag));
+                communityTag.setTagHot(Objects.isNull(communityTag.getTagHot()) ? 1 : communityTag.getTagHot() + 1);
+                communityTag.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
+                communityTag.setUpdateBy(userId);
+                communityTagMapper.updateById(communityTag);
+            }
         }
 
         //插入图片日志
         List<String> images = communityArticle.getImages();
-        CommunityArticleImages articleImages = null;
-        for (String image : images) {
-            articleImages = new CommunityArticleImages();
-            articleImages.setArticleId(communityArticle.getId());
-            articleImages.setImageUrl(image);
-            articleImages.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
-            articleImages.setCreateBy(userId);
-            communityArticleImagesMapper.insert(articleImages);
+        if (images != null && !images.isEmpty()) {
+            CommunityArticleImages articleImages = null;
+            for (String image : images) {
+                articleImages = new CommunityArticleImages();
+                articleImages.setArticleId(communityArticle.getId());
+                articleImages.setImageUrl(image);
+                articleImages.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+                articleImages.setCreateBy(userId);
+                communityArticleImagesMapper.insert(articleImages);
+            }
         }
 
         //插入板块
         List<Long> classIds = communityArticle.getClassIds();
-        if (!classIds.isEmpty()) {
+        if (classIds != null && !classIds.isEmpty()) {
             List<CommunityArticleClass> articleClasses = new ArrayList<>();
             CommunityArticleClass articleClass = null;
             for (Long classId : classIds) {
@@ -319,17 +323,20 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
         //插入合集
         List<String> collectionIds = communityArticle.getCollectionIds();
-        List<CommunityCollectionArticle> collectionArticles = new ArrayList<>();
-        CommunityCollectionArticle collectionArticle = null;
-        for (String collectionId : collectionIds) {
-            collectionArticle = new CommunityCollectionArticle();
-            collectionArticle.setCollectionId(Long.parseLong(collectionId));
-            collectionArticle.setArticleId(communityArticle.getId());
-            collectionArticle.setCreateBy(userId);
-            collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
-            collectionArticles.add(collectionArticle);
+        if (collectionIds != null && !collectionIds.isEmpty()) {
+            List<CommunityCollectionArticle> collectionArticles = new ArrayList<>();
+            CommunityCollectionArticle collectionArticle = null;
+            for (String collectionId : collectionIds) {
+                collectionArticle = new CommunityCollectionArticle();
+                collectionArticle.setCollectionId(Long.parseLong(collectionId));
+                collectionArticle.setArticleId(communityArticle.getId());
+                collectionArticle.setCreateBy(userId);
+                collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+                collectionArticles.add(collectionArticle);
+            }
+            collectionArticleService.saveBatch(collectionArticles);
         }
-        collectionArticleService.saveBatch(collectionArticles);
+
     }