make same changes
This commit is contained in:
parent
452a8b5cab
commit
f24b569de1
@ -4,10 +4,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 180.97.221.51:8848
|
||||
server-addr: 117.72.78.133:8848
|
||||
config:
|
||||
server-addr: 180.97.221.51:8848
|
||||
namespace: 1877a228-6bff-46b9-a442-829473c3adc7
|
||||
server-addr: 117.72.78.133:8848
|
||||
namespace: 622d03f1-aeac-430c-8361-e69a73a5c4db
|
||||
file-extension: yml
|
||||
refresh-enabled: true
|
||||
group: DEFAULT_GROUP
|
||||
|
||||
@ -4,10 +4,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 180.97.221.51:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
server-addr: 180.97.221.51:8848
|
||||
namespace: fe5388cc-76bc-44d6-ba20-034f97c567e5
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: 636cb425-50d7-4489-a462-fd4a5be6b87d
|
||||
file-extension: yml
|
||||
refresh-enabled: true
|
||||
group: DEFAULT_GROUP
|
||||
|
||||
@ -160,6 +160,12 @@
|
||||
<artifactId>dingtalk</artifactId>
|
||||
<version>2.0.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-api</artifactId>
|
||||
<version>1.4.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -90,7 +90,7 @@ public class LoginRequiredAspect {
|
||||
} else {
|
||||
log.info("FoundOldToken,currentBody:{} redisBody:{}", JSON.toJSONString(body), JSON.toJSONString(redisBody));
|
||||
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 {
|
||||
|
||||
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_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;
|
||||
}
|
||||
|
||||
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 {
|
||||
Headers.Builder headerBuilder = new Headers.Builder();
|
||||
if (Objects.nonNull(headerMap) && !headerMap.isEmpty()) {
|
||||
|
||||
@ -45,6 +45,7 @@ public class RandImageUtil {
|
||||
|
||||
/**
|
||||
* 直接通过response 返回图片
|
||||
*
|
||||
* @param response
|
||||
* @param resultCode
|
||||
* @throws IOException
|
||||
@ -57,6 +58,7 @@ public class RandImageUtil {
|
||||
|
||||
/**
|
||||
* 生成base64字符串
|
||||
*
|
||||
* @param resultCode
|
||||
* @return
|
||||
* @throws IOException
|
||||
@ -74,10 +76,10 @@ public class RandImageUtil {
|
||||
//删除 \r\n
|
||||
base64 = base64.replaceAll("\n", "").replaceAll("\r", "");
|
||||
|
||||
return BASE64_PRE+base64;
|
||||
return BASE64_PRE + base64;
|
||||
}
|
||||
|
||||
private static BufferedImage getImageBuffer(String resultCode){
|
||||
private static BufferedImage getImageBuffer(String resultCode) {
|
||||
// 在内存中创建图象
|
||||
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
// 获取图形上下文
|
||||
|
||||
Loading…
Reference in New Issue
Block a user