优化结构

This commit is contained in:
Yvan
2026-08-21 00:28:09 +08:00
parent 361a562f75
commit 13f4589a18
21 changed files with 32 additions and 506 deletions
+5 -4
View File
@@ -1,4 +1,4 @@
# Platform
# Shared Packages
这里放跨业务模块的基础设施,不放具体业务表或业务用例。
@@ -7,7 +7,8 @@
- `database`:跨模块共享的 GORM 支持、分页和迁移执行器
- `module`:模块迁移、后台元数据和路由注册协议
- `task`:跨模块共享的进程内任务注册表和贡献协议
- `logging`:跨 app 复用的结构化日志能力
- `paymentkit`:支付金额、签名、状态和报文处理纯函数
平台层只能提供机制,不能引用 `internal/modules/*`。数据库配置加载、系统集成配置
和系统表仍由 system 模块负责;未来提炼公共连接管理时,也必须先形成不带系统
业务语义的稳定接口,再移动到这里。
`pkg` 只能提供机制和稳定协议,不能引用任何 `app/*/internal`。数据库配置加载、
系统集成配置、系统表和 provider 生命周期仍由 `app/system` 负责。
+3 -3
View File
@@ -50,9 +50,9 @@ func skipStackFile(filename string) bool {
"/go/pkg/mod/",
"/go.uber.org/",
"/gorm.io/",
"/internal/logging/",
"/internal/server/middleware/",
"/internal/server/router/",
"/pkg/logging/",
"/internal/transport/middleware/",
"/internal/transport/router/",
} {
if strings.Contains(normalized, marker) {
return true
+2 -2
View File
@@ -25,7 +25,7 @@ type Options struct {
}
// ErrorEntry is the storage-neutral representation of an Error-level log.
// Keeping it in internal/logging lets the log core report failures without taking a
// Keeping it in pkg/logging lets the log core report failures without taking a
// dependency on the application service or persistence layers.
type ErrorEntry struct {
Form, Info, Level, RequestID, TraceID string
@@ -264,7 +264,7 @@ func isGORMLoggerEntry(filename string, fields []zapcore.Field) bool {
}
normalized := strings.ReplaceAll(filename, "\\", "/")
return strings.HasSuffix(normalized, "/gorm_logger_writer.go") ||
strings.HasSuffix(normalized, "/internal/data/gorm_logger.go")
strings.HasSuffix(normalized, "/pkg/database/gormkit/logger.go")
}
func errorEntryFromZap(entry zapcore.Entry, fields []zapcore.Field) ErrorEntry {
+1 -1
View File
@@ -105,7 +105,7 @@ func TestErrorSinkSkipsGORMBridge(t *testing.T) {
base := zapcore.NewNopCore()
core := &routedFileCore{base: base, encoder: zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()), level: zapcore.ErrorLevel, root: root, state: &routedFileState{writers: map[string]*DailyWriter{}}, errorSink: state}
defer core.Close()
for _, filename := range []string{"/tmp/gorm_logger_writer.go", "/workspace/internal/data/gorm_logger.go"} {
for _, filename := range []string{"/tmp/gorm_logger_writer.go", "/workspace/pkg/database/gormkit/logger.go"} {
if err := core.Write(zapcore.Entry{Level: zapcore.ErrorLevel, Message: "database failed", Caller: zapcore.EntryCaller{Defined: true, File: filename, Line: 10}}, nil); err != nil {
t.Fatal(err)
}