Forráskód Böngészése

站点嵌入问题修复

chenlei1231 5 hónapja
szülő
commit
7ce83a0978
19 módosított fájl, 891 hozzáadás és 130 törlés
  1. 43 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/AdwebConstant.java
  2. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/NumConstant.java
  3. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/WordPressConstants.java
  4. 21 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/domain/HttpApiResult.java
  5. 172 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/ListUtil.java
  6. 180 124
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/AdwebSiteController.java
  7. 49 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/entity/AdwebSitePermission.java
  8. 48 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/entity/AdwebSiteUserPermission.java
  9. 13 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/entity/SiteUserPermissionMapper.java
  10. 14 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/mapper/SitePermissionMapper.java
  11. 14 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/ISitePermissionService.java
  12. 20 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/ISiteUserPermissionService.java
  13. 3 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebSiteServiceImpl.java
  14. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebUserWpsiteServiceImpl.java
  15. 18 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SitePermissionServiceImpl.java
  16. 192 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SiteUserPermissionServiceImpl.java
  17. 12 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/system/service/SysAdwebApi.java
  18. 81 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/system/service/impl/SysAdwebApiImpl.java
  19. 8 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/entity/SysUser.java

+ 43 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/AdwebConstant.java

@@ -0,0 +1,43 @@
+package org.jeecg.modules.adweb.common.constant;
+
+public interface AdwebConstant {
+    /*网站类型(1模板,2站点)*/
+    public static final Integer TEMPLATE = 1;
+    public static final Integer SITE = 2;
+    public static final Integer WPTEMPLATE = 3;
+
+    /*网站状态 当前状态:0:已删除;1:正常; 2:未发布*/
+    public static final Integer SITE_DEL = 0;
+
+    public static final Integer SITE_PUBLISH = 1;
+
+    public static final Integer SITE_UNPUBLISH = 2;
+
+    /*菜单状态*/
+    public static final Integer MENU_DEL = 1;
+
+    /*模板配置状态*/
+    public static final Integer TEMPLATE_SETTING_DEL = 1;
+
+    /*模板上架状态*/
+    public static final Integer TEMPLATE_PUTAWAY = 1;
+
+    /*产品状态0删除1可用*/
+    public static final Integer STATUS = 1;
+
+    /*组件编码*/
+    public static final String PRODUCT = "product";
+
+    /*内容*/
+    public static final String NEWS = "news";
+
+    /*平台标识*/
+    public static final String APPKEY = "adweb";
+
+    /*内容分类*/
+    public static final String NEWSCATALOG = "newsCatalog";
+
+    public static final String PRODUCTCTALOG = "productCatalog";
+
+
+}

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/constant/NumConstant.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/NumConstant.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.adweb.constant;
+package org.jeecg.modules.adweb.common.constant;
 
 public class NumConstant {
 

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/constant/WordPressConstants.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/WordPressConstants.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.adweb.constant;
+package org.jeecg.modules.adweb.common.constant;
 
 public class WordPressConstants {
     public static final String SSO_RES_KEY_NAME = "Adweb_Wordpress_ssoResKey";

+ 21 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/domain/HttpApiResult.java

@@ -0,0 +1,21 @@
+package org.jeecg.modules.adweb.common.domain;
+
+import lombok.Data;
+import org.jeecg.modules.adweb.databridge.dto.APIStatus;
+
+
+@Data
+public class HttpApiResult {
+
+    private int code = APIStatus.SUCCESS.getCode();
+
+    private String msg = "";
+
+    private int count = 0;
+
+    private Object data;
+
+    public static HttpApiResult getInstance(){
+        return new HttpApiResult();
+    }
+}

+ 172 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/ListUtil.java

@@ -0,0 +1,172 @@
+package org.jeecg.modules.adweb.common.util;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.modules.adweb.common.constant.NumConstant;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+public final class ListUtil {
+
+    /**
+     * 判断集合是否为空
+     *
+     * @param list
+     * @return
+     */
+    public static boolean isEmpty(List list) {
+        if (list != null && list.size() != 0) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * 判断集合是否不为空
+     *
+     * @param list
+     * @return
+     */
+    public static boolean notEmpty(List list) {
+        if (list != null && list.size() != 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 返回集合大小
+     *
+     * @param list
+     * @return
+     */
+    public static int returnSize(List list) {
+        if (notEmpty(list)) {
+            return list.size();
+        } else {
+            return NumConstant.ZERO;
+        }
+    }
+
+    /**
+     * @param list 原集合
+     * @param str  符号
+     * @return java.lang.String
+     * @author 汤星鹏
+     * @Description 集合转字符串
+     * @date 2019/8/26 11:50
+     */
+    public static String listToString(List list, String str) {
+        if (ListUtil.notEmpty(list)) {
+            return list.stream().map(l->l.toString()).collect(Collectors.joining(str)).toString();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 将String类型的结合转Long类型
+     *
+     * @param list
+     * @return
+     */
+    public static List<Long> stringToLong(List<String> list) {
+
+        if (ListUtil.notEmpty(list)) {
+            List<Long> longList = new ArrayList<>();
+            list.forEach(l -> {
+                if (StringUtils.isNotBlank(l)) {
+                    longList.add(Long.parseLong(l));
+                }
+            });
+            return longList;
+        } else {
+            return new ArrayList<>();
+        }
+    }
+
+    /**
+     * @param list  集合
+     * @param index 下标
+     * @return java.lang.Object
+     * @author 汤星鹏
+     * @Description 获取对应下标对象
+     * @date 2019/11/5 9:31
+     */
+    public static <T> T listGetIndex(List<T> list, Integer index) {
+        if (ListUtil.notEmpty(list)) {
+            return list.get(index);
+        }
+        return null;
+    }
+
+    /**
+     * @param list 集合
+     * @return java.lang.Object
+     * @author 汤星鹏
+     * @Description 获取下标为o对应对象
+     * @date 2019/11/5 9:33
+     */
+    public static <T> T listGetZero(List<T> list) {
+        return listGetIndex(list, NumConstant.ZERO);
+    }
+
+    /**
+     * @param list
+     * @return java.util.List<T>
+     * @author 汤星鹏
+     * @Description 集合去重
+     * @date 2019/11/11 14:47
+     */
+    public static <T> List<T> distinct(List<T> list) {
+        if (notEmpty(list)) {
+            return list.stream().distinct().collect(Collectors.toList());
+        }
+        return null;
+    }
+
+    /**
+     * 分页函数
+     * @author pochettino
+     * @param currentPage   当前页数
+     * @param pageSize  每一页的数据条数
+     * @param list  要进行分页的数据列表
+     * @return  当前页要展示的数据
+     */
+    public static Page getPages(Integer currentPage, Integer pageSize, List list) {
+        Page page = new Page();
+        if(list==null){
+            return  null;
+        }
+        int size = list.size();
+
+        if(pageSize > size) {
+            pageSize = size;
+        }
+        if (pageSize!=0){
+            // 求出最大页数,防止currentPage越界
+            int maxPage = size % pageSize == 0 ? size / pageSize : size / pageSize + 1;
+
+            if(currentPage > maxPage) {
+                currentPage = maxPage;
+            }
+        }
+        // 当前页第一条数据的下标
+        int curIdx = currentPage > 1 ? (currentPage - 1) * pageSize : 0;
+
+        List pageList = new ArrayList();
+
+        // 将当前页的数据放进pageList
+        for(int i = 0; i < pageSize && curIdx + i < size; i++) {
+            pageList.add(list.get(curIdx + i));
+        }
+
+        page.setCurrent(currentPage).setSize(pageSize).setTotal(list.size()).setRecords(pageList);
+        return page;
+    }
+}

+ 180 - 124
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/AdwebSiteController.java

@@ -1,147 +1,162 @@
 package org.jeecg.modules.adweb.site.controller;
 
-import java.util.Arrays;
-
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.netty.util.internal.StringUtil;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+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.modules.adweb.common.constant.AdwebConstant;
+import org.jeecg.modules.adweb.common.domain.HttpApiResult;
+import org.jeecg.modules.adweb.common.util.ListUtil;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
-import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
+import org.jeecg.modules.adweb.system.service.SysAdwebApi;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.jeecg.common.aspect.annotation.AutoLog;
-import org.springframework.security.access.prepost.PreAuthorize;
 
- /**
+import java.util.Arrays;
+import java.util.List;
+
+/**
  * @Description: adweb站点配置表单
  * @Author: jeecg-boot
- * @Date:   2024-09-29
+ * @Date: 2024-09-29
  * @Version: V1.0
  */
-@Tag(name="adweb站点配置表单")
+@Tag(name = "adweb站点配置表单")
 @RestController
 @RequestMapping("/adweb/adwebSite")
 @Slf4j
 public class AdwebSiteController extends JeecgController<AdwebSite, IAdwebSiteService> {
+
+    @Autowired
+    private IAdwebSiteService adwebSiteService;
+
+    @Autowired
+    private SysAdwebApi sysAdwebApi;
+
 	@Autowired
-	private IAdwebSiteService adwebSiteService;
-	
-	/**
-	 * 分页列表查询
-	 *
-	 * @param adwebSite
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	//@AutoLog(value = "adweb站点配置表单-分页列表查询")
-	@Operation(summary="adweb站点配置表单-分页列表查询")
-	@GetMapping(value = "/list")
-	public Result<IPage<AdwebSite>> queryPageList(AdwebSite adwebSite,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<AdwebSite> queryWrapper = QueryGenerator.initQueryWrapper(adwebSite, req.getParameterMap());
-		Page<AdwebSite> page = new Page<AdwebSite>(pageNo, pageSize);
-		IPage<AdwebSite> pageList = adwebSiteService.page(page, queryWrapper);
-		return Result.OK(pageList);
-	}
-	
-	/**
-	 *   添加
-	 *
-	 * @param adwebSite
-	 * @return
-	 */
-	@AutoLog(value = "adweb站点配置表单-添加")
-	@Operation(summary="adweb站点配置表单-添加")
-	@PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:add')")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody AdwebSite adwebSite) {
-		adwebSiteService.save(adwebSite);
-		return Result.OK("添加成功!");
-	}
-	
-	/**
-	 *  编辑
-	 *
-	 * @param adwebSite
-	 * @return
-	 */
-	@AutoLog(value = "adweb站点配置表单-编辑")
-	@Operation(summary="adweb站点配置表单-编辑")
+	private ISiteUserPermissionService siteUserPermissionService;
+
+
+    /**
+     * 分页列表查询
+     *
+     * @param adwebSite
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "adweb站点配置表单-分页列表查询")
+    @Operation(summary = "adweb站点配置表单-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<AdwebSite>> queryPageList(AdwebSite adwebSite,
+                                                  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                  HttpServletRequest req) {
+        QueryWrapper<AdwebSite> queryWrapper = QueryGenerator.initQueryWrapper(adwebSite, req.getParameterMap());
+        Page<AdwebSite> page = new Page<AdwebSite>(pageNo, pageSize);
+        IPage<AdwebSite> pageList = adwebSiteService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 添加
+     *
+     * @param adwebSite
+     * @return
+     */
+    @AutoLog(value = "adweb站点配置表单-添加")
+    @Operation(summary = "adweb站点配置表单-添加")
+    @PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:add')")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody AdwebSite adwebSite) {
+        adwebSiteService.save(adwebSite);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param adwebSite
+     * @return
+     */
+    @AutoLog(value = "adweb站点配置表单-编辑")
+    @Operation(summary = "adweb站点配置表单-编辑")
     @PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:edit')")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody AdwebSite adwebSite) {
-		adwebSiteService.updateById(adwebSite);
-		return Result.OK("编辑成功!");
-	}
-	
-	/**
-	 *   通过id删除
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "adweb站点配置表单-通过id删除")
-	@Operation(summary="adweb站点配置表单-通过id删除")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody AdwebSite adwebSite) {
+        adwebSiteService.updateById(adwebSite);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "adweb站点配置表单-通过id删除")
+    @Operation(summary = "adweb站点配置表单-通过id删除")
     @PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:delete')")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		adwebSiteService.removeById(id);
-		return Result.OK("删除成功!");
-	}
-	
-	/**
-	 *  批量删除
-	 *
-	 * @param ids
-	 * @return
-	 */
-	@AutoLog(value = "adweb站点配置表单-批量删除")
-	@Operation(summary="adweb站点配置表单-批量删除")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        adwebSiteService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "adweb站点配置表单-批量删除")
+    @Operation(summary = "adweb站点配置表单-批量删除")
     @PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:deleteBatch')")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.adwebSiteService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("批量删除成功!");
-	}
-	
-	/**
-	 * 通过id查询
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "adweb站点配置表单-通过id查询")
-	@Operation(summary="adweb站点配置表单-通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<AdwebSite> queryById(@RequestParam(name="id",required=true) String id) {
-		AdwebSite adwebSite = adwebSiteService.getById(id);
-		if(adwebSite==null) {
-			return Result.error("未找到对应数据");
-		}
-		return Result.OK(adwebSite);
-	}
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.adwebSiteService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "adweb站点配置表单-通过id查询")
+    @Operation(summary = "adweb站点配置表单-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<AdwebSite> queryById(@RequestParam(name = "id", required = true) String id) {
+        AdwebSite adwebSite = adwebSiteService.getById(id);
+        if (adwebSite == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(adwebSite);
+    }
 
     /**
-    * 导出excel
-    *
-    * @param request
-    * @param adwebSite
-    */
+     * 导出excel
+     *
+     * @param request
+     * @param adwebSite
+     */
     @PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:exportXls')")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, AdwebSite adwebSite) {
@@ -149,16 +164,57 @@ public class AdwebSiteController extends JeecgController<AdwebSite, IAdwebSiteSe
     }
 
     /**
-      * 通过excel导入数据
-    *
-    * @param request
-    * @param response
-    * @return
-    */
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
     @PreAuthorize("@jps.requiresPermissions('adweb:adweb_site:importExcel')")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         return super.importExcel(request, response, AdwebSite.class);
     }
 
+    /**
+     * 根据uid获取所属一级站点信息
+     * "id", "name", "code", "domain","domain_dev","status"
+     */
+    @GetMapping("/getSiteListByUid")
+    public HttpApiResult getAllSites() {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
+        if (sysAdwebApi.isAdmin()) {
+
+        } else if (sysAdwebApi.isOem()) {
+            List<String> oemGroupUids = sysAdwebApi.getOemGroupUids();
+            List<String> codeList = siteUserPermissionService.getSiteCodeListByUids(oemGroupUids);
+            queryWrapper.in("code", codeList);
+        } else {
+            List<String> codeList = siteUserPermissionService.getSiteCodeList(sysUser.getId());
+            queryWrapper.in("code", codeList);
+        }
+        queryWrapper.eq("site_type", AdwebConstant.SITE);
+        queryWrapper.ne("status", AdwebConstant.SITE_DEL).isNull("parent_group_code");
+        queryWrapper.select("id", "name", "code", "domain", "domain_dev", "status");
+        List<AdwebSite> siteList = adwebSiteService.list(queryWrapper);
+
+        // 处理域名,全部改为绝对路径
+        if (ListUtil.notEmpty(siteList)) {
+            for (AdwebSite site : siteList) {
+                String domain = site.getDomain();
+                if (StringUtil.isNullOrEmpty(domain)) {
+                    continue;
+                }
+                if (!domain.startsWith("http")) {
+                    site.setDomain("https://" + domain);
+                }
+            }
+        }
+        HttpApiResult httpApiResult = new HttpApiResult();
+        httpApiResult.setData(siteList);
+        httpApiResult.setCount(siteList.size());
+        return httpApiResult;
+    }
+
 }

+ 49 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/entity/AdwebSitePermission.java

@@ -0,0 +1,49 @@
+package org.jeecg.modules.adweb.site.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 站点权限表
+ * @Author: liang
+ * @Date:   2022-08-09
+ * @Version: V1.0
+ */
+@Data
+@TableName("adweb_site_permission")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="站点权限表")
+public class AdwebSitePermission implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**主键id*/
+	@TableId(type = IdType.AUTO)
+    @Schema(description  = "主键id")
+    private Integer id;
+	/**站点code*/
+    @Schema(description  = "站点code")
+    private String siteCode;
+	/**站点名*/
+    @Schema(description  = "站点名")
+    private String siteName;
+	/**站点权限code*/
+	@Schema(description  = "站点权限code")
+	private String permissionCode;
+	/**状态*/
+	@Schema(description  = "状态")
+	private Integer status;
+	/**创建日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+	@Schema(description  = "创建日期")
+	private Date createTime;
+}

+ 48 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/entity/AdwebSiteUserPermission.java

@@ -0,0 +1,48 @@
+package org.jeecg.modules.adweb.site.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 用户站点权限表
+ * @Author: liang
+ * @Date:   2022-08-09
+ * @Version: V1.0
+ */
+@Data
+@TableName("adweb_site_user_permission")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="用户站点权限表")
+public class AdwebSiteUserPermission implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**主键id*/
+	@TableId(type = IdType.AUTO)
+	@Schema(description  = "主键id")
+    private Integer id;
+	/**用户id*/
+	@Dict(dictTable = "sys_user", dicText = "username", dicCode = "id")
+    @Schema(description = "用户id")
+    private String uid;
+	/**站点权限code*/
+	@Schema(description = "站点权限code")
+	private String permissionCode;
+	/**状态*/
+	@Schema(description = "状态")
+	private Integer status;
+	/**创建日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+	@Schema(description = "创建日期")
+	private Date createTime;
+}

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/entity/SiteUserPermissionMapper.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.adweb.site.entity;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: 站点和用户的中间表
+ * @Author: jeecg-boot
+ * @Date:   2021-04-06
+ * @Version: V1.0
+ */
+public interface SiteUserPermissionMapper extends BaseMapper<AdwebSitePermission> {
+
+}

+ 14 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/mapper/SitePermissionMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.adweb.site.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
+
+/**
+ * @Description: 站点和用户的中间表
+ * @Author: jeecg-boot
+ * @Date:   2021-04-06
+ * @Version: V1.0
+ */
+public interface SitePermissionMapper extends BaseMapper<AdwebSitePermission> {
+
+}

+ 14 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/ISitePermissionService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.adweb.site.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
+
+/**
+ * @Description: 站点权限表
+ * @Author: liang
+ * @Date:   2022-08-09
+ * @Version: V1.0
+ */
+public interface ISitePermissionService extends IService<AdwebSitePermission> {
+
+}

+ 20 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/ISiteUserPermissionService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.adweb.site.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
+
+import java.util.List;
+
+/**
+ * @Description: 站点权限表
+ * @Author: liang
+ * @Date:   2022-08-09
+ * @Version: V1.0
+ */
+public interface ISiteUserPermissionService extends IService<AdwebSiteUserPermission> {
+
+    public List<String> getSiteCodeList(String uid);
+
+    public List<String> getSiteCodeListByUids(List<String> list);
+
+}

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebSiteServiceImpl.java

@@ -7,8 +7,8 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.FastJsonUtil;
 import org.jeecg.common.util.RedisUtil;
-import org.jeecg.modules.adweb.constant.NumConstant;
-import org.jeecg.modules.adweb.constant.WordPressConstants;
+import org.jeecg.modules.adweb.common.constant.NumConstant;
+import org.jeecg.modules.adweb.common.constant.WordPressConstants;
 import org.jeecg.modules.adweb.site.dto.WordPressConfig;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.entity.AdwebUserWpsite;
@@ -55,7 +55,7 @@ public class AdwebSiteServiceImpl extends ServiceImpl<AdwebSiteMapper, AdwebSite
     public WordPressConfig queryWordPressConfig(String siteCode) {
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         WordPressConfig config = new WordPressConfig();
-        if (StringUtils.isNotBlank(siteCode)) {
+        if (StringUtils.isBlank(siteCode)) {
             return config;
         }
         try {

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

@@ -9,7 +9,7 @@ import org.jeecg.modules.adweb.site.entity.AdwebUserWpsite;
 import org.jeecg.modules.adweb.site.mapper.AdwebUserWpsiteMapper;
 import org.jeecg.modules.adweb.site.service.IAdwebUserWpsiteService;
 import org.springframework.stereotype.Service;
-import org.jeecg.modules.adweb.constant.NumConstant;
+import org.jeecg.modules.adweb.common.constant.NumConstant;
 
 import java.util.List;
 

+ 18 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SitePermissionServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.adweb.site.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
+import org.jeecg.modules.adweb.site.mapper.SitePermissionMapper;
+import org.jeecg.modules.adweb.site.service.ISitePermissionService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 站点权限
+ * @Author: lengjinilang
+ * @Date:   2022-08-09
+ * @Version: V1.0
+ */
+@Service
+public class SitePermissionServiceImpl extends ServiceImpl<SitePermissionMapper, AdwebSitePermission> implements ISitePermissionService {
+
+}

+ 192 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SiteUserPermissionServiceImpl.java

@@ -0,0 +1,192 @@
+package org.jeecg.modules.adweb.site.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.adweb.common.util.ListUtil;
+import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
+import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
+import org.jeecg.modules.adweb.site.entity.SiteUserPermissionMapper;
+import org.jeecg.modules.adweb.site.service.ISitePermissionService;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 站点权限表
+ * @Author: liang
+ * @Date: 2022-08-09
+ * @Version: V1.0
+ */
+@Service
+@Slf4j
+public class SiteUserPermissionServiceImpl implements ISiteUserPermissionService {
+
+    @Autowired
+    private ISitePermissionService sitePermissionService;
+
+    @Override
+    public List<String> getSiteCodeList(String uid) {
+        List<String> codeList = new ArrayList<>();
+        List<AdwebSiteUserPermission> AdwebSiteUserPermissionList = null;
+        try {
+            AdwebSiteUserPermissionList = this.list(new LambdaQueryWrapper<AdwebSiteUserPermission>()
+                    .eq(AdwebSiteUserPermission::getUid, uid)
+                    .eq(AdwebSiteUserPermission::getStatus, 1));
+        } catch (Exception e) {
+            log.error("通过uid获取站点权限失败", e);
+        }
+        if (ListUtil.isEmpty(AdwebSiteUserPermissionList)) {
+            codeList.add("-1");
+            return codeList;
+        }
+        List<String> permissionsList = AdwebSiteUserPermissionList.stream().map(AdwebSiteUserPermission::getPermissionCode).collect(Collectors.toList());
+
+        try {
+            codeList = sitePermissionService.list(new LambdaQueryWrapper<AdwebSitePermission>()
+                            .in(AdwebSitePermission::getPermissionCode, permissionsList)
+                            .eq(AdwebSitePermission::getStatus, 1))
+                    .stream().map(AdwebSitePermission::getSiteCode).collect(Collectors.toList());
+        } catch (Exception e) {
+            log.error("通过站点权限获取站点code失败", e);
+        }
+        if (ListUtil.isEmpty(codeList)) {
+            codeList.add("-1");
+            return codeList;
+        }
+        return codeList;
+    }
+
+    @Override
+    public List<String> getSiteCodeListByUids(List<String> list) {
+        List<String> codeList = new ArrayList<>();
+        List<AdwebSiteUserPermission> AdwebSiteUserPermissionList = null;
+        try {
+            AdwebSiteUserPermissionList = this.list(new LambdaQueryWrapper<AdwebSiteUserPermission>()
+                    .in(AdwebSiteUserPermission::getUid, list)
+                    .eq(AdwebSiteUserPermission::getStatus, 1));
+        } catch (Exception e) {
+            log.error("通过uid获取站点权限失败", e);
+        }
+        if (ListUtil.isEmpty(AdwebSiteUserPermissionList)) {
+            codeList.add("-1");
+            return codeList;
+        }
+        List<String> permissionsList = AdwebSiteUserPermissionList.stream().map(AdwebSiteUserPermission::getPermissionCode).collect(Collectors.toList());
+        try {
+            codeList = sitePermissionService.list(new LambdaQueryWrapper<AdwebSitePermission>()
+                            .in(AdwebSitePermission::getPermissionCode, permissionsList)
+                            .eq(AdwebSitePermission::getStatus, 1))
+                    .stream().map(AdwebSitePermission::getSiteCode).collect(Collectors.toList());
+        } catch (Exception e) {
+            log.error("通过站点权限获取站点code失败", e);
+        }
+        if (ListUtil.isEmpty(codeList)) {
+            codeList.add("-1");
+            return codeList;
+        }
+        return codeList;
+    }
+
+    /**
+     * @param entityList
+     * @param batchSize
+     * @return
+     */
+    @Override
+    public boolean saveBatch(Collection<AdwebSiteUserPermission> entityList, int batchSize) {
+        return false;
+    }
+
+    /**
+     * @param entityList
+     * @param batchSize
+     * @return
+     */
+    @Override
+    public boolean saveOrUpdateBatch(Collection<AdwebSiteUserPermission> entityList, int batchSize) {
+        return false;
+    }
+
+    /**
+     * @param entityList
+     * @param batchSize
+     * @return
+     */
+    @Override
+    public boolean updateBatchById(Collection<AdwebSiteUserPermission> entityList, int batchSize) {
+        return false;
+    }
+
+    /**
+     * @param entity
+     * @return
+     */
+    @Override
+    public boolean saveOrUpdate(AdwebSiteUserPermission entity) {
+        return false;
+    }
+
+    /**
+     * @param queryWrapper
+     * @param throwEx
+     * @return
+     */
+    @Override
+    public AdwebSiteUserPermission getOne(Wrapper<AdwebSiteUserPermission> queryWrapper, boolean throwEx) {
+        return null;
+    }
+
+    /**
+     * @param queryWrapper
+     * @param throwEx
+     * @return
+     */
+    @Override
+    public Optional<AdwebSiteUserPermission> getOneOpt(Wrapper<AdwebSiteUserPermission> queryWrapper, boolean throwEx) {
+        return Optional.empty();
+    }
+
+    /**
+     * @param queryWrapper
+     * @return
+     */
+    @Override
+    public Map<String, Object> getMap(Wrapper<AdwebSiteUserPermission> queryWrapper) {
+        return Map.of();
+    }
+
+    /**
+     * @param queryWrapper
+     * @param mapper
+     * @param <V>
+     * @return
+     */
+    @Override
+    public <V> V getObj(Wrapper<AdwebSiteUserPermission> queryWrapper, Function<? super Object, V> mapper) {
+        return null;
+    }
+
+    /**
+     * @return
+     */
+    @Override
+    public BaseMapper<AdwebSiteUserPermission> getBaseMapper() {
+        return null;
+    }
+
+    /**
+     * @return
+     */
+    @Override
+    public Class<AdwebSiteUserPermission> getEntityClass() {
+        return null;
+    }
+}

+ 12 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/system/service/SysAdwebApi.java

@@ -0,0 +1,12 @@
+package org.jeecg.modules.adweb.system.service;
+
+import java.util.List;
+
+public interface SysAdwebApi {
+
+    boolean isAdmin();
+
+    boolean isOem();
+
+    List<String> getOemGroupUids();
+}

+ 81 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/system/service/impl/SysAdwebApiImpl.java

@@ -0,0 +1,81 @@
+package org.jeecg.modules.adweb.system.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.adweb.common.util.ListUtil;
+import org.jeecg.modules.adweb.system.service.SysAdwebApi;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.mapper.SysUserMapper;
+import org.jeecg.modules.system.mapper.SysUserRoleMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class SysAdwebApiImpl implements SysAdwebApi {
+    @Resource
+    private SysUserRoleMapper sysUserRoleMapper;
+
+    @Resource
+    private SysUserMapper userMapper;
+
+    @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 = sysUserRoleMapper.getRoleByUserName(username);
+        for (String role : roles) {
+            if (adminRoleIdList.contains(role)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public boolean isOem() {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String username = sysUser.getUsername();
+        List<String> adminRoleIdList = new ArrayList<>();    // 管理员角色id列表
+        adminRoleIdList.add("adweb_oem");
+        List<String> roles = sysUserRoleMapper.getRoleByUserName(username);
+        for (String role : roles) {
+            if ("adweb_oem".equals(role)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public List<String> getOemGroupUids() {
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        SysUser sysUser = userMapper.getUserByName(loginUser.getUsername());
+        String workNo = sysUser.getWorkNo();
+        List<String> list = null;
+        try {
+            list = userMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getOemCode, workNo)).stream().map(SysUser::getId).collect(Collectors.toList());
+        } catch (Exception e) {
+            log.error("获取当前登录渠道下客户群的uid");
+        }
+        if (ListUtil.isEmpty(list)) {
+            list = new ArrayList<>();
+            list.add("-1");
+        }
+        list.add(sysUser.getId());
+        return list;
+    }
+}

+ 8 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/entity/SysUser.java

@@ -189,6 +189,14 @@ public class SysUser implements Serializable {
     /**设备id uniapp推送用*/
     private String clientId;
 
+    /**用户渠道来源code*/
+    private String oemCode;
+
+    /**
+     * 是否有主账户
+     */
+    private Integer hasMasterAccount;
+
     /**
      * 登录首页地址
      */