Browse Source

全局保留一个admin 逻辑的特殊判断

chenlei1231 3 months ago
parent
commit
828ac964a0

+ 0 - 2
jeecg-module-system/jeecg-system-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java

@@ -610,6 +610,4 @@ public interface ISysBaseAPI extends CommonAPI {
      */
     boolean dictTableWhiteListCheckByDict(String tableOrDictCode, String... fields);
 
-    boolean isAdmin();
-
 }

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

@@ -23,7 +23,6 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
-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;
@@ -35,6 +34,7 @@ import org.jeecg.modules.adweb.seo.service.ISeoKeywordsService;
 import org.jeecg.modules.adweb.seo.service.ISeoPlanSubscriptionService;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.system.service.SysAdwebApi;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -60,17 +60,23 @@ import static cn.hutool.core.collection.CollUtil.distinct;
 @RequestMapping("/seo/seoKeywords")
 @Slf4j
 public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeywordsService> {
-    @Autowired private ISeoKeywordsService seoKeywordsService;
+    @Autowired
+    private ISeoKeywordsService seoKeywordsService;
 
-    @Autowired ISeoKeywordsRankService seoKeywordsRankService;
+    @Autowired
+    ISeoKeywordsRankService seoKeywordsRankService;
 
-    @Autowired ISeoKeywordsRankService seoKpiStatisticsService;
+    @Autowired
+    ISeoKeywordsRankService seoKpiStatisticsService;
 
-    @Autowired private ISysBaseAPI sysBaseAPI;
+    @Autowired
+    private SysAdwebApi sysAdwebApi;
 
-    @Autowired private IAdwebSiteService adwebSiteService;
+    @Autowired
+    private IAdwebSiteService adwebSiteService;
 
-    @Autowired private ISeoPlanSubscriptionService seoPlanSubscriptionService;
+    @Autowired
+    private ISeoPlanSubscriptionService seoPlanSubscriptionService;
 
     @Value("${jeecg.path.upload}")
     private String uploadUrl;
@@ -212,7 +218,9 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
         return super.exportXls(request, seoKeywords, SeoKeywords.class, "关键词");
     }
 
-    /** 关键词排名页面 - 列表数据 */
+    /**
+     * 关键词排名页面 - 列表数据
+     */
     @AutoLog(value = "营销推广-SEO-关键词排名统计查询接口")
     @RequestMapping(value = "/keywordList")
     public Result<?> queryRankInfoList(
@@ -297,7 +305,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
         }
         ArrayList<String> columns = null;
         // 表头信息
-        if (sysBaseAPI.isAdmin()) {
+        if (sysAdwebApi.isAdmin()) {
             columns = new ArrayList<>(Arrays.asList("序号", "关键词", "url", "关键词类型"));
         } else {
             columns = new ArrayList<>(Arrays.asList("序号", "关键词", "关键词类型"));
@@ -310,7 +318,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
         List<String> dates = pageList.getRecords().get(0).getDateList();
         columns.addAll(dates);
 
-        boolean isAdmin = sysBaseAPI.isAdmin();
+        boolean isAdmin = sysAdwebApi.isAdmin();
 
         for (int i = 0; i < enquiryList.size(); i++) {
             SeoKeywords seoKeywords = enquiryList.get(i);
@@ -352,7 +360,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
                     "Content-Disposition",
                     "attachment;filename="
                             + new String(
-                                    (fileName + ".xlsx").getBytes(), StandardCharsets.ISO_8859_1));
+                            (fileName + ".xlsx").getBytes(), StandardCharsets.ISO_8859_1));
             out = response.getOutputStream();
             log.info("导出数据:" + list);
             writer.write(list, true);
@@ -406,7 +414,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
             try {
                 SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd");
                 String formattedDate = dateFormat.format(now);
-                File realFile = new File(uploadUrl, formattedDate + RandomStringUtils.random(4,true,true) + ".xlsx");
+                File realFile = new File(uploadUrl, formattedDate + RandomStringUtils.random(4, true, true) + ".xlsx");
                 file.transferTo(realFile);
                 stream = new FileInputStream(realFile);
                 XSSFWorkbook workbook = new XSSFWorkbook(stream);
@@ -460,7 +468,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
                 }
 
                 //新增关键词本身去重
-                Integer originalSize =  list.size();
+                Integer originalSize = list.size();
                 List<SeoKeywords> listNew = distinct(list);
                 // 去重
                 QueryWrapper<SeoKeywords> queryWrapper = new QueryWrapper<>();
@@ -486,8 +494,8 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
                 }
 
                 String msg = "关键词导入成功!关键词个数:" + listNew.size();
-                if(originalSize>listNew.size()){
-                    msg = "关键词导入成功!关键词个数:" + listNew.size()+",重复关键词已去除!重复个数:"+(originalSize-listNew.size());
+                if (originalSize > listNew.size()) {
+                    msg = "关键词导入成功!关键词个数:" + listNew.size() + ",重复关键词已去除!重复个数:" + (originalSize - listNew.size());
                 }
 
                 return seoKeywordsService.saveBatch(listNew) ? Result.OK(msg) : Result.error("关键词导入失败!");
@@ -507,7 +515,6 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
     }
 
 
-
     /**
      * @param seoKeywords
      * @return

+ 0 - 25
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java

@@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
-import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.dto.DataLogDTO;
 import org.jeecg.common.api.dto.OnlineAuthDTO;
 import org.jeecg.common.api.dto.message.*;
@@ -1883,28 +1882,4 @@ public class SysBaseApiImpl implements ISysBaseAPI {
         return obj;
     }
 
-    /**
-     * 根据username判断一个用户是否是管理员
-     *
-     * @return
-     */
-    @Override
-    public boolean isAdmin() {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        String username = sysUser.getUsername();
-        List<String> adminRoleIdList = new ArrayList<>();    // 管理员角色id列表
-        adminRoleIdList.add("admin");
-        adminRoleIdList.add("adweb_admin");
-        adminRoleIdList.add("seo_admin");
-        adminRoleIdList.add("adweb_site_manager");
-        adminRoleIdList.add("adweb_seo_manager");
-        List<String> roles = this.getRolesByUsername(username);
-        for (String role : roles) {
-            if (adminRoleIdList.contains(role)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
 }