Browse Source

seo管理 关键词管理调整

zq940222 4 months ago
parent
commit
e3aaf586c1

+ 41 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsController.java

@@ -27,6 +27,7 @@ import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.modules.adweb.common.constant.AdwebConstant;
 import org.jeecg.modules.adweb.seo.dto.AvesApiSearchKeywordsDTO;
+import org.jeecg.modules.adweb.seo.dto.ChangeTypeDTO;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
@@ -524,4 +525,44 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
         }
         return Result.OK(true);
     }
+
+    /**
+     * 关键词类型更改
+     *
+     * @return
+     */
+    @PostMapping(value = "/changeType")
+    public Result<?> changeType(@RequestBody ChangeTypeDTO changeTypeDTO) {
+        Integer id = changeTypeDTO.getId();
+        Integer type = changeTypeDTO.getType();
+        if (id == null || type == null) {
+            return Result.error("参数错误!");
+        }
+        SeoKeywords temp = seoKeywordsService.getById(id);
+        // 改为指定关键词时,判断是否是别的关键词的相关关键词,改为长尾关键词时,判断是否具有相关关键词
+        if (type == 2) {
+            QueryWrapper<SeoKeywords> queryWrapper2 = new QueryWrapper<>();
+            queryWrapper2.ne("status", 0);
+            queryWrapper2.eq("subscription_id", temp.getSubscriptionId());
+            queryWrapper2.eq("related_keyword_id", id);
+            if (seoKeywordsService.count(queryWrapper2) > 0) {
+                return Result.error("此关键词已经关联长尾词!");
+            }
+        }
+        if (type == 1) {
+            SeoKeywords word = seoKeywordsService.getById(id);
+            if (word != null && word.getRelatedKeywordId() != null) {
+                return Result.error("此关键词已关联指定关键词!");
+            }
+        }
+
+        SeoKeywords seoKeywords = new SeoKeywords();
+        seoKeywords.setId(id);
+        seoKeywords.setKeywordType(type);
+        boolean flag = seoKeywordsService.updateById(seoKeywords);
+        if (flag) {
+            return Result.OK("关键词类型更改成功!");
+        }
+        return Result.error("更改失败!");
+    }
 }

+ 14 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/dto/ChangeTypeDTO.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.adweb.seo.dto;
+
+import lombok.Data;
+
+/**
+ * @author Zenas
+ */
+@Data
+public class ChangeTypeDTO {
+
+    Integer id;
+
+    Integer type;
+}