feat(system): 添加 websopy 用户同步服务集成
- 配置 websopy 服务地址用于用户数据同步功能 - 实现用户同步到 websopy 的接口调用逻辑 - 添加用户缓存刷新功能以保持数据一致性 - 移除 PostConstruct 初始化方式改为运行时获取配置 - 添加同步操作的空值检查和警告日志处理
This commit is contained in:
@@ -10,7 +10,6 @@ import org.apache.http.HttpResponse;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -29,16 +28,11 @@ public class UserSyncService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ConfigProperties configProperties;
|
private ConfigProperties configProperties;
|
||||||
|
|
||||||
private String websopyBaseUrl;
|
/**
|
||||||
|
* 获取 websopy 基础 URL
|
||||||
@PostConstruct
|
*/
|
||||||
public void init() {
|
private String getWebsopyBaseUrl() {
|
||||||
websopyBaseUrl = configProperties.getWebsopyUrl();
|
return configProperties.getWebsopyUrl();
|
||||||
if (websopyBaseUrl == null || websopyBaseUrl.isEmpty()) {
|
|
||||||
log.warn("websopyUrl 未配置,用户同步功能将不可用");
|
|
||||||
} else {
|
|
||||||
log.info("用户同步服务初始化完成,websopy地址: {}", websopyBaseUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +41,7 @@ public class UserSyncService {
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
*/
|
*/
|
||||||
public void syncUserToWebsopy(User user) {
|
public void syncUserToWebsopy(User user) {
|
||||||
|
String websopyBaseUrl = getWebsopyBaseUrl();
|
||||||
if (websopyBaseUrl == null || websopyBaseUrl.isEmpty()) {
|
if (websopyBaseUrl == null || websopyBaseUrl.isEmpty()) {
|
||||||
log.warn("websopyUrl 未配置,跳过用户同步: userId={}", user.getUserId());
|
log.warn("websopyUrl 未配置,跳过用户同步: userId={}", user.getUserId());
|
||||||
return;
|
return;
|
||||||
@@ -102,6 +97,7 @@ public class UserSyncService {
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
public void refreshUserCache(Integer userId) {
|
public void refreshUserCache(Integer userId) {
|
||||||
|
String websopyBaseUrl = getWebsopyBaseUrl();
|
||||||
if (websopyBaseUrl == null || websopyBaseUrl.isEmpty()) {
|
if (websopyBaseUrl == null || websopyBaseUrl.isEmpty()) {
|
||||||
log.warn("websopyUrl 未配置,跳过刷新缓存: userId={}", userId);
|
log.warn("websopyUrl 未配置,跳过刷新缓存: userId={}", userId);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ config:
|
|||||||
bucketDomain: https://oss.wsdns.cn
|
bucketDomain: https://oss.wsdns.cn
|
||||||
aliyunDomain: https://oss-gxwebsoft.oss-cn-shenzhen.aliyuncs.com
|
aliyunDomain: https://oss-gxwebsoft.oss-cn-shenzhen.aliyuncs.com
|
||||||
|
|
||||||
|
# websopy 服务地址(用于同步用户数据)
|
||||||
|
websopyUrl: https://websopy-api.websoft.top
|
||||||
|
|
||||||
# 生产环境证书配置
|
# 生产环境证书配置
|
||||||
certificate:
|
certificate:
|
||||||
# 生产环境使用挂载卷模式
|
# 生产环境使用挂载卷模式
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ config:
|
|||||||
upload-path: /Users/gxwebsoft/Documents/uploads
|
upload-path: /Users/gxwebsoft/Documents/uploads
|
||||||
local-upload-path: /Users/gxwebsoft/Documents/uploads
|
local-upload-path: /Users/gxwebsoft/Documents/uploads
|
||||||
|
|
||||||
|
# websopy 服务地址(用于同步用户数据)
|
||||||
|
websopyUrl: https://websopy-api.websoft.top
|
||||||
|
|
||||||
# 阿里云OSS云存储
|
# 阿里云OSS云存储
|
||||||
endpoint: https://oss-cn-shenzhen.aliyuncs.com
|
endpoint: https://oss-cn-shenzhen.aliyuncs.com
|
||||||
accessKeyId: LTAI5tGXuJku8MK7TA6gQMZw
|
accessKeyId: LTAI5tGXuJku8MK7TA6gQMZw
|
||||||
|
|||||||
Reference in New Issue
Block a user