docs: 合并CLAUDE规范

This commit is contained in:
2026-08-01 00:15:56 +08:00
parent b61736eb2b
commit e32226d7d2
2 changed files with 38 additions and 64 deletions
+38 -1
View File
@@ -4,11 +4,12 @@
## Git 提交规范
- 提交信息使用中文,简洁描述变更内容
- 提交信息必须简短且使用中文,不要使用英文长句
- 格式:`类型: 简述`,例如 `feat: 新增用户登录接口``fix: 修复多租户拦截器空指针``docs: 补充API文档`
## 技术栈
- Java 17
- 框架:Spring Boot 3.2.5
- ORMMyBatis-Plus 3.5.5
- 数据库:MySQL 8.0
@@ -18,6 +19,7 @@
- 连接池:Druid 1.2.8
- 密码加密:jBCrypt 0.4
- API 文档:Knife4j (OpenAPI 3)
- Lombok@Data, @Slf4j
## 项目结构
@@ -36,6 +38,12 @@ lpt-be/src/main/java/com/guo/learningprogresstracker/
└── utils/ → 工具类
```
- controller 只做参数校验和路由。
- service/impl 承载业务逻辑。
- mapper 使用 MyBatis-Plus BaseMapper。
- entity 使用 `@TableName``@TableField` 映射数据库字段。
- mapStruct 承载 DTO 转换。
## API 端点总览(32 个)
| 模块 | 端点数 | 端点 |
@@ -59,6 +67,35 @@ lpt-be/src/main/java/com/guo/learningprogresstracker/
- 响应格式:`CommonResult<T>` 统一包装 `{ code, message, data }`
- CORS:可配置,local profile 允许所有来源。
## 响应规范
- 成功:`CommonResult.success(data)`code=200。
- 业务错误:`CommonResult.error(msg)`code=400HTTP 200。
- 未登录:`GlobalExceptionHandler.handleNotLogin()`HTTP 401 + code=401。
- 参数校验失败:`MethodArgumentNotValidException`code=400。
## DTO 转换
- MapStruct 编译期生成 `*ConvertImpl.java`,同名属性自动映射。
- 默认 `unmappedTargetPolicy = IGNORE`
- 自定义映射使用 `@Mapping(source, target)`
- 增删 DTO 字段后必须重新编译,否则生成代码不含新字段。
## CORS
-`CorsProperties` 读取各 profile 的 `cors.allowed-origins`
- `allowed-origins: "*"` 时自动切换为 `allowedOriginPatterns("*")`,兼容 `allowCredentials`
## 标题抓取
- `TitleFetcher`:静态工具类,支持 HTTP→HTTPS 重定向和宽松 SSL。
- `UtilsController``GET /utils/fetch-title?url=...` 代理端点。
## 运行环境
- 默认 profilelocal`application.yml``spring.profiles.active: local`)。
- 编译命令:`mvn clean compile -DskipTests`,需要 JDK 17。
## 配置文件
| Profile | 文件 |