合并 PostConstruct

This commit is contained in:
thinkgem
2025-10-16 20:18:54 +08:00
parent 53546e1527
commit 17d83bdc1c
2 changed files with 11 additions and 16 deletions

View File

@@ -27,7 +27,6 @@ import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.List;
@@ -49,16 +48,6 @@ public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser>
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");
}
}
/**
* 获取单条数据

View File

@@ -9,6 +9,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
import io.swagger.annotations.Api;
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;
@@ -21,6 +22,7 @@ import javax.annotation.PostConstruct;
* @version 20167-8-27
*/
@Controller
@Lazy(false)
@Api(tags = "Cache - 缓存管理")
@RequestMapping(value = "${adminPath}/sys/cache")
public class CacheController extends BaseController {
@@ -38,15 +40,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");
}
}
}