- 移除不必要的配置字段和复杂错误类型 - 简化trace和log初始化逻辑,保留核心功能 - 使用标准Go错误替代自定义错误结构 - 启用默认批处理和消息丢弃机制- 保留gzip压缩和自动重连功能- 更新相关文档路径引用 - 添加OTel简化增强实现说明文档
2.2 KiB
2.2 KiB
卡密兑换平台
CODEBUDDY.md
Commands
- make build
- go run main.go
- make up
- go test ./...
- go test -v ./internal/logic/...
- make image
- make image.push
Architecture
- Entry: main.go initializes OpenTelemetry and starts internal/cmd.Main
- HTTP server and routes: internal/cmd/cmd.go binds controllers under /api with middleware
- Controllers: internal/controller/* grouped by domains (order, merchant, channel, road, road_pool, sys_user_login, sysUser, sys_payment, user_center, restriction, card_info_*) expose HTTP endpoints
- Business logic: internal/logic/* implements domain logic; heavy use of GoFrame generators (dao/service/enums)
- Data access: internal/dao, internal/model/{do,entity} generated by GoFrame DAO/ORM; MySQL driver enabled in main.go
- SystemV2: internal/systemV2/* newer modules with dao/logic/model/service mirroring v1
- Utilities: utility/* for config, cache (Redis), cron, otel tracing, limiter, notify, token, integrations (tmall, jd, walmart, ctrip, originalJd)
- Middleware: internal/middleware/* for auth and error handling
- Boot: internal/boot for app init; packed resources under internal/packed
Environments & Running
- Configuration via GoFrame config files under manifest/config and env vars (e.g., serverName)
- Docker Compose profiles provided in docker-compose.yml; backend maps 12401->22401 and mounts manifest/config and logs
- Make tasks rely on GoFrame CLI (gf); Makefile includes hack/hack.mk and auto-installs gf if missing
Code Generation Conventions
- Controllers: make ctrl
- DAO/DO/Entity: make dao
- Services: make service
- Enums: make enums
- Protobuf: make pb / make pbentity
Testing Notes
- Focused tests exist in internal/logic/* (e.g., card_apple_account, card_t_mall_order, limiter)
- Use go test -run to target specific tests when needed
Observability
- OpenTelemetry configured in main.go with service name composed from env serverName; utility/otel handles setup
- Health check endpoints and monitor tasks registered via internal/controller/monitor and utility/monitor
Deployment
- Docker image build/tag via make image; push with make image.push
- Kubernetes kustomize deploy supported via make deploy with overlays under manifest/deploy/kustomize