From f7538c1ed81edf5b9e6c5a9b83f0c87ea21fe451 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Wed, 6 Mar 2024 16:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=903.6.3=E7=89=88=E6=9C=AC=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E3=80=91=E9=A6=96=E9=A1=B5=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/constant/CommonConstant.java | 2 + .../constant/enums/RoleIndexConfigEnum.java | 8 ++- .../system/constant/DefIndexConst.java | 25 +++++++++ .../controller/SysRoleIndexController.java | 55 ++++++++++++++----- .../system/service/ISysRoleIndexService.java | 33 ++++++++++- 5 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/constant/DefIndexConst.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java index aee67a3f..8e3299a9 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java @@ -377,6 +377,8 @@ public interface CommonConstant { /**前端vue3版本Header参数名*/ String VERSION="X-Version"; + String VERSION_V3 = "v3"; + /**存储在线程变量里的动态表名*/ String DYNAMIC_TABLE_NAME="DYNAMIC_TABLE_NAME"; /** diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/enums/RoleIndexConfigEnum.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/enums/RoleIndexConfigEnum.java index 09d9c103..eaf2c39e 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/enums/RoleIndexConfigEnum.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/enums/RoleIndexConfigEnum.java @@ -13,12 +13,16 @@ import java.util.List; public enum RoleIndexConfigEnum { /**首页自定义 admin*/ - ADMIN("admin", "dashboard/Analysis"), +// ADMIN("admin", "dashboard/Analysis"), //TEST("test", "dashboard/IndexChart"), /**首页自定义 hr*/ - HR("hr", "dashboard/IndexBdc"); +// HR("hr", "dashboard/IndexBdc"); + //DM("dm", "dashboard/IndexTask"), + // 注:此值仅为防止报错,无任何实际意义 + ROLE_INDEX_CONFIG_ENUM("RoleIndexConfigEnumDefault", "dashboard/Analysis"); + /** * 角色编码 */ diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/constant/DefIndexConst.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/constant/DefIndexConst.java new file mode 100644 index 00000000..9e4f6f34 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/constant/DefIndexConst.java @@ -0,0 +1,25 @@ +package org.jeecg.modules.system.constant; + +/** + * 默认首页常量 + */ +public interface DefIndexConst { + + /** + * 默认首页的roleCode + */ + String DEF_INDEX_ALL = "DEF_INDEX_ALL"; + + /** + * 默认首页的缓存key + */ + String CACHE_KEY = "sys:cache:def_index"; + + /** + * 默认首页的初始值 + */ + String DEF_INDEX_NAME = "首页"; + String DEF_INDEX_URL = "/dashboard/analysis"; + String DEF_INDEX_COMPONENT = "dashboard/Analysis"; + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleIndexController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleIndexController.java index a8616e3d..19274630 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleIndexController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleIndexController.java @@ -1,29 +1,26 @@ package org.jeecg.modules.system.controller; -import java.util.Arrays; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.apache.shiro.authz.annotation.RequiresRoles; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.common.aspect.annotation.AutoLog; -import org.jeecg.modules.system.entity.SysRoleIndex; -import org.jeecg.modules.system.service.ISysRoleIndexService; - 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.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; +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.modules.system.entity.SysRoleIndex; +import org.jeecg.modules.system.service.ISysRoleIndexService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; /** * @Description: 角色首页配置 @@ -172,4 +169,32 @@ public class SysRoleIndexController extends JeecgController().eq(SysRoleIndex::getRoleCode, roleCode)); return Result.OK(sysRoleIndex); } + + /** + * 查询默认首页配置 + */ + @GetMapping("/queryDefIndex") + public Result queryDefIndex() { + SysRoleIndex defIndexCfg = sysRoleIndexService.queryDefaultIndex(); + return Result.OK(defIndexCfg); + } + + /** + * 更新默认首页配置 + */ + @RequiresPermissions("system:permission:setDefIndex") + @PutMapping("/updateDefIndex") + public Result updateDefIndex( + @RequestParam("url") String url, + @RequestParam("component") String component, + @RequestParam("isRoute") Boolean isRoute + ) { + boolean success = sysRoleIndexService.updateDefaultIndex(url, component, isRoute); + if (success) { + return Result.OK("设置成功"); + } else { + return Result.error("设置失败"); + } + } + } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleIndexService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleIndexService.java index 328f67c9..54d3b670 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleIndexService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleIndexService.java @@ -1,14 +1,43 @@ package org.jeecg.modules.system.service; -import org.jeecg.modules.system.entity.SysRoleIndex; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.system.entity.SysRoleIndex; /** * @Description: 角色首页配置 * @Author: jeecg-boot - * @Date: 2022-03-25 + * @Date: 2022-03-25 * @Version: V1.0 */ public interface ISysRoleIndexService extends IService { + /** + * 查询默认首页 + * + * @return + */ + SysRoleIndex queryDefaultIndex(); + + /** + * 更新默认首页 + * + * @param url + * @param component + * @param isRoute 是否是路由页面 + * @return + */ + boolean updateDefaultIndex(String url, String component, boolean isRoute); + + /** + * 创建最原始的默认首页配置 + * + * @return + */ + SysRoleIndex initDefaultIndex(); + + /** + * 清理默认首页的redis缓存 + */ + void cleanDefaultIndexCache(); + }