feat(登录配置): 添加服务器域名配置并重构URL管理
将硬编码的服务器域名替换为可配置项,新增SERVER_HOST配置枚举 创建UrlConstants类集中管理所有URL路径 修改相关服务类使用配置的域名和URL常量 调整SecurityConfig中/getConfig的访问权限
This commit is contained in:
parent
0b07c719a3
commit
31adc0adc2
|
|
@ -134,10 +134,10 @@ public class SecurityConfig {
|
|||
.authorizeRequests()
|
||||
// 对于登录login 注册register 验证码captchaImage 以及公共Api的请求允许匿名访问
|
||||
// 注意: 当携带token请求以下这几个接口时 会返回403的错误
|
||||
.antMatchers("/login", "/register", "/getConfig", "/captchaImage", "/api/**", "/file/**").anonymous()
|
||||
.antMatchers("/login", "/register", "/captchaImage", "/api/**", "/file/**").anonymous()
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js",
|
||||
"/profile/**").permitAll()
|
||||
.antMatchers("/qywx/**", "/test/**", "/monitor/**", "/getQyUserinfo").permitAll()
|
||||
.antMatchers("/qywx/**", "/test/**", "/monitor/**", "/getQyUserinfo", "/getConfig").permitAll()
|
||||
// TODO this is danger.
|
||||
.antMatchers("/swagger-ui.html").anonymous()
|
||||
.antMatchers("/swagger-resources/**").anonymous()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.agileboot.admin.customize.service.job;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.agileboot.common.enums.common.ConfigKeyEnum;
|
||||
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
|
||||
import com.agileboot.domain.cabinet.cell.db.CabinetCellService;
|
||||
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetEntity;
|
||||
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetService;
|
||||
import com.agileboot.domain.common.cache.CacheCenter;
|
||||
import com.agileboot.domain.qywx.accessToken.AccessTokenApplicationService;
|
||||
import com.agileboot.domain.qywx.accessToken.db.QyAccessTokenEntity;
|
||||
import com.agileboot.domain.qywx.api.QywxApiUtil;
|
||||
|
|
@ -199,7 +201,9 @@ public class DeadlineOrderJob {
|
|||
article.setDescription(String.format("用户姓名: %s, 订单号: %s, 商品名称: %s, 创建时间: %s, 归还期限: %s天, 截止日期: %s", order.getName(),
|
||||
order.getOrderId(), orderGoods.getGoodsName(), DateUtil.formatDateTime(order.getCreateTime()), returnDeadlineDays, DateUtil.formatDateTime(deadlineDate)));
|
||||
article.setPicurl(orderGoods.getCoverImg());
|
||||
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth");
|
||||
|
||||
String serverHost = CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
article.setUrl(serverHost + "/shop-api/api/shop/qy/wechatAuth");
|
||||
articles.add(article);
|
||||
|
||||
QywxApiUtil.sendNewsMessage(accessToken.getAccessToken(), Integer.valueOf(authCorpInfo.getAgentid()),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ import com.agileboot.domain.shop.order.db.ShopOrderGoodsEntity;
|
|||
import com.agileboot.domain.shop.order.db.ShopOrderService;
|
||||
import com.agileboot.domain.system.role.db.SysRoleService;
|
||||
import com.agileboot.domain.system.user.model.UserModelFactory;
|
||||
import com.agileboot.common.enums.common.ConfigKeyEnum;
|
||||
import com.agileboot.domain.common.cache.CacheCenter;
|
||||
import com.agileboot.common.constant.UrlConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -189,7 +192,8 @@ public class QywxMessageJob {
|
|||
article.setTitle("逾期未归还通知");
|
||||
article.setDescription("你借用的 【" + record.getGoodsName() + "】 已逾期未归还,请及时归还");
|
||||
article.setPicurl(record.getCoverImg());
|
||||
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth/home");
|
||||
String serverHost = CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
article.setUrl(serverHost + UrlConstants.WECHAT_AUTH_HOME_URL);
|
||||
articles.add(article);
|
||||
|
||||
QywxApiUtil.sendNewsMessage(accessToken, Integer.valueOf(authCorpInfo.getAgentid()),
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ public class LoginService {
|
|||
boolean isCaptchaOn = isCaptchaOn();
|
||||
configDTO.setIsCaptchaOn(isCaptchaOn);
|
||||
configDTO.setDictionary(MapCache.dictionaryCache());
|
||||
configDTO.setServerHost(guavaCache.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue()));
|
||||
return configDTO;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,4 +16,6 @@ public class ConfigDTO {
|
|||
private Map<String, List<DictionaryData>> dictionary;
|
||||
|
||||
private String res;
|
||||
|
||||
private String serverHost;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import cn.hutool.http.useragent.UserAgentUtil;
|
|||
import cn.hutool.json.JSONUtil;
|
||||
import com.agileboot.api.response.ShopGoodsResponse;
|
||||
import com.agileboot.common.constant.WeixinConstants;
|
||||
import com.agileboot.common.constant.UrlConstants;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.enums.common.ConfigKeyEnum;
|
||||
import com.agileboot.domain.common.cache.CacheCenter;
|
||||
import com.agileboot.domain.shop.category.CategoryApplicationService;
|
||||
import com.agileboot.domain.shop.category.db.ShopCategoryEntity;
|
||||
import com.agileboot.domain.shop.category.dto.ShopCategoryDTO;
|
||||
|
|
@ -41,6 +44,7 @@ public class ShopController {
|
|||
private final ShopApplicationService shopApplicationService;
|
||||
private final GoodsApplicationService goodsApplicationService;
|
||||
private final CategoryApplicationService categoryApplicationService;
|
||||
private final CacheCenter cacheCenter;
|
||||
|
||||
@GetMapping("/list")
|
||||
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid,
|
||||
|
|
@ -127,9 +131,10 @@ public class ShopController {
|
|||
state = "state";
|
||||
}
|
||||
|
||||
String redirect_uri = "http%3A%2F%2Fwxshop.ab98.cn%2Fshop";
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
String redirect_uri = URLUtil.encodeQuery(serverHost + UrlConstants.HOME_REDIRECT_URL);
|
||||
if (StringUtils.isNotBlank(shopId)) {
|
||||
redirect_uri += "%3FshopId%3D" + shopId;
|
||||
redirect_uri += URLUtil.encodeQuery("?shopId=" + shopId);
|
||||
}
|
||||
// 构造微信网页授权URL
|
||||
String authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize"
|
||||
|
|
@ -155,9 +160,10 @@ public class ShopController {
|
|||
});
|
||||
log.info("/qy/wechatAuth 参数:{}", joiner.toString());*/
|
||||
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
String authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize"
|
||||
+ "?appid=" + WeixinConstants.corpid
|
||||
+ "&redirect_uri=http%3A%2F%2Fwxshop.ab98.cn%2Fshop-api%2Fapi%2Fshop%2FapprovalRedirect"
|
||||
+ "&redirect_uri=" + URLUtil.encodeQuery(serverHost + UrlConstants.APPROVAL_REDIRECT_HANDLER_URL)
|
||||
+ "&response_type=code"
|
||||
+ "&scope=snsapi_base"
|
||||
+ "&state=STATE"
|
||||
|
|
@ -173,8 +179,9 @@ public class ShopController {
|
|||
*/
|
||||
@GetMapping("/approvalRedirect")
|
||||
public RedirectView approvalRedirect(HttpServletRequest request) {
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl("http://wxshop.ab98.cn/shop#/approval/list")
|
||||
.fromHttpUrl(serverHost + UrlConstants.APPROVAL_REDIRECT_URL)
|
||||
.queryParam("corpid", WeixinConstants.corpid)
|
||||
.queryParam("device", "APP");
|
||||
|
||||
|
|
@ -194,9 +201,10 @@ public class ShopController {
|
|||
*/
|
||||
@GetMapping("/qy/wechatAuth/asset")
|
||||
public RedirectView qyWechatAuthAssetRedirect(HttpServletRequest request) {
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
String authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize"
|
||||
+ "?appid=" + WeixinConstants.corpid
|
||||
+ "&redirect_uri=http%3A%2F%2Fwxshop.ab98.cn%2Fshop-api%2Fapi%2Fshop%2FapprovalAssetRedirect"
|
||||
+ "&redirect_uri=" + URLUtil.encodeQuery(serverHost + UrlConstants.APPROVAL_ASSET_REDIRECT_HANDLER_URL)
|
||||
+ "&response_type=code"
|
||||
+ "&scope=snsapi_base"
|
||||
+ "&state=STATE"
|
||||
|
|
@ -212,8 +220,9 @@ public class ShopController {
|
|||
*/
|
||||
@GetMapping("/approvalAssetRedirect")
|
||||
public RedirectView approvalAssetRedirect(HttpServletRequest request) {
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl("http://wxshop.ab98.cn/shop#/approvalAsset/list")
|
||||
.fromHttpUrl(serverHost + UrlConstants.APPROVAL_ASSET_REDIRECT_URL)
|
||||
.queryParam("corpid", WeixinConstants.corpid)
|
||||
.queryParam("device", "APP");
|
||||
|
||||
|
|
@ -237,9 +246,11 @@ public class ShopController {
|
|||
boolean isMobile = UserAgentUtil.parse(userAgent).isMobile();
|
||||
String redirectPath = isMobile ? "homeRedirect" : "adminRedirect";
|
||||
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
String redirectHandlerUrl = isMobile ? UrlConstants.HOME_REDIRECT_HANDLER_URL : UrlConstants.ADMIN_REDIRECT_HANDLER_URL;
|
||||
String authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize"
|
||||
+ "?appid=" + WeixinConstants.corpid
|
||||
+ "&redirect_uri=http%3A%2F%2Fwxshop.ab98.cn%2Fshop-api%2Fapi%2Fshop%2F" + redirectPath
|
||||
+ "&redirect_uri=" + URLUtil.encodeQuery(serverHost + redirectHandlerUrl)
|
||||
+ "&response_type=code"
|
||||
+ "&scope=snsapi_base"
|
||||
+ "&state=STATE"
|
||||
|
|
@ -256,8 +267,9 @@ public class ShopController {
|
|||
*/
|
||||
@GetMapping("/homeRedirect")
|
||||
public RedirectView homeRedirect(HttpServletRequest request) {
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl("http://wxshop.ab98.cn/shop")
|
||||
.fromHttpUrl(serverHost + UrlConstants.HOME_REDIRECT_URL)
|
||||
.queryParam("corpid", WeixinConstants.corpid)
|
||||
.queryParam("device", "APP");
|
||||
|
||||
|
|
@ -278,8 +290,9 @@ public class ShopController {
|
|||
*/
|
||||
@GetMapping("/adminRedirect")
|
||||
public RedirectView adminRedirect(HttpServletRequest request) {
|
||||
String serverHost = cacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl("http://wxshop.ab98.cn/shop-admin")
|
||||
.fromHttpUrl(serverHost + UrlConstants.ADMIN_REDIRECT_URL)
|
||||
.queryParam("corpid", WeixinConstants.corpid)
|
||||
.queryParam("device", "PC");
|
||||
|
||||
|
|
@ -296,7 +309,10 @@ public class ShopController {
|
|||
String res = URLEncoder.encode("token=12312", StandardCharsets.UTF_8.name());
|
||||
System.out.println(res);
|
||||
|
||||
String url = URLUtil.encode("http://wxshop.ab98.cn/shop-api/api/shop/");
|
||||
// 注意:main方法中无法直接获取缓存,这里仅作为示例
|
||||
// 实际使用时应该从CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue())获取
|
||||
String serverHost = "http://example.com";
|
||||
String url = URLUtil.encodeQuery(serverHost + "/shop-api/api/shop/");
|
||||
System.out.println(url);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,5 @@ public class PayApiConstants {
|
|||
public static final String old_biz_id = "wxshop_old";
|
||||
public static final String appkey = "wxshop202503081132";
|
||||
public static final String pay_url = "http://222.218.10.217:7890/open/trade/wx/jsapi/precreate";
|
||||
public static final String pay_callback_url = "http://wxshop.ab98.cn/shop-api/api/payment/callback";
|
||||
public static final String refund_url = "http://222.218.10.217:7890/open/trade/refund";
|
||||
public static final String refund_callback_url = "http://wxshop.ab98.cn/shop-api/api/payment/refund/callback";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
package com.agileboot.common.constant;
|
||||
|
||||
/**
|
||||
* URL常量类
|
||||
*/
|
||||
public class UrlConstants {
|
||||
/**
|
||||
* 服务器主机地址(从缓存中获取)
|
||||
*/
|
||||
public static final String SERVER_HOST = "sys.server.host";
|
||||
|
||||
/**
|
||||
* 微信授权相关URL
|
||||
*/
|
||||
public static final String WECHAT_AUTH_URL = "/shop-api/api/shop/qy/wechatAuth";
|
||||
|
||||
/**
|
||||
* 微信授权资产相关URL
|
||||
*/
|
||||
public static final String WECHAT_AUTH_ASSET_URL = "/shop-api/api/shop/qy/wechatAuth/asset";
|
||||
|
||||
/**
|
||||
* 微信授权主页相关URL
|
||||
*/
|
||||
public static final String WECHAT_AUTH_HOME_URL = "/shop-api/api/shop/qy/wechatAuth/home";
|
||||
|
||||
/**
|
||||
* 审批重定向URL
|
||||
*/
|
||||
public static final String APPROVAL_REDIRECT_URL = "/shop#/approval/list";
|
||||
|
||||
/**
|
||||
* 审批重定向处理URL
|
||||
*/
|
||||
public static final String APPROVAL_REDIRECT_HANDLER_URL = "/shop-api/api/shop/approvalRedirect";
|
||||
|
||||
/**
|
||||
* 资产审批重定向处理URL
|
||||
*/
|
||||
public static final String APPROVAL_ASSET_REDIRECT_HANDLER_URL = "/shop-api/api/shop/approvalAssetRedirect";
|
||||
|
||||
/**
|
||||
* 主页重定向处理URL(移动端)
|
||||
*/
|
||||
public static final String HOME_REDIRECT_HANDLER_URL = "/shop-api/api/shop/homeRedirect";
|
||||
|
||||
/**
|
||||
* 管理后台重定向处理URL(PC端)
|
||||
*/
|
||||
public static final String ADMIN_REDIRECT_HANDLER_URL = "/shop-api/api/shop/adminRedirect";
|
||||
|
||||
/**
|
||||
* 资产审批重定向URL
|
||||
*/
|
||||
public static final String APPROVAL_ASSET_REDIRECT_URL = "/shop#/approvalAsset/list";
|
||||
|
||||
/**
|
||||
* 主页重定向URL
|
||||
*/
|
||||
public static final String HOME_REDIRECT_URL = "/shop";
|
||||
|
||||
/**
|
||||
* 管理后台重定向URL
|
||||
*/
|
||||
public static final String ADMIN_REDIRECT_URL = "/shop-admin";
|
||||
|
||||
/**
|
||||
* 支付回调URL
|
||||
*/
|
||||
public static final String PAY_CALLBACK_URL = "/shop-api/api/payment/callback";
|
||||
|
||||
/**
|
||||
* 退款回调URL
|
||||
*/
|
||||
public static final String REFUND_CALLBACK_URL = "/shop-api/api/payment/refund/callback";
|
||||
}
|
||||
|
|
@ -16,7 +16,8 @@ public enum ConfigKeyEnum implements BasicEnum<String> {
|
|||
INIT_PASSWORD("sys.user.initPassword", "初始密码"),
|
||||
SIDE_BAR_THEME("sys.index.sideTheme", "侧边栏开关"),
|
||||
CAPTCHA("sys.account.captchaOnOff", "验证码开关"),
|
||||
REGISTER("sys.account.registerUser", "注册开放功能");
|
||||
REGISTER("sys.account.registerUser", "注册开放功能"),
|
||||
SERVER_HOST("sys.server.host", "服务器域名");
|
||||
|
||||
private final String value;
|
||||
private final String description;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package com.agileboot.domain.asset;
|
|||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.agileboot.common.constant.UrlConstants;
|
||||
import com.agileboot.common.constant.WeixinConstants;
|
||||
import com.agileboot.common.enums.common.ConfigKeyEnum;
|
||||
import com.agileboot.domain.common.cache.CacheCenter;
|
||||
import com.agileboot.domain.asset.api.request.ConsumeOutputRequest;
|
||||
import com.agileboot.domain.asset.api.response.ConsumeOutputResponse;
|
||||
import com.agileboot.domain.asset.command.PostAssetApprovalCommand;
|
||||
|
|
@ -195,7 +198,8 @@ public class AssetApplicationService {
|
|||
article.setDescription(postAssetApprovalCommand.getName() + " 申请领用" + firstGoods.getGoodsName());
|
||||
}
|
||||
article.setPicurl(firstGoods.getCoverImg());
|
||||
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth/asset");
|
||||
String serverHost = CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
article.setUrl(serverHost + UrlConstants.WECHAT_AUTH_ASSET_URL);
|
||||
articles.add(article);
|
||||
|
||||
QywxApiUtil.sendNewsMessage(accessToken.getAccessToken(), Integer.valueOf(authCorpInfo.getAgentid()),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ package com.agileboot.domain.shop.approval;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.agileboot.common.constant.PayApiConstants;
|
||||
import com.agileboot.common.constant.UrlConstants;
|
||||
import com.agileboot.common.constant.WeixinConstants;
|
||||
import com.agileboot.common.enums.common.ConfigKeyEnum;
|
||||
import com.agileboot.domain.common.cache.CacheCenter;
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
|
|
@ -808,7 +811,8 @@ public class ReturnApprovalApplicationService {
|
|||
article.setTitle("退货审核通知");
|
||||
article.setDescription("退还商品:" + orderGoods.getGoodsName());
|
||||
article.setPicurl(orderGoods.getCoverImg());
|
||||
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth");
|
||||
String serverHost = CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
article.setUrl(serverHost + UrlConstants.WECHAT_AUTH_URL);
|
||||
articles.add(article);
|
||||
|
||||
QywxApiUtil.sendNewsMessage(accessToken.getAccessToken(), Integer.valueOf(authCorpInfo.getAgentid()),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.agileboot.common.constant.PayApiConstants;
|
|||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.common.enums.common.ConfigKeyEnum;
|
||||
import com.agileboot.domain.common.cache.CacheCenter;
|
||||
import com.agileboot.common.constant.UrlConstants;
|
||||
import com.agileboot.domain.ab98.user.db.Ab98UserEntity;
|
||||
import com.agileboot.domain.ab98.user.db.Ab98UserService;
|
||||
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
|
||||
|
|
@ -280,7 +283,9 @@ public class OrderApplicationService {
|
|||
article.setDescription(submitOrderCommand.getName() + " 申请领用" + firstOrderGoods.getGoodsName());
|
||||
}
|
||||
article.setPicurl(firstOrderGoods.getCoverImg());
|
||||
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth");
|
||||
|
||||
String serverHost = CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
article.setUrl(serverHost + UrlConstants.WECHAT_AUTH_URL);
|
||||
articles.add(article);
|
||||
|
||||
QywxApiUtil.sendNewsMessage(accessToken.getAccessToken(), Integer.valueOf(authCorpInfo.getAgentid()),
|
||||
|
|
@ -302,7 +307,8 @@ public class OrderApplicationService {
|
|||
request.setPay_amount(amountInFen.toPlainString()); // 单位转换为分
|
||||
|
||||
request.setTitle("商品订单支付");
|
||||
request.setNotify_url(PayApiConstants.pay_callback_url);
|
||||
String serverHost = CacheCenter.configCache.get(ConfigKeyEnum.SERVER_HOST.getValue());
|
||||
request.setNotify_url(serverHost + UrlConstants.PAY_CALLBACK_URL);
|
||||
request.setBiz_id(PayApiConstants.biz_id);
|
||||
request.setUcid(orderModel.getUcid());
|
||||
request.setExtra("");
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public abstract class AbstractGuavaCacheTemplate<T> {
|
|||
// -- 没写访问下,超过5秒会失效(非自动失效,需有任意put get方法才会扫描过期失效数据)
|
||||
// .expireAfterWrite(5L, TimeUnit.MINUTES)
|
||||
// 没写访问下,超过5秒会失效(非自动失效,需有任意put get方法才会扫描过期失效数据。但区别是会开一个异步线程进行刷新,刷新过程中访问返回旧数据)
|
||||
.refreshAfterWrite(5L, TimeUnit.MINUTES)
|
||||
.refreshAfterWrite(10L, TimeUnit.MINUTES)
|
||||
// 移除监听事件
|
||||
.removalListener(removal -> {
|
||||
// 可做一些删除后动作,比如上报删除数据用于统计
|
||||
|
|
|
|||
Loading…
Reference in New Issue