diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..4e529dc --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,107 @@ +# XuqmGroup-Server — Claude 项目上下文 + +## 项目定位 + +XuqmGroup 后端服务集合。Spring Boot 3.4.4 + Java 21 + Maven 多模块微服务架构。 + +- Git 远端:`https://xuqinmin.com/xuqmGroup/XuqmGroup-Server.git` +- 技术栈:Spring Boot 3.4.4,Java 21,Spring Security 6(JWT),Spring Data JPA,MySQL 8,Redis 7 + +## 模块结构 + +``` +XuqmGroup-Server/ +├── pom.xml # 父 POM,统一依赖版本 +├── common/ # 公共库(ApiResponse、JWT、异常处理) +├── tenant-service/ # 租户服务 :8081 +├── im-service/ # IM 服务 :8082 +├── push-service/ # 推送服务 :8083 +├── update-service/ # 版本管理服务 :8084 +├── license-service/ # 证书授权服务 :8085 +├── file-service/ # 文件服务 +├── im-sdk/ # IM SDK(服务端封装) +└── demo-service/ # 演示服务 +``` + +## 服务端口 + +| 服务 | 端口 | 说明 | +|------|------|------| +| tenant-service | 8081 | 租户管理、认证、应用管理 | +| im-service | 8082 | IM 消息、群组、WebSocket | +| push-service | 8083 | 推送 token 注册、推送发送 | +| update-service | 8084 | App/RN Bundle 版本管理 | +| license-service | 8085 | 证书授权 | + +## 技术栈 + +| 组件 | 版本 | +|------|------| +| Spring Boot | 3.4.4 | +| Java | 21 | +| Spring Security | 6.x(JWT 无状态认证) | +| Spring Data JPA | Hibernate 6 | +| MySQL | 8.x | +| Redis | 7.x | +| JJWT | 0.12.6 | +| Spring WebSocket + STOMP | IM 实时通信 | + +## 快速启动 + +```bash +# 前置:MySQL 8 + Redis 7 本地运行 +cd XuqmGroup-Server + +# 启动所有服务 +cd tenant-service && mvn spring-boot:run & +cd im-service && mvn spring-boot:run & +cd push-service && mvn spring-boot:run & +cd update-service && mvn spring-boot:run & +``` + +首次启动自动建表(ddl-auto: update)。 +默认管理员:`admin` / `Admin@123456` + +## 核心 API 概览 + +### tenant-service(:8081) + +- 认证:`/api/auth/login`、`/api/auth/register`、`/api/auth/captcha` +- 应用管理:`/api/apps` CRUD +- 功能服务:`/api/apps/{appKey}/services`(IM/Push/Update 开关) +- 子账号:`/api/sub-accounts` +- 运营平台:`/api/ops/tenants`、`/api/ops/statistics` + +### im-service(:8082) + +- 消息:`/api/im/messages/send`、`/api/im/messages/history/{toId}` +- 群组:`/api/im/groups` CRUD +- WebSocket:`ws://localhost:8082/ws/im?token=` +- 关键词过滤、Webhook + +### push-service(:8083) + +- Token:`/api/push/register`、`/api/push/device/unregister` +- 推送:`/api/push/send`、`/api/push/internal/notify` +- 开关:`/api/push/receive-push` + +### update-service(:8084) + +- App 更新:`/api/v1/updates/app/check`、`/api/v1/updates/app/upload` +- RN Bundle:`/api/v1/rn/update/check`、`/api/v1/rn/upload` + +## 待新增:xuqm-log-service + +日志/错误追踪服务,Spring Boot 3.x + MySQL + Redis。 + +- 新建位置:`XuqmGroup-Server/xuqm-log-service/` +- 核心 API 前缀:`/log/v1/` +- 需要新增 `/api/sdk/config` 返回字段:`logApiUrl`、`logEnabled` + +## 常用命令 + +```bash +mvn spring-boot:run -pl tenant-service # 启动单个服务 +mvn clean package # 打包所有模块 +mvn clean package -pl tenant-service # 打包单个服务 +``` diff --git a/VERSION.xuqm-log-service b/VERSION.xuqm-log-service new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION.xuqm-log-service @@ -0,0 +1 @@ +1.0.0 diff --git a/pom.xml b/pom.xml index bfa0a96..eacfc9a 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ demo-service file-service license-service + xuqm-log-service diff --git a/xuqm-log-service/src/main/java/com/xuqm/log/service/WebhookService.java b/xuqm-log-service/src/main/java/com/xuqm/log/service/WebhookService.java index 1d1e499..c25a017 100644 --- a/xuqm-log-service/src/main/java/com/xuqm/log/service/WebhookService.java +++ b/xuqm-log-service/src/main/java/com/xuqm/log/service/WebhookService.java @@ -54,10 +54,10 @@ public class WebhookService { } String cooldownKey = COOLDOWN_KEY_PREFIX + webhook.getId() + ":" + issue.getFingerprint(); - Long acquired = redisTemplate.opsForValue() + Boolean acquired = redisTemplate.opsForValue() .setIfAbsent(cooldownKey, "1", Duration.ofSeconds(webhook.getCooldownSec())); - if (acquired != null && acquired) { + if (Boolean.TRUE.equals(acquired)) { sendWebhook(webhook, issue); } else { log.debug("Webhook cooldown active: webhookId={}, fingerprint={}", webhook.getId(), issue.getFingerprint());