From 3d8237ce01eb7707b5ff3e790bbb37f7b557adcc Mon Sep 17 00:00:00 2001 From: thinkgem Date: Thu, 16 Oct 2025 20:20:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=20PostConstruct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/EmpUserServiceSupport.java | 10 ------ .../modules/sys/web/CacheController.java | 32 +++++++++++-------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java b/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java index 79da73bb..82a9225e 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java @@ -49,16 +49,6 @@ public class EmpUserServiceSupport extends CrudService this.employeeService = employeeService; this.employeeOfficeDao = employeeOfficeDao; } - - /** - * 租户功能验证 - */ - @PostConstruct - private void corpModelValid() throws Exception{ - if (!Global.isUseCorpModel().equals(Global.getPropertyToBoolean("user.useCorpModel", "false"))){ - throw new Exception("\n\nuser.useCorpModel=true? 你开启了多租户模式,似乎你的当前版本不是JeeSite专业版。\n"); - } - } /** * 获取单条数据 diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/web/CacheController.java b/modules/core/src/main/java/com/jeesite/modules/sys/web/CacheController.java index 8c95e55b..b81d7e3a 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/web/CacheController.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/web/CacheController.java @@ -1,20 +1,19 @@ package com.jeesite.modules.sys.web; -import jakarta.annotation.PostConstruct; - -import io.swagger.v3.oas.annotations.tags.Tag; -import org.apache.shiro.authz.annotation.Logical; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - import com.jeesite.common.cache.CacheUtils; import com.jeesite.common.config.Global; import com.jeesite.common.lang.StringUtils; import com.jeesite.common.mybatis.mapper.MapperHelper; import com.jeesite.common.web.BaseController; import com.jeesite.modules.sys.utils.UserUtils; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.PostConstruct; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; /** * 缓存管理 @@ -22,6 +21,7 @@ import com.jeesite.modules.sys.utils.UserUtils; * @version 20167-8-27 */ @Controller +@Lazy(false) @Tag(name = "Cache - 缓存管理") @RequestMapping(value = "${adminPath}/sys/cache") public class CacheController extends BaseController { @@ -39,15 +39,19 @@ public class CacheController extends BaseController { UserUtils.clearCache(); return renderResult(Global.TRUE, text("清理缓存成功")); } - + @PostConstruct - public void postConstruct(){ - String rebel = System.getProperty("rebel.base"); - if (StringUtils.isNotBlank(rebel) && Global - .getPropertyToBoolean("spring.cache.isClusterMode", "false")){ + public void postConstruct() throws Exception { + // 如果使用了 JRebel 插件,则清理缓存 + if (StringUtils.isNotBlank(System.getProperty("rebel.base")) && Global.getPropertyToBoolean("spring.cache.isClusterMode", "false")){ logger.info("JRebel: Cache clear..."); CacheUtils.clearCache(); } + // 则开启了租户参数,但无法使用,则给予提示 + if (!Global.isUseCorpModel().equals(Global.getPropertyToBoolean("user.useCorpModel", "false"))){ + throw new Exception("\n\nuser.useCorpModel=true? 你开启了多租户模式,似乎你的当前版本不是JeeSite专业版。\n"); + } } } +