Переглянути джерело

seo管理 关键词管理重构

zq940222 5 місяців тому
батько
коміт
6b8158cdd9

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

@@ -4,7 +4,7 @@ import cn.hutool.core.io.IoUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
 import cn.hutool.poi.excel.ExcelWriter;
 
 
-import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xkcoding.http.util.StringUtil;
 import com.xkcoding.http.util.StringUtil;
@@ -23,8 +23,8 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.common.util.FastJsonUtil;
 import org.jeecg.config.security.utils.SecureUtil;
 import org.jeecg.config.security.utils.SecureUtil;
 import org.jeecg.modules.adweb.seo.dto.AvesApiSearchKeywordsDTO;
 import org.jeecg.modules.adweb.seo.dto.AvesApiSearchKeywordsDTO;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
@@ -79,54 +79,10 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
         if ((seoKeywords.getSiteCode() == null || seoKeywords.getSiteCode().isEmpty())) {
         if ((seoKeywords.getSiteCode() == null || seoKeywords.getSiteCode().isEmpty())) {
             return Result.error("请选择站点");
             return Result.error("请选择站点");
         }
         }
-        //		QueryWrapper<SeoKeywords> queryWrapper = QueryGenerator.initQueryWrapper(seoKeywords,
-        // req.getParameterMap());
-        //		Page<SeoKeywords> page = new Page<SeoKeywords>(pageNo, pageSize);
-        //		IPage<SeoKeywords> pageList = seoKeywordsService.page(page, queryWrapper);
-        //		return Result.OK(pageList);
-        String siteCode = null;
-        String userFlag = req.getParameter("siteCode");
-        if (StringUtil.isNotEmpty(userFlag)) {
-            siteCode = userFlag;
-        }
-
-        // 根据用户做筛选
-        if (!sysBaseAPI.isAdmin()) {
-            if (seoKeywords.getSiteId() != null) {
-                JSONObject jsonObject = sysBaseAPI.getSiteInfoById(seoKeywords.getSiteId());
-                log.info("jsonObject:{}", FastJsonUtil.toJSONString(jsonObject));
-                siteCode = jsonObject.getString("code");
-            } else {
-                return Result.error("fail");
-            }
-        }
-
-        // 根据关键词做筛选
-        String keywords = req.getParameter("keywords");
-
-        // 根据创建时间做筛选
-        String createTime = req.getParameter("createTime");
-
-        // 根据最后搜索时间查询
-        String lastSearchTime = req.getParameter("lastSearchTime");
-
-        // 根据订阅ID查询
-        String subscriptionId = seoKeywords.getSubscriptionId();
-        String order = seoKeywords.getOrder();
-        String column = seoKeywords.getColumn();
-        Page<SeoKeywords> page = new Page<>(pageNo, pageSize);
-        IPage<SeoKeywords> pageList =
-                seoKeywordsService.pageList(
-                        page,
-                        siteCode,
-                        keywords,
-                        subscriptionId,
-                        lastSearchTime,
-                        createTime,
-                        seoKeywords.getKeywordType(),
-                        column,
-                        order,
-                        seoKeywords.getKeywordRank());
+        QueryWrapper<SeoKeywords> queryWrapper =
+                QueryGenerator.initQueryWrapper(seoKeywords, req.getParameterMap());
+        Page<SeoKeywords> page = new Page<SeoKeywords>(pageNo, pageSize);
+        IPage<SeoKeywords> pageList = seoKeywordsService.page(page, queryWrapper);
         return Result.OK(pageList);
         return Result.OK(pageList);
     }
     }
 
 
@@ -448,4 +404,22 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
             e.printStackTrace();
             e.printStackTrace();
         }
         }
     }
     }
+
+    /**
+     * @param seoKeywords
+     * @return
+     */
+    @GetMapping(value = "/getSeoKeyword")
+    public Result<?> getSeoKeyword(SeoKeywords seoKeywords) {
+        QueryWrapper<SeoKeywords> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("keywords", seoKeywords.getKeywords());
+        queryWrapper.eq("site_code", seoKeywords.getSiteCode());
+        queryWrapper.ne("status", 0);
+        queryWrapper.eq("subscription_id", seoKeywords.getSubscriptionId());
+        List<SeoKeywords> seoKeywordsList = seoKeywordsService.list(queryWrapper);
+        if (!seoKeywordsList.isEmpty()) {
+            return Result.OK(false);
+        }
+        return Result.OK(true);
+    }
 }
 }

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoKeywordsRankServiceImpl.java

@@ -17,7 +17,7 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.adweb.common.constant.AdwebConstant;
 import org.jeecg.modules.adweb.common.constant.AdwebConstant;
-import org.jeecg.modules.adweb.seo.entity.ComprehensiveStatistics;
+import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywordsSerp;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywordsSerp;
 import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
 import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;

+ 32 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoKeywordsServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.adweb.seo.service.impl;
 package org.jeecg.modules.adweb.seo.service.impl;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 
 import jakarta.annotation.Resource;
 import jakarta.annotation.Resource;
@@ -97,4 +98,35 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
 
 
         return seoKeywordsMapper.getKeywordList(page, rankStart, rankEnd, isCustomer, keyword, siteCode, keywordType, datesStr, historyId,column,order,buttonColumn,buttonSort);
         return seoKeywordsMapper.getKeywordList(page, rankStart, rankEnd, isCustomer, keyword, siteCode, keywordType, datesStr, historyId,column,order,buttonColumn,buttonSort);
     }
     }
+
+    /**
+     * 关键词管理列表数据
+     * @param page
+     * @param siteCode
+     * @param keywords
+     * @param historyId
+     * @param lastSearchTime
+     * @param createTime
+     * @param keywordType
+     * @param column
+     * @param order
+     * @param keywordRank
+     * @return
+     */
+    @Override
+    public IPage<SeoKeywords> pageList(Page<SeoKeywords> page, String siteCode, String keywords, String historyId, String lastSearchTime, String createTime, Integer keywordType,
+                                       String column, String order, Integer keywordRank){
+        if(column.equals("createTime")){
+            column = "create_time";
+            return seoKeywordsMapper.getPageListByCreateTime(page,siteCode,keywords,historyId,lastSearchTime,createTime,keywordType,column,order,keywordRank);
+        }else if(column.equals("lastSearchTime")){
+            column = "last_search_time";
+            return seoKeywordsMapper.getPageListByCreateTime(page,siteCode,keywords,historyId,lastSearchTime,createTime,keywordType,column,order,keywordRank);
+        }else if (column.equals("lastRank")){
+            column = "last_rank";
+        } else if (column.equals("keywords")){
+            column = "keywords";
+        }
+        return seoKeywordsMapper.getPageList(page,siteCode,keywords,historyId,lastSearchTime,createTime,keywordType,column,order,keywordRank);
+    }
 }
 }