- 重构根目录CLAUDE.md为项目总览(60行精简版) - 细化backend模块CLAUDE.md为开发指南 - 新增各子模块CLAUDE.md文件: - api/desc/ - API定义模块 - internal/handler/ - 请求处理器 - internal/logic/ - 业务逻辑层 - internal/model/ - 数据模型层 - internal/middleware/ - 中间件层 - internal/svc/ - 服务上下文 - configs/ - 配置目录 - deploy/ - 部署配置 - pkg/ - 公共库 - scripts/ - 工具脚本 - configs/sql/ - SQL脚本 - 修复PostgreSQL SSL配置参数 - 清理旧的backend-old目录 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
34
backend/pkg/CLAUDE.md
Normal file
34
backend/pkg/CLAUDE.md
Normal file
@ -0,0 +1,34 @@
|
||||
# 公共库目录
|
||||
|
||||
## 📦 包结构
|
||||
```
|
||||
pkg/
|
||||
├── constants/ # 全局常量
|
||||
├── errorx/ # 错误处理
|
||||
├── response/ # 响应格式
|
||||
└── utils/ # 工具集合
|
||||
├── jwt/ # JWT工具
|
||||
├── hash/ # 哈希工具
|
||||
├── file/ # 文件处理
|
||||
└── database/ # 数据库工具
|
||||
```
|
||||
|
||||
## 🎯 设计原则
|
||||
- **可复用**: 项目间共享的通用功能
|
||||
- **无依赖**: 不依赖内部业务代码
|
||||
- **易测试**: 独立可测试的单元
|
||||
|
||||
## 🚀 快速使用
|
||||
```go
|
||||
// 使用错误处理
|
||||
import "photography-backend/pkg/errorx"
|
||||
err := errorx.New(errorx.CodeInvalidArgument)
|
||||
|
||||
// 使用JWT工具
|
||||
import "photography-backend/pkg/utils/jwt"
|
||||
token, err := jwt.GenerateToken(userID)
|
||||
|
||||
// 使用响应格式
|
||||
import "photography-backend/pkg/response"
|
||||
response.Success(c, data)
|
||||
```
|
||||
Reference in New Issue
Block a user