make same changes
This commit is contained in:
parent
452a8b5cab
commit
f24b569de1
@ -4,10 +4,10 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: 180.97.221.51:8848
|
server-addr: 117.72.78.133:8848
|
||||||
config:
|
config:
|
||||||
server-addr: 180.97.221.51:8848
|
server-addr: 117.72.78.133:8848
|
||||||
namespace: 1877a228-6bff-46b9-a442-829473c3adc7
|
namespace: 622d03f1-aeac-430c-8361-e69a73a5c4db
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
refresh-enabled: true
|
refresh-enabled: true
|
||||||
group: DEFAULT_GROUP
|
group: DEFAULT_GROUP
|
||||||
|
|||||||
@ -4,10 +4,10 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: 180.97.221.51:8848
|
server-addr: 127.0.0.1:8848
|
||||||
config:
|
config:
|
||||||
server-addr: 180.97.221.51:8848
|
server-addr: 127.0.0.1:8848
|
||||||
namespace: fe5388cc-76bc-44d6-ba20-034f97c567e5
|
namespace: 636cb425-50d7-4489-a462-fd4a5be6b87d
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
refresh-enabled: true
|
refresh-enabled: true
|
||||||
group: DEFAULT_GROUP
|
group: DEFAULT_GROUP
|
||||||
|
|||||||
@ -160,6 +160,12 @@
|
|||||||
<artifactId>dingtalk</artifactId>
|
<artifactId>dingtalk</artifactId>
|
||||||
<version>2.0.14</version>
|
<version>2.0.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
|
<artifactId>nacos-api</artifactId>
|
||||||
|
<version>1.4.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@ -90,7 +90,7 @@ public class LoginRequiredAspect {
|
|||||||
} else {
|
} else {
|
||||||
log.info("FoundOldToken,currentBody:{} redisBody:{}", JSON.toJSONString(body), JSON.toJSONString(redisBody));
|
log.info("FoundOldToken,currentBody:{} redisBody:{}", JSON.toJSONString(body), JSON.toJSONString(redisBody));
|
||||||
throw new BusinessException(
|
throw new BusinessException(
|
||||||
TokenCodeEnum.AUTH_FAILED.getCode(), TokenCodeEnum.AUTH_FAILED.getMessage());
|
TokenCodeEnum.AUTH_TIME_OUT.getCode(), TokenCodeEnum.AUTH_TIME_OUT.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,62 @@
|
|||||||
|
package top.baogutang.common.config;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.NacosFactory;
|
||||||
|
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||||
|
import com.alibaba.nacos.api.config.ConfigService;
|
||||||
|
import com.alibaba.nacos.api.config.listener.Listener;
|
||||||
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.cloud.context.refresh.ContextRefresher;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: nacos config listener
|
||||||
|
* @author: nikooh
|
||||||
|
* @date: 2024/07/02 : 18:37
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class NacosConfigExchangeListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ContextRefresher contextRefresher;
|
||||||
|
|
||||||
|
@Value("${spring.cloud.nacos.config.server-addr}")
|
||||||
|
private String serverAddr;
|
||||||
|
|
||||||
|
@Value("${spring.application.name}")
|
||||||
|
private String dataId;
|
||||||
|
|
||||||
|
@Value("${spring.cloud.nacos.config.group}")
|
||||||
|
private String group;
|
||||||
|
|
||||||
|
@Value("${spring.cloud.nacos.config.namespace}")
|
||||||
|
private String namespace;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void addNacosConfigListener() throws NacosException {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
|
||||||
|
properties.put(PropertyKeyConst.NAMESPACE, namespace);
|
||||||
|
ConfigService configService = NacosFactory.createConfigService(properties);
|
||||||
|
configService.addListener(dataId, group, new Listener() {
|
||||||
|
@Override
|
||||||
|
public void receiveConfigInfo(String configInfo) {
|
||||||
|
log.info(">>>>>>>>>>receive config change! dataId:{},group:{}<<<<<<<<<<", dataId, group);
|
||||||
|
CompletableFuture.runAsync(() -> contextRefresher.refresh());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Executor getExecutor() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,6 +7,10 @@ package top.baogutang.common.constants;
|
|||||||
*/
|
*/
|
||||||
public class CacheConstant {
|
public class CacheConstant {
|
||||||
|
|
||||||
|
private CacheConstant() {
|
||||||
|
// empty private constructor
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实名认证完成
|
* 实名认证完成
|
||||||
*/
|
*/
|
||||||
@ -41,4 +45,9 @@ public class CacheConstant {
|
|||||||
public static final String PREFIX_DING_TALK_ACCESS_TOKEN = "top:baogutang:dingtalk:access_token:";
|
public static final String PREFIX_DING_TALK_ACCESS_TOKEN = "top:baogutang:dingtalk:access_token:";
|
||||||
|
|
||||||
public static final String PREFIX_APPLE_PRODUCT = "top:baogutang:apple:product:%s:%s:";
|
public static final String PREFIX_APPLE_PRODUCT = "top:baogutang:apple:product:%s:%s:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序登陆缓存sessionId
|
||||||
|
*/
|
||||||
|
public static final String WX_SESSION_ID = "top:baogutang:weixin_app:wx_session_id:%s";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ public class OkHttpUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T post(String url, Map<String, String> headerMap, Map<String, String> params, TypeReference<T> type) {
|
public static <T> T post(String url, Map<String, String> headerMap, Map<String, Object> params, TypeReference<T> type) {
|
||||||
try {
|
try {
|
||||||
Headers.Builder headerBuilder = new Headers.Builder();
|
Headers.Builder headerBuilder = new Headers.Builder();
|
||||||
if (Objects.nonNull(headerMap) && !headerMap.isEmpty()) {
|
if (Objects.nonNull(headerMap) && !headerMap.isEmpty()) {
|
||||||
|
|||||||
@ -45,6 +45,7 @@ public class RandImageUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接通过response 返回图片
|
* 直接通过response 返回图片
|
||||||
|
*
|
||||||
* @param response
|
* @param response
|
||||||
* @param resultCode
|
* @param resultCode
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@ -57,6 +58,7 @@ public class RandImageUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成base64字符串
|
* 生成base64字符串
|
||||||
|
*
|
||||||
* @param resultCode
|
* @param resultCode
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user