Skip to content

Commit abdb185

Browse files
authored
Merge pull request #5 from TrueNine/dev
🚀 [release] 0.0.5
2 parents 4b2bc66 + 79deaff commit abdb185

6 files changed

Lines changed: 133 additions & 88 deletions

File tree

CLAUDE.md

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,110 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5+
## 框架定位
6+
7+
Compose Server 是一个现代化、模块化的 Kotlin 企业级服务端开发**框架**,而非脚手架。它通过 Gradle 多模块方式,提供安全、数据库、缓存、对象存储、支付、AI 等企业级能力,支持按需集成到任意 Spring Boot 项目中。
8+
59
## 构建和测试命令
610

711
这是一个基于 Gradle 的 Kotlin 多模块项目。
812

9-
### 基本构建命令
10-
1113
- `./gradlew build` - 构建整个项目
1214
- `./gradlew clean` - 清理构建输出
1315
- `./gradlew publishToMavenLocal` - 发布到本地 Maven 仓库
1416
- `./gradlew versionCatalogUpdate` - 更新版本目录中的依赖版本
15-
16-
### 测试命令
17-
1817
- `./gradlew test` - 运行所有测试
1918
- `./gradlew :模块名:test` - 运行特定模块的测试
20-
- `./gradlew :shared:test` - 运行共享模块测试
21-
- `./gradlew :rds:shared:test` - 运行 RDS 共享模块测试
22-
23-
### 代码质量检查
24-
2519
- `./gradlew spotlessCheck` - 检查代码格式
2620
- `./gradlew spotlessApply` - 自动修复代码格式
2721

28-
### 单个模块构建
29-
30-
- `./gradlew :模块名:build` - 构建特定模块
31-
- `./gradlew :shared:build` - 构建共享模块
32-
3322
## 项目架构
3423

3524
### 模块化结构
3625

37-
项目采用多模块设计,主要模块包括:
26+
本框架采用多模块设计,主要模块包括:
3827

39-
- **shared** - 共享基础组件,包含通用工具类、异常处理、类型定义等
28+
- **shared** - 核心基础组件,包含通用工具类、异常处理、类型定义、统一响应、分页等
4029
- **meta** - 元数据和注解处理器
41-
- **rds** - 数据库相关模块
42-
- `rds:shared` - 数据库共享组件
43-
- `rds:crud` - CRUD 操作封装
44-
- `rds:jimmer-ext-postgres` - Jimmer ORM PostgreSQL 扩展
45-
- `rds:flyway-migration-postgresql` - Flyway 数据库迁移
46-
- **security** - 安全相关模块
47-
- `security:spring` - Spring Security 集成
48-
- `security:oauth2` - OAuth2 认证
49-
- `security:crypto` - 加密解密功能
50-
- **oss** - 对象存储模块
51-
- `oss:shared` - 对象存储共享组件
52-
- `oss:minio` - MinIO 集成
53-
- `oss:aliyun-oss` - 阿里云 OSS 集成
54-
- `oss:huawei-obs` - 华为云 OBS 集成
55-
- **pay** - 支付模块(微信支付等)
56-
- **cacheable** - 缓存组件
57-
- **data** - 数据处理模块
58-
- `data:extract` - 数据提取(EasyExcel 等)
59-
- `data:crawler` - 数据爬虫
60-
- **depend** - 特定依赖处理模块
30+
- **rds** - 数据库相关(Jimmer ORM、CRUD、PostgreSQL 扩展、Flyway 迁移)
31+
- **surveillance** - 监控组件
32+
- **security** - 安全相关(Spring Security、OAuth2、加密解密)
33+
- **oss** - 对象存储(MinIO、阿里云 OSS、华为云 OBS)
34+
- **pay** - 支付模块(微信支付 V3)
35+
- **cacheable** - 多级缓存(Redis、Caffeine)
36+
- **data** - 数据处理(EasyExcel、爬虫、行政区划等)
37+
- **depend** - 特定依赖处理
6138
- **testtoolkit** - 测试工具包
6239
- **gradle-plugin** - Gradle 插件
63-
- **ksp** - Kotlin Symbol Processing 相关
64-
- **sms** - 短信发送模块
65-
- **mcp** - AI 相关模块
40+
- **ksp** - Kotlin Symbol Processing
41+
- **sms** - 短信服务(腾讯云短信,短信抽象层)
42+
- **mcp** - AI 能力(LangChain4j、Ollama、智谱 AI)
43+
44+
> 所有模块均可独立集成,推荐组合见下表。
45+
46+
### 推荐模块组合
47+
48+
| 使用场景 | 推荐模块组合 |
49+
|----------------|----------------------------------------|
50+
| 基础 Web API | shared + security-spring |
51+
| 数据库操作 | shared + rds-shared + rds-crud |
52+
| 文件存储 | shared + oss-shared + oss-minio |
53+
| 微信支付 | shared + pay |
54+
| 数据导入导出 | shared + data-extract |
55+
| AI 能力 | shared + mcp |
56+
57+
## 技术栈
58+
59+
- **Kotlin** 2.2.x
60+
- **Spring Boot** 3.5.x
61+
- **Jimmer** 0.9.x
62+
- **Gradle** 9.x
63+
- **PostgreSQL****Redis****Caffeine****MinIO****阿里云 OSS****华为云 OBS**
64+
65+
## 依赖管理
66+
67+
- 统一使用 Gradle Version Catalog(`gradle/libs.versions.toml`)管理依赖版本
68+
- 所有模块版本、groupId 通过根项目统一管理
69+
- 推荐通过 `publishToMavenLocal` 集成本地开发版本
70+
6671

67-
### 技术栈
72+
## 代码约定
6873

69-
- **语言**: Kotlin (JVM)
70-
- **框架**: Spring Boot 3.5.3
71-
- **ORM**: Jimmer 0.9.97
72-
- **构建工具**: Gradle 9.x
73-
- **数据库**: PostgreSQL (主要)
74-
- **缓存**: Redis, Caffeine
75-
- **对象存储**: MinIO, 阿里云 OSS, 华为云 OBS
74+
- 所有模块使用 `kotlinspring-convention` 插件,集成 Spring Boot 与 Kotlin 规范
75+
- 包名格式:`io.github.truenine.composeserver.模块名`
7676

77-
### 依赖管理
77+
- 代码格式化:使用 Spotless,提交前请运行 `./gradlew spotlessApply`
78+
- 数据库迁移:使用 Flyway,脚本位于 `rds/flyway-migration-数据库类型/src/main/resources/db/migration/`,命名规则 `V版本号__描述.sql`
7879

79-
- 使用 Gradle Version Catalog (`gradle/libs.versions.toml`) 统一管理依赖版本
80-
- 通过 build-logic 自定义 Gradle 插件和约定,使用 pluginManagement includeBuild 引入
81-
- 所有模块版本通过 `project` 版本号统一管理
82-
- 所有 groupId 通过 `group` 版本号统一管理
80+
## 集成与最佳实践
8381

84-
### 代码约定
82+
1. **依赖引入**
83+
在业务项目的 `build.gradle.kts` 中按需添加依赖,例如:
84+
```kotlin
85+
implementation("io.github.truenine:composeserver-shared:latest")
86+
implementation("io.github.truenine:composeserver-rds-shared:latest")
87+
implementation("io.github.truenine:composeserver-security-spring:latest")
88+
```
89+
2. **自动配置**
90+
启用自动配置注解(如有):
91+
```kotlin
92+
@SpringBootApplication
93+
@EnableComposeServer
94+
class YourApplication
95+
```
96+
3. **统一响应、异常、分页等**
97+
推荐使用框架内置的统一响应、异常处理、分页等能力,详见 `shared` 模块。
8598

86-
- 所有模块使用 `kotlinspring-convention` 插件,集成 Spring Boot 和 Kotlin 配置
87-
- 测试类命名为 `TestEntrance`
88-
- 使用 Spotless 进行代码格式化
89-
- 包名遵循 `io.github.truenine.composeserver.模块名` 格式
99+
4. **测试与发布**
100+
- 修改代码后先格式化,再运行测试,最后构建或发布到本地 Maven 仓库
101+
- 推荐使用 `./gradlew test``./gradlew build``./gradlew publishToMavenLocal`
90102

91-
### 开发工作流
103+
## 其他说明
92104

93-
1. 修改代码后运行 `./gradlew spotlessApply` 格式化代码
94-
2. 运行 `./gradlew test` 确保测试通过
95-
3. 运行 `./gradlew build` 构建项目
96-
4. 使用 `./gradlew publishToMavenLocal` 发布到本地测试
105+
- 本项目为**框架库**,不包含脚手架或项目初始化功能
106+
- 所有模块均已发布至 Maven Central,详见 [README.md][Maven Central](https://central.sonatype.com/search?q=g:io.github.truenine)
107+
- 详细 API、集成示例、变更日志等请参考 [README.md] 和官方文档
97108

98-
### 数据库迁移
109+
---
99110

100-
- 使用 Flyway 进行数据库版本管理
101-
- 迁移脚本位于 `rds/flyway-migration-postgresql/src/main/resources/db/migration/`
102-
- 命名规则:`V版本号__描述.sql`
111+
如需为本项目贡献代码或扩展模块,请遵循上述规范和最佳实践。

build-logic/src/main/kotlin/buildlogic.java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tasks.withType<Jar> {
4343
testing {
4444
suites {
4545
val test by getting(JvmTestSuite::class) {
46-
useJUnitJupiter(libs.versions.org.junit.junit5.get())
46+
useJUnitJupiter(libs.versions.org.junit.jupiter.get())
4747
}
4848
}
4949
}

docs/GLOBAL_CLAUDE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Claude Code 专用 AI 规则(2025-07 版)
2+
3+
## 通用规范
4+
- 所有回复必须使用简体中文。
5+
6+
## SQL 规范
7+
- SQL 语句全部小写(关键字、标识符)。
8+
- 命名风格统一使用下划线命名法(snake_case)。
9+
- 严禁拼接 SQL 字符串,必须使用参数化查询,防止 SQL 注入。
10+
- 表、字段、索引等命名需简洁明了,避免缩写。
11+
- 禁止在代码中硬编码数据库连接信息,需使用配置文件或安全管理方式。
12+
- 建议为重要业务表和字段添加注释,便于维护。
13+
14+
## 通用代码规范
15+
- 文档注释必须由英文书写。
16+
- 优先采用提前返回(early return),减少嵌套。
17+
- 禁止行尾注释,注释需单独成行。
18+
- 统一使用 2 空格缩进,仅用空格,不用 Tab。
19+
- 禁止全量 import,必须显式导入所需内容。
20+
- 编程语言优先选择编译型语言,避免动态语言,以便尽早发现错误。
21+
- 应积极采用日志记录方式协助诊断问题,并合理控制日志级别,避免无效或过量日志输出。
22+
23+
## markdown 规范
24+
- Markdown 文件需扁平、紧凑,严禁嵌套列表。
25+
- 采用分级标题+扁平条目归类结构,避免多层嵌套,整体风格清晰、紧凑、分组明确。
26+
- 内容应准确、简明,避免歧义和冗余。
27+
- 结构应清晰,分组合理,便于查阅。
28+
- 统一术语和表达风格,避免同义词混用。
29+
- 注重可读性,适当分段,避免长段落堆砌。
30+
- 人类以阅读为主,AI 需确保文档对人类友好、易于理解。
31+
32+
## 依赖与技术规范
33+
- 仅推荐和采用最新技术,所有建议和代码实现前必须查阅最新官方文档,确保内容为 2025 年及以后主流方案。
34+
- 禁止试图通过降级依赖版本来解决问题,遇到依赖或兼容性问题时,必须优先查阅最新技术文档或最佳实践,积极采用主流和前沿方案。

gradle/libs.versions.toml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ cn-dev33-sa-token-redis = "1.44.0"
44
cn-hutool = "5.8.39"
55
com-alibaba-cloud = "2023.0.3.3"
66
com-baomidou-mybatis-plus = "3.5.12"
7-
com-diffplug-spotless = "7.0.4"
7+
com-diffplug-spotless = "7.1.0"
88
com-fasterxml-jackson = "2.19.1"
9-
com-flywaydb-flyway = "11.10.1"
9+
com-flywaydb-flyway = "11.10.2"
1010
com-github-tschuchortdev-kotlin-compile-testing = "1.6.0"
1111
com-google-devtools-ksp = "2.2.0-2.0.2"
1212
com-mapstruct = "1.6.3"
@@ -25,18 +25,18 @@ net-sf-sevenzipjbinding = "16.02-2.01"
2525
nl-littlerobots-version-catalog-updat-gradle-plugin = "1.0.0"
2626
org-apache-commons-exec = "1.5.0"
2727
org-apache-logging-log4j = "2.24.3"
28-
org-assertj = "3.27.2"
29-
org-babyfish-jimmer = "0.9.97"
28+
org-assertj = "4.0.0-M1"
29+
org-babyfish-jimmer = "0.9.99"
30+
org-gradle = "9.0.0-rc-2"
3031
org-hibernate-orm = "6.6.15.Final"
3132
org-jetbrains-dokka = "2.0.0"
3233
org-jetbrains-kotlin = "2.2.0"
3334
org-jetbrains-kotlinx-coroutines = "1.10.2"
34-
org-jetbrains-kotlinx-datetime = "0.7.0-0.6.x-compat"
35+
org-jetbrains-kotlinx-datetime = "0.7.1-0.6.x-compat"
3536
org-jetbrains-kotlinx-io = "0.8.0"
3637
org-jetbrains-kotlinx-serialization = "1.9.0"
37-
org-junit-junit5 = "6.0.0-M1"
38-
org-junit-platform = "1.13.1"
39-
org-liquibase = "4.32.0"
38+
org-junit-jupiter = "6.0.0-M1"
39+
org-liquibase = "4.33.0"
4040
org-slf4j = "2.1.0-alpha1"
4141
org-springframework-ai = "1.0.0"
4242
org-springframework-batch = "5.2.2"
@@ -49,7 +49,7 @@ org-springframework-modulith = "1.4.1"
4949
org-springframework-security = "6.5.1"
5050
org-testcontainers = "1.21.3"
5151
org-testng = "7.11.0"
52-
project = "0.0.4"
52+
project = "0.0.5"
5353

5454
[libraries]
5555
cn-dev33-sa-token-redis-jackson = { module = "cn.dev33:sa-token-redis-jackson", version.ref = "cn-dev33-sa-token" }
@@ -106,7 +106,7 @@ com-querydsl-querydsl-jpa = { module = "com.querydsl:querydsl-jpa", version.ref
106106
com-squareup-javapoet = "com.squareup:javapoet:1.13.0"
107107
com-squareup-kotlinpoet-jvm = { module = "com.squareup:kotlinpoet-jvm", version.ref = "com-squareup-kotlinpoet" }
108108
com-squareup-kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "com-squareup-kotlinpoet" }
109-
com-squareup-okhttp3-okhttp = "com.squareup.okhttp3:okhttp:5.0.0"
109+
com-squareup-okhttp3-okhttp = "com.squareup.okhttp3:okhttp:5.1.0"
110110
com-squareup-okio-okio = { module = "com.squareup.okio:okio", version.ref = "com-squareup-okio" }
111111
com-squareup-okio-okio-jvm = { module = "com.squareup.okio:okio-jvm", version.ref = "com-squareup-okio" }
112112
com-squareup-retrofit2-retrofit = "com.squareup.retrofit2:retrofit:3.0.0"
@@ -126,7 +126,7 @@ dev-langchain4j-langchain4j-pgvector = { module = "dev.langchain4j:langchain4j-p
126126
dev-langchain4j-langchain4j-reactor = { module = "dev.langchain4j:langchain4j-reactor", version.ref = "dev-langchain4j" }
127127
dev-langchain4j-langchain4j-spring-boot-starter = { module = "dev.langchain4j:langchain4j-spring-boot-starter", version.ref = "dev-langchain4j" }
128128
dev-langchain4j-langchain4j-zhipu-ai = "dev.langchain4j:langchain4j-zhipu-ai:0.36.2"
129-
io-github-bonigarcia-webdrivermanager = "io.github.bonigarcia:webdrivermanager:6.1.0"
129+
io-github-bonigarcia-webdrivermanager = "io.github.bonigarcia:webdrivermanager:6.1.1"
130130
io-github-truenine-composeserver-cacheable = { module = "io.github.truenine:composeserver-cacheable", version.ref = "project" }
131131
io-github-truenine-composeserver-data-crawler = { module = "io.github.truenine:composeserver-data-crawler", version.ref = "project" }
132132
io-github-truenine-composeserver-data-extract = { module = "io.github.truenine:composeserver-data-extract", version.ref = "project" }
@@ -161,7 +161,7 @@ io-jsonwebtoken-jjwt-api = "io.jsonwebtoken:jjwt-api:0.12.6"
161161
io-minio-minio = "io.minio:minio:8.5.17"
162162
io-mockk-mockk = "io.mockk:mockk:1.14.4"
163163
io-netty-netty-handler = { module = "io.netty:netty-handler", version.ref = "io-netty" }
164-
io-projectreactor-kotlin-reactor-kotlin-extensions = "io.projectreactor.kotlin:reactor-kotlin-extensions:1.2.3"
164+
io-projectreactor-kotlin-reactor-kotlin-extensions = "io.projectreactor.kotlin:reactor-kotlin-extensions:1.3.0-RC1"
165165
io-projectreactor-reactor-test = "io.projectreactor:reactor-test:3.8.0-M4"
166166
io-spring-gradle-dependency-management-plugin = "io.spring.gradle:dependency-management-plugin:1.1.7"
167167
io-swagger-core-v3-swagger-annotations-jakarta = "io.swagger.core.v3:swagger-annotations-jakarta:2.2.34"
@@ -232,12 +232,12 @@ org-jetbrains-kotlinx-kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlin
232232
org-jetbrains-kotlinx-kotlinx-io-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-io-core-jvm", version.ref = "org-jetbrains-kotlinx-io" }
233233
org-jetbrains-kotlinx-kotlinx-serialization-bom = { module = "org.jetbrains.kotlinx:kotlinx-serialization-bom", version.ref = "org-jetbrains-kotlinx-serialization" }
234234
org-jetbrains-kotlinx-kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "org-jetbrains-kotlinx-serialization" }
235-
org-jsoup-jsoup = "org.jsoup:jsoup:1.20.1"
236-
org-junit-jupiter-junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "org-junit-junit5" }
237-
org-junit-jupiter-junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "org-junit-junit5" }
238-
org-junit-jupiter-junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "org-junit-junit5" }
239-
org-junit-platform-junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "org-junit-platform" }
240-
org-junit-vintage-junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "org-junit-junit5" }
235+
org-jsoup-jsoup = "org.jsoup:jsoup:1.21.1"
236+
org-junit-jupiter-junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "org-junit-jupiter" }
237+
org-junit-jupiter-junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "org-junit-jupiter" }
238+
org-junit-jupiter-junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "org-junit-jupiter" }
239+
org-junit-platform-junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "org-junit-jupiter" }
240+
org-junit-vintage-junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "org-junit-jupiter" }
241241
org-lionsoul-ip2region = "org.lionsoul:ip2region:2.7.0"
242242
org-liquibase-liquibase-core = { module = "org.liquibase:liquibase-core", version.ref = "org-liquibase" }
243243
org-mapstruct-mapstruct = { module = "org.mapstruct:mapstruct", version.ref = "com-mapstruct" }

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ pluginManagement {
77
}
88
}
99

10-
rootProject.name = "compose-server"
10+
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" }
1111

1212
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
1313

14+
rootProject.name = "compose-server"
15+
1416
fun Pair<String, List<String>>.useFile() {
1517
second.forEach { n ->
1618
include("$first:$n")

0 commit comments

Comments
 (0)