feat(user-sync): 更新用户同步服务时间格式和日志记录

- 将 updateTime 字段从毫秒时间戳改为 yyyy-MM-dd HH:mm:ss 格式
- 在同步日志中添加用户名、昵称和电话信息
- 添加请求体的调试日志输出
- 引入 LocalDateTime 和 DateTimeFormatter 时间处理类
This commit is contained in:
2026-04-04 04:36:52 +08:00
parent fd4d00a86d
commit 88b2e9977c

View File

@@ -12,6 +12,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
@@ -61,12 +63,14 @@ public class UserSyncService {
userCache.put("avatar", user.getAvatar());
userCache.put("phone", user.getPhone());
userCache.put("status", user.getStatus());
userCache.put("updateTime", System.currentTimeMillis());
userCache.put("updateTime", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
String url = websopyBaseUrl + "/api/app/user-sync/single";
String body = userCache.toJSONString();
log.info("同步用户到 websopy: userId={}, url={}", user.getUserId(), url);
log.info("同步用户到 websopy: userId={}, username={}, nickname={}, phone={}, url={}",
user.getUserId(), user.getUsername(), user.getNickname(), user.getPhone(), url);
log.debug("同步用户请求体: {}", body);
// 发送 HTTP POST 请求
Map<String, String> headers = new HashMap<>();