diff --git a/app/admin/catalog.go b/app/admin/catalog.go new file mode 100644 index 0000000..8fab30b --- /dev/null +++ b/app/admin/catalog.go @@ -0,0 +1,34 @@ +// Package app is the composition root for the running administration service. +// It knows which business modules are enabled and wires their contributions +// into the shared platform. Individual modules do not import this package. +package app + +import ( + systemmodule "kra/app/system" + systemserver "kra/app/system/transport/server" + systemworker "kra/app/system/worker" + "kra/pkg/module" + platformtask "kra/pkg/task" +) + +// Catalog lists the business modules enabled in this binary. Adding an order +// module means adding one Definition here; system initialization and runtime +// code consume the catalog without knowing that module's implementation. +func Catalog() module.Catalog { + return module.Catalog{Definitions: []module.Definition{systemmodule.Definition()}} +} + +// TaskRegistry builds the process-wide registry from dependency-free module +// contributions. Dependency-bearing methods are added by their module runtime +// constructors after the usecases have been created. +func TaskRegistry(catalog module.Catalog) *platformtask.Registry { + registry := platformtask.NewRegistry() + registry.RegisterAll(catalog.TaskMethods()) + return registry +} + +// Runtime composes HTTP route contributors from the enabled modules. +func Runtime(systemRoutes *systemserver.Routes, systemTasks *systemworker.TaskMethods, registry *platformtask.Registry) *module.Runtime { + platformtask.Apply(registry, systemTasks) + return module.NewRuntime(systemRoutes) +} diff --git a/internal/modules/system/transport/server/gin.go b/app/admin/server/gin.go similarity index 80% rename from internal/modules/system/transport/server/gin.go rename to app/admin/server/gin.go index 6d18932..cd16dbe 100644 --- a/internal/modules/system/transport/server/gin.go +++ b/app/admin/server/gin.go @@ -10,18 +10,22 @@ import ( "strings" "time" + "kra/app/system/service" + "kra/app/system/transport/handler" + "kra/app/system/transport/httpx" + servermiddleware "kra/app/system/transport/middleware" "kra/internal/conf" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/handler" - "kra/internal/modules/system/transport/httpx" - servermiddleware "kra/internal/modules/system/transport/middleware" - serverrouter "kra/internal/modules/system/transport/router" + platformmodule "kra/pkg/module" "github.com/gin-gonic/gin" kratoshttp "github.com/go-kratos/kratos/v3/transport/http" ) func NewGinEngine(runtime *conf.Runtime, access *service.AccessControlService, handlers *handler.Set, auth *service.AuthService, security *service.SecurityService, audit *service.AuditRecorder, logger *slog.Logger, version string) *gin.Engine { + return NewGinEngineWithRuntime(runtime, access, auth, security, audit, logger, version, platformmodule.NewRuntime(NewRoutes(handlers))) +} + +func NewGinEngineWithRuntime(runtime *conf.Runtime, access *service.AccessControlService, auth *service.AuthService, security *service.SecurityService, audit *service.AuditRecorder, logger *slog.Logger, version string, routes *platformmodule.Runtime) *gin.Engine { gin.SetMode(gin.ReleaseMode) engine := gin.New() if err := engine.SetTrustedProxies(nil); err != nil && logger != nil { @@ -36,7 +40,6 @@ func NewGinEngine(runtime *conf.Runtime, access *service.AccessControlService, h } public := engine.Group(prefix) public.GET("/health", func(c *gin.Context) { c.JSON(http.StatusOK, "ok") }) - serverrouter.RegisterPublic(public, engine, handlers.Public) private := engine.Group(prefix) // The reference administration behavior installs operation recording after JWT, @@ -44,26 +47,9 @@ func NewGinEngine(runtime *conf.Runtime, access *service.AccessControlService, h // equivalent Kra guards avoids persisting rejected unauthenticated or // unauthorized requests as successful business operations. private.Use(servermiddleware.Auth(auth), servermiddleware.MustChangePassword(), servermiddleware.AccessControl(runtime, access), servermiddleware.OperationAudit(runtime, audit)) - serverrouter.RegisterUser(private, handlers.User) - serverrouter.RegisterNavigation(private, handlers.Navigation) - serverrouter.RegisterSession(private, handlers.Session) - serverrouter.RegisterAuthority(private, handlers.Authority) - serverrouter.RegisterMenu(private, handlers.Menu) - serverrouter.RegisterAPI(private, public, engine, handlers.API) - serverrouter.RegisterPermission(private, handlers.Permission) - serverrouter.RegisterOrganization(private, handlers.Organization) - serverrouter.RegisterDictionary(private, handlers.Dictionary) - serverrouter.RegisterParameter(private, handlers.Parameter) - serverrouter.RegisterAPIToken(private, handlers.APIToken) - serverrouter.RegisterSystemConfig(private, handlers.SystemConfig) - serverrouter.RegisterVersion(private, handlers.Version) - serverrouter.RegisterExport(private, public, handlers.Export) - serverrouter.RegisterAudit(private, public, handlers.Audit) - serverrouter.RegisterTask(private, handlers.Task) - serverrouter.RegisterMedia(private, handlers.Media) - serverrouter.RegisterAnnouncement(private, public, handlers.Announcement) - serverrouter.RegisterEmail(private, handlers.Email) - serverrouter.RegisterPayment(private, public, handlers.Payment) + if routes != nil { + routes.RegisterRoutes(public, private, engine) + } registerSwagger(engine, prefix, version, logger) registerLocalStorage(engine, runtime) diff --git a/internal/modules/system/transport/server/gin_test.go b/app/admin/server/gin_test.go similarity index 99% rename from internal/modules/system/transport/server/gin_test.go rename to app/admin/server/gin_test.go index 8bbd43a..4a8b3cc 100644 --- a/internal/modules/system/transport/server/gin_test.go +++ b/app/admin/server/gin_test.go @@ -11,8 +11,8 @@ import ( "strings" "testing" + "kra/app/system/transport/handler" "kra/internal/conf" - "kra/internal/modules/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/server/swagger.go b/app/admin/server/swagger.go similarity index 99% rename from internal/modules/system/transport/server/swagger.go rename to app/admin/server/swagger.go index ac02735..951c2c0 100644 --- a/internal/modules/system/transport/server/swagger.go +++ b/app/admin/server/swagger.go @@ -8,7 +8,7 @@ import ( "strings" "sync" - "kra/internal/modules/system/routeinfo" + "kra/app/system/routeinfo" "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" diff --git a/internal/modules/system/README.md b/app/system/README.md similarity index 69% rename from internal/modules/system/README.md rename to app/system/README.md index 8be54b6..0bb148a 100644 --- a/internal/modules/system/README.md +++ b/app/system/README.md @@ -14,3 +14,8 @@ 系统表统一使用 `sys_` 前缀;业务表应由新业务模块自行命名和迁移,不要混入 本目录。 + +system 通过 `Definition()` 提供自己的迁移、支付菜单/API 和默认任务,通过 +`worker.TaskMethods` 提供依赖系统用例的任务实现,通过 `transport/server.Routes` +提供路由。应用组合根消费这些公共协议;新增业务不需要修改 system 的初始化、 +worker、路由或数据层。 diff --git a/internal/modules/system/biz/access_control.go b/app/system/biz/access_control.go similarity index 100% rename from internal/modules/system/biz/access_control.go rename to app/system/biz/access_control.go diff --git a/internal/modules/system/biz/actor.go b/app/system/biz/actor.go similarity index 100% rename from internal/modules/system/biz/actor.go rename to app/system/biz/actor.go diff --git a/internal/modules/system/biz/announcement.go b/app/system/biz/announcement.go similarity index 100% rename from internal/modules/system/biz/announcement.go rename to app/system/biz/announcement.go diff --git a/internal/modules/system/biz/api.go b/app/system/biz/api.go similarity index 100% rename from internal/modules/system/biz/api.go rename to app/system/biz/api.go diff --git a/internal/modules/system/biz/api_token.go b/app/system/biz/api_token.go similarity index 100% rename from internal/modules/system/biz/api_token.go rename to app/system/biz/api_token.go diff --git a/internal/modules/system/biz/audit.go b/app/system/biz/audit.go similarity index 100% rename from internal/modules/system/biz/audit.go rename to app/system/biz/audit.go diff --git a/internal/modules/system/biz/authentication.go b/app/system/biz/authentication.go similarity index 100% rename from internal/modules/system/biz/authentication.go rename to app/system/biz/authentication.go diff --git a/internal/modules/system/biz/authentication_test.go b/app/system/biz/authentication_test.go similarity index 100% rename from internal/modules/system/biz/authentication_test.go rename to app/system/biz/authentication_test.go diff --git a/internal/modules/system/biz/authority.go b/app/system/biz/authority.go similarity index 100% rename from internal/modules/system/biz/authority.go rename to app/system/biz/authority.go diff --git a/internal/modules/system/biz/biz.go b/app/system/biz/biz.go similarity index 73% rename from internal/modules/system/biz/biz.go rename to app/system/biz/biz.go index e4a4b57..0df3048 100644 --- a/internal/modules/system/biz/biz.go +++ b/app/system/biz/biz.go @@ -3,4 +3,4 @@ package biz import "github.com/google/wire" // ProviderSet is biz providers. -var ProviderSet = wire.NewSet(NewUserUsecase, NewAuthenticationUsecase, NewSystemConfigUsecase, NewAuthorityUsecase, NewAPIUsecase, NewPermissionUsecase, NewAccessControlUsecase, NewMenuUsecase, NewDepartmentUsecase, NewPositionUsecase, NewDictionaryUsecase, NewParameterUsecase, NewTokenUsecase, NewSecurityUsecase, NewVersionUsecase, NewExportUsecase, NewAuditUsecase, NewAuditRecorderUsecase, NewLogViewerUsecase, NewTaskUsecase, NewTaskApplicationUsecase, NewMediaUsecase, NewAnnouncementUsecase, NewEmailUsecase, NewPaymentUsecase) +var ProviderSet = wire.NewSet(NewUserUsecase, NewAuthenticationUsecase, NewSystemConfigUsecase, NewAuthorityUsecase, NewAPIUsecase, NewPermissionUsecase, NewAccessControlUsecase, NewMenuUsecase, NewDepartmentUsecase, NewPositionUsecase, NewDictionaryUsecase, NewParameterUsecase, NewTokenUsecase, NewSecurityUsecase, NewVersionUsecase, NewExportUsecase, NewAuditUsecase, NewAuditRecorderUsecase, NewLogViewerUsecase, NewTaskUsecaseWithRegistry, NewTaskApplicationUsecase, NewMediaUsecase, NewAnnouncementUsecase, NewEmailUsecase, NewPaymentUsecase) diff --git a/internal/modules/system/biz/data_scope.go b/app/system/biz/data_scope.go similarity index 100% rename from internal/modules/system/biz/data_scope.go rename to app/system/biz/data_scope.go diff --git a/internal/modules/system/biz/department.go b/app/system/biz/department.go similarity index 100% rename from internal/modules/system/biz/department.go rename to app/system/biz/department.go diff --git a/internal/modules/system/biz/dictionary.go b/app/system/biz/dictionary.go similarity index 100% rename from internal/modules/system/biz/dictionary.go rename to app/system/biz/dictionary.go diff --git a/internal/modules/system/biz/email.go b/app/system/biz/email.go similarity index 100% rename from internal/modules/system/biz/email.go rename to app/system/biz/email.go diff --git a/internal/modules/system/biz/errors.go b/app/system/biz/errors.go similarity index 100% rename from internal/modules/system/biz/errors.go rename to app/system/biz/errors.go diff --git a/internal/modules/system/biz/export.go b/app/system/biz/export.go similarity index 100% rename from internal/modules/system/biz/export.go rename to app/system/biz/export.go diff --git a/internal/modules/system/biz/infrastructure.go b/app/system/biz/infrastructure.go similarity index 100% rename from internal/modules/system/biz/infrastructure.go rename to app/system/biz/infrastructure.go diff --git a/internal/modules/system/biz/media.go b/app/system/biz/media.go similarity index 100% rename from internal/modules/system/biz/media.go rename to app/system/biz/media.go diff --git a/internal/modules/system/biz/media_metadata.go b/app/system/biz/media_metadata.go similarity index 100% rename from internal/modules/system/biz/media_metadata.go rename to app/system/biz/media_metadata.go diff --git a/internal/modules/system/biz/media_test.go b/app/system/biz/media_test.go similarity index 100% rename from internal/modules/system/biz/media_test.go rename to app/system/biz/media_test.go diff --git a/internal/modules/system/biz/media_upload.go b/app/system/biz/media_upload.go similarity index 100% rename from internal/modules/system/biz/media_upload.go rename to app/system/biz/media_upload.go diff --git a/internal/modules/system/biz/menu.go b/app/system/biz/menu.go similarity index 100% rename from internal/modules/system/biz/menu.go rename to app/system/biz/menu.go diff --git a/internal/modules/system/biz/pagination.go b/app/system/biz/pagination.go similarity index 100% rename from internal/modules/system/biz/pagination.go rename to app/system/biz/pagination.go diff --git a/internal/modules/system/biz/parameter.go b/app/system/biz/parameter.go similarity index 100% rename from internal/modules/system/biz/parameter.go rename to app/system/biz/parameter.go diff --git a/internal/modules/system/biz/payment.go b/app/system/biz/payment.go similarity index 100% rename from internal/modules/system/biz/payment.go rename to app/system/biz/payment.go diff --git a/internal/modules/system/biz/payment_log.go b/app/system/biz/payment_log.go similarity index 100% rename from internal/modules/system/biz/payment_log.go rename to app/system/biz/payment_log.go diff --git a/internal/modules/system/biz/payment_order.go b/app/system/biz/payment_order.go similarity index 100% rename from internal/modules/system/biz/payment_order.go rename to app/system/biz/payment_order.go diff --git a/internal/modules/system/biz/payment_test.go b/app/system/biz/payment_test.go similarity index 100% rename from internal/modules/system/biz/payment_test.go rename to app/system/biz/payment_test.go diff --git a/internal/modules/system/biz/permission.go b/app/system/biz/permission.go similarity index 100% rename from internal/modules/system/biz/permission.go rename to app/system/biz/permission.go diff --git a/internal/modules/system/biz/position.go b/app/system/biz/position.go similarity index 100% rename from internal/modules/system/biz/position.go rename to app/system/biz/position.go diff --git a/internal/modules/system/biz/security.go b/app/system/biz/security.go similarity index 100% rename from internal/modules/system/biz/security.go rename to app/system/biz/security.go diff --git a/internal/modules/system/biz/security_test.go b/app/system/biz/security_test.go similarity index 100% rename from internal/modules/system/biz/security_test.go rename to app/system/biz/security_test.go diff --git a/internal/modules/system/biz/system_init.go b/app/system/biz/system_init.go similarity index 100% rename from internal/modules/system/biz/system_init.go rename to app/system/biz/system_init.go diff --git a/internal/modules/system/biz/task.go b/app/system/biz/task.go similarity index 90% rename from internal/modules/system/biz/task.go rename to app/system/biz/task.go index 747e858..d60680a 100644 --- a/internal/modules/system/biz/task.go +++ b/app/system/biz/task.go @@ -72,9 +72,23 @@ type TaskRuntime interface { Unsubscribe(uint, chan []byte) } -type TaskUsecase struct{ TaskRepo } +type TaskUsecase struct { + TaskRepo + methods TaskMethodRegistry +} -func NewTaskUsecase(repo TaskRepo) *TaskUsecase { return &TaskUsecase{TaskRepo: repo} } +func NewTaskUsecase(repo TaskRepo) *TaskUsecase { + return NewTaskUsecaseWithRegistry(repo, DefaultTaskMethodRegistry()) +} + +func NewTaskUsecaseWithRegistry(repo TaskRepo, methods TaskMethodRegistry) *TaskUsecase { + if methods == nil { + methods = DefaultTaskMethodRegistry() + } + return &TaskUsecase{TaskRepo: repo, methods: methods} +} + +func (uc *TaskUsecase) RegisteredMethods() []TaskMethod { return uc.methods.List() } func (uc *TaskUsecase) Validate(value *TimedTask) error { if value.Name == "" { @@ -91,7 +105,7 @@ func (uc *TaskUsecase) Validate(value *TimedTask) error { } switch value.ExecutorType { case TaskExecutorMethod: - if !registeredTaskMethod(value.MethodName) { + if _, ok := uc.methods.Lookup(value.MethodName); !ok { return fmt.Errorf("方法 %s 未注册", value.MethodName) } if len(value.Params) > 0 && !json.Valid(value.Params) { @@ -154,6 +168,10 @@ func NewTaskApplicationUsecase(tasks *TaskUsecase, runtime TaskRuntime) *TaskApp return &TaskApplicationUsecase{tasks: tasks, runtime: runtime} } +func (uc *TaskApplicationUsecase) RegisteredMethods() []TaskMethod { + return uc.tasks.RegisteredMethods() +} + func (uc *TaskApplicationUsecase) syncRuntime(ctx context.Context, id uint) error { if ctx == nil { ctx = context.Background() diff --git a/app/system/biz/task_registry.go b/app/system/biz/task_registry.go new file mode 100644 index 0000000..d92e322 --- /dev/null +++ b/app/system/biz/task_registry.go @@ -0,0 +1,28 @@ +package biz + +import platformtask "kra/pkg/task" + +type TaskMethodFunc = platformtask.MethodFunc +type TaskMethod = platformtask.Method + +type TaskMethodRegistry interface { + Register(platformtask.Method) + Lookup(string) (TaskMethodFunc, bool) + List() []TaskMethod +} + +var defaultTaskMethods = platformtask.NewRegistry() + +// RegisterTaskMethod remains as a compatibility helper for tests and callers +// that have not moved to constructor injection yet. +func RegisterTaskMethod(name, description string, fn TaskMethodFunc) { + defaultTaskMethods.Register(platformtask.Method{Name: name, Description: description, Run: fn}) +} + +func TaskMethodByName(name string) (TaskMethodFunc, bool) { + return defaultTaskMethods.Lookup(name) +} + +func RegisteredTaskMethods() []TaskMethod { return defaultTaskMethods.List() } + +func DefaultTaskMethodRegistry() TaskMethodRegistry { return defaultTaskMethods } diff --git a/internal/modules/system/biz/task_test.go b/app/system/biz/task_test.go similarity index 100% rename from internal/modules/system/biz/task_test.go rename to app/system/biz/task_test.go diff --git a/internal/modules/system/biz/upload_session.go b/app/system/biz/upload_session.go similarity index 100% rename from internal/modules/system/biz/upload_session.go rename to app/system/biz/upload_session.go diff --git a/internal/modules/system/biz/user.go b/app/system/biz/user.go similarity index 100% rename from internal/modules/system/biz/user.go rename to app/system/biz/user.go diff --git a/internal/modules/system/biz/user_test.go b/app/system/biz/user_test.go similarity index 100% rename from internal/modules/system/biz/user_test.go rename to app/system/biz/user_test.go diff --git a/internal/modules/system/biz/version.go b/app/system/biz/version.go similarity index 100% rename from internal/modules/system/biz/version.go rename to app/system/biz/version.go diff --git a/internal/modules/system/data/config_helpers.go b/app/system/data/config_helpers.go similarity index 100% rename from internal/modules/system/data/config_helpers.go rename to app/system/data/config_helpers.go diff --git a/internal/modules/system/data/config_store.go b/app/system/data/config_store.go similarity index 99% rename from internal/modules/system/data/config_store.go rename to app/system/data/config_store.go index 6ac18eb..41f16c0 100644 --- a/internal/modules/system/data/config_store.go +++ b/app/system/data/config_store.go @@ -9,8 +9,8 @@ import ( "path/filepath" "strconv" + "kra/app/system/integration/storage" "kra/internal/conf" - "kra/internal/modules/system/integration/storage" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" @@ -351,7 +351,7 @@ func (d *Data) reloadConfig(ctx context.Context) error { } } if databaseReady && (next.Admin.System == nil || !next.Admin.System.DisableAutoMigrate) { - if err = migrateAll(candidateDB.WithContext(ctx)); err != nil { + if err = migrateAll(candidateDB.WithContext(ctx), d.catalog); err != nil { return fmt.Errorf("reload database migrations: %w", err) } } diff --git a/internal/modules/system/data/config_watch.go b/app/system/data/config_watch.go similarity index 100% rename from internal/modules/system/data/config_watch.go rename to app/system/data/config_watch.go diff --git a/internal/modules/system/data/data.go b/app/system/data/data.go similarity index 96% rename from internal/modules/system/data/data.go rename to app/system/data/data.go index db636d7..fae521d 100644 --- a/internal/modules/system/data/data.go +++ b/app/system/data/data.go @@ -11,10 +11,11 @@ import ( "github.com/google/wire" "github.com/redis/go-redis/v9" "gorm.io/gorm" + datapayment "kra/app/system/data/payment" + datasystem "kra/app/system/data/repository" + "kra/app/system/integration/storage" "kra/internal/conf" - datapayment "kra/internal/modules/system/data/payment" - datasystem "kra/internal/modules/system/data/repository" - "kra/internal/modules/system/integration/storage" + "kra/pkg/module" ) var ProviderSet = wire.NewSet( @@ -44,6 +45,7 @@ type Data struct { dbList map[string]*gorm.DB appLogger *slog.Logger auditLog *dataScopeAuditWriter + catalog module.Catalog } // DB exposes the active primary database to narrowly scoped data submodules. @@ -139,7 +141,7 @@ func (d *Data) database(name string) (*gorm.DB, error) { return db, nil } -func NewData(runtime *conf.Runtime, appLogger *slog.Logger, storageManager *storage.Reloadable) (*Data, func(), error) { +func NewData(runtime *conf.Runtime, appLogger *slog.Logger, storageManager *storage.Reloadable, catalog module.Catalog) (*Data, func(), error) { if appLogger == nil { appLogger = slog.Default() } @@ -153,7 +155,7 @@ func NewData(runtime *conf.Runtime, appLogger *slog.Logger, storageManager *stor // and /init/initdb remain available. c.Database = &conf.Data_Database{} } - d := &Data{runtime: runtime, appLogger: appLogger, storage: storageManager} + d := &Data{runtime: runtime, appLogger: appLogger, storage: storageManager, catalog: catalog} usingFallback := !databaseConnectionConfigured(c.Database) var db *gorm.DB var err error @@ -190,7 +192,7 @@ func NewData(runtime *conf.Runtime, appLogger *slog.Logger, storageManager *stor } disableAutoMigrate := admin.System != nil && admin.System.DisableAutoMigrate if !usingFallback && !disableAutoMigrate { - if err = migrateAll(db); err != nil { + if err = migrateAll(db, catalog); err != nil { return nil, nil, fmt.Errorf("migrate tables: %w", err) } } diff --git a/internal/modules/system/data/data_scope.go b/app/system/data/data_scope.go similarity index 99% rename from internal/modules/system/data/data_scope.go rename to app/system/data/data_scope.go index a6ed497..ae1a638 100644 --- a/internal/modules/system/data/data_scope.go +++ b/app/system/data/data_scope.go @@ -7,7 +7,7 @@ import ( "reflect" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" "gorm.io/gorm/clause" diff --git a/internal/modules/system/data/data_scope_audit.go b/app/system/data/data_scope_audit.go similarity index 100% rename from internal/modules/system/data/data_scope_audit.go rename to app/system/data/data_scope_audit.go diff --git a/internal/modules/system/data/data_scope_audit_test.go b/app/system/data/data_scope_audit_test.go similarity index 100% rename from internal/modules/system/data/data_scope_audit_test.go rename to app/system/data/data_scope_audit_test.go diff --git a/internal/modules/system/data/data_scope_record.go b/app/system/data/data_scope_record.go similarity index 100% rename from internal/modules/system/data/data_scope_record.go rename to app/system/data/data_scope_record.go diff --git a/internal/modules/system/data/data_scope_test.go b/app/system/data/data_scope_test.go similarity index 98% rename from internal/modules/system/data/data_scope_test.go rename to app/system/data/data_scope_test.go index 27e077e..def5769 100644 --- a/internal/modules/system/data/data_scope_test.go +++ b/app/system/data/data_scope_test.go @@ -5,7 +5,7 @@ import ( "errors" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/database.go b/app/system/data/database.go similarity index 99% rename from internal/modules/system/data/database.go rename to app/system/data/database.go index 91cb638..350450b 100644 --- a/internal/modules/system/data/database.go +++ b/app/system/data/database.go @@ -20,7 +20,7 @@ import ( "gorm.io/gorm/logger" "gorm.io/gorm/schema" "kra/internal/conf" - "kra/internal/platform/database/gormkit" + "kra/pkg/database/gormkit" ) var databaseNamePattern = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9_$-]*$`) diff --git a/internal/modules/system/data/gorm_logger_test.go b/app/system/data/gorm_logger_test.go similarity index 96% rename from internal/modules/system/data/gorm_logger_test.go rename to app/system/data/gorm_logger_test.go index 7444afd..40c3e6d 100644 --- a/internal/modules/system/data/gorm_logger_test.go +++ b/app/system/data/gorm_logger_test.go @@ -9,7 +9,7 @@ import ( "time" "kra/internal/logging" - "kra/internal/platform/database/gormkit" + "kra/pkg/database/gormkit" "gorm.io/gorm/logger" ) diff --git a/internal/modules/system/data/initialization_backend.go b/app/system/data/initialization_backend.go similarity index 98% rename from internal/modules/system/data/initialization_backend.go rename to app/system/data/initialization_backend.go index cadab84..5190d8c 100644 --- a/internal/modules/system/data/initialization_backend.go +++ b/app/system/data/initialization_backend.go @@ -5,9 +5,9 @@ import ( "errors" "fmt" + "kra/app/system/biz" + "kra/app/system/integration/storage" "kra/internal/conf" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/integration/storage" "github.com/google/uuid" "google.golang.org/protobuf/encoding/protojson" @@ -180,7 +180,7 @@ func (d *Data) InitializeDatabase(ctx context.Context, input *biz.DatabaseConfig } }() db := candidate.WithContext(ctx) - if err := migrateAll(db); err != nil { + if err := migrateAll(db, d.catalog); err != nil { return err } if seed != nil { diff --git a/internal/modules/system/data/initialization_backend_test.go b/app/system/data/initialization_backend_test.go similarity index 100% rename from internal/modules/system/data/initialization_backend_test.go rename to app/system/data/initialization_backend_test.go diff --git a/internal/modules/system/data/integration_config.go b/app/system/data/integration_config.go similarity index 100% rename from internal/modules/system/data/integration_config.go rename to app/system/data/integration_config.go diff --git a/internal/modules/system/data/integration_config_test.go b/app/system/data/integration_config_test.go similarity index 99% rename from internal/modules/system/data/integration_config_test.go rename to app/system/data/integration_config_test.go index e1eaf29..2e5c166 100644 --- a/internal/modules/system/data/integration_config_test.go +++ b/app/system/data/integration_config_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" + "kra/app/system/integration/storage" "kra/internal/conf" - "kra/internal/modules/system/integration/storage" "google.golang.org/protobuf/encoding/protojson" "gopkg.in/yaml.v3" diff --git a/app/system/data/migrations.go b/app/system/data/migrations.go new file mode 100644 index 0000000..506eb4f --- /dev/null +++ b/app/system/data/migrations.go @@ -0,0 +1,32 @@ +package data + +import ( + datapayment "kra/app/system/data/payment" + datasystem "kra/app/system/data/repository" + "kra/pkg/database/migration" + "kra/pkg/module" + + "gorm.io/gorm" +) + +func InfrastructureMigrations() []migration.Step { + return []migration.Step{{ + ID: "202608200001_data_infrastructure", + Migrate: func(db *gorm.DB) error { + return migration.CreateMissingTables(db, &integrationConfigPO{}) + }, + }} +} + +// migrateAll is the single data-layer migration entry point. Module-specific +// schema work stays with the module that owns its persistent objects. +func migrateAll(db *gorm.DB, catalogs ...module.Catalog) error { + steps := InfrastructureMigrations() + if len(catalogs) > 0 && len(catalogs[0].MigrationSteps()) > 0 { + steps = append(steps, catalogs[0].MigrationSteps()...) + } else { + steps = append(steps, datasystem.Migrations()...) + steps = append(steps, datapayment.Migrations()...) + } + return migration.Run(db, steps) +} diff --git a/internal/modules/system/data/migrations_test.go b/app/system/data/migrations_test.go similarity index 95% rename from internal/modules/system/data/migrations_test.go rename to app/system/data/migrations_test.go index c3ac4a4..b7d2760 100644 --- a/internal/modules/system/data/migrations_test.go +++ b/app/system/data/migrations_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "kra/internal/platform/database/migration" + "kra/pkg/database/migration" ) func TestMigrateAllRunsModuleSchemasWithoutBootstrapSeed(t *testing.T) { diff --git a/internal/modules/system/data/mongo.go b/app/system/data/mongo.go similarity index 100% rename from internal/modules/system/data/mongo.go rename to app/system/data/mongo.go diff --git a/internal/modules/system/data/payment/migrations.go b/app/system/data/payment/migrations.go similarity index 58% rename from internal/modules/system/data/payment/migrations.go rename to app/system/data/payment/migrations.go index dbf0b66..f4a1090 100644 --- a/internal/modules/system/data/payment/migrations.go +++ b/app/system/data/payment/migrations.go @@ -1,8 +1,8 @@ package payment import ( - "kra/internal/modules/system/adminsurface" - "kra/internal/platform/database/migration" + "kra/pkg/database/migration" + platformmodule "kra/pkg/module" "gorm.io/gorm" ) @@ -19,17 +19,17 @@ func Migrations() []migration.Step { // AdminSurface describes the payment-owned entries shown in the system // administration UI. The system module persists these records because it owns // the menu/API/policy tables. -func AdminSurface() adminsurface.Surface { - return adminsurface.Surface{ - Menus: []adminsurface.Menu{ +func AdminSurface() platformmodule.Surface { + return platformmodule.Surface{ + Menus: []platformmodule.Menu{ {Name: "paymentOrders", Path: "paymentOrders", ParentName: "extensions", Component: "view/systemTools/payment/orders.vue", Title: "支付订单", Icon: "wallet", Sort: 6}, {Name: "paymentConfig", Path: "paymentConfig", ParentName: "extensions", Component: "view/systemTools/payment/config.vue", Title: "支付配置", Icon: "credit-card", Sort: 7}, }, - APIs: []adminsurface.API{ - {Path: "/payment/configs", Method: "GET", APIGroup: "支付", Description: "获取支付渠道配置"}, - {Path: "/payment/config", Method: "POST", APIGroup: "支付", Description: "保存支付渠道配置"}, - {Path: "/payment/orders", Method: "GET", APIGroup: "支付", Description: "分页查询支付订单"}, - {Path: "/payment/order", Method: "POST", APIGroup: "支付", Description: "查询支付订单"}, + APIs: []platformmodule.API{ + {Path: "/payment/configs", Method: "GET", Group: "支付", Description: "获取支付渠道配置"}, + {Path: "/payment/config", Method: "POST", Group: "支付", Description: "保存支付渠道配置"}, + {Path: "/payment/orders", Method: "GET", Group: "支付", Description: "分页查询支付订单"}, + {Path: "/payment/order", Method: "POST", Group: "支付", Description: "查询支付订单"}, }, } } diff --git a/internal/modules/system/data/payment/models.go b/app/system/data/payment/models.go similarity index 100% rename from internal/modules/system/data/payment/models.go rename to app/system/data/payment/models.go diff --git a/internal/modules/system/data/payment/payment.go b/app/system/data/payment/payment.go similarity index 99% rename from internal/modules/system/data/payment/payment.go rename to app/system/data/payment/payment.go index 493703d..a8a2026 100644 --- a/internal/modules/system/data/payment/payment.go +++ b/app/system/data/payment/payment.go @@ -11,8 +11,8 @@ import ( "strconv" "strings" - "kra/internal/modules/system/biz" - datapayment "kra/internal/modules/system/integration/payment" + "kra/app/system/biz" + datapayment "kra/app/system/integration/payment" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/payment/payment_config_test.go b/app/system/data/payment/payment_config_test.go similarity index 99% rename from internal/modules/system/data/payment/payment_config_test.go rename to app/system/data/payment/payment_config_test.go index 1c82540..4995319 100644 --- a/internal/modules/system/data/payment/payment_config_test.go +++ b/app/system/data/payment/payment_config_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestSavePaymentConfigRequiresDouyinAppIDWhenEnabled(t *testing.T) { diff --git a/internal/modules/system/data/payment/payment_helpers.go b/app/system/data/payment/payment_helpers.go similarity index 91% rename from internal/modules/system/data/payment/payment_helpers.go rename to app/system/data/payment/payment_helpers.go index b55d929..a050003 100644 --- a/internal/modules/system/data/payment/payment_helpers.go +++ b/app/system/data/payment/payment_helpers.go @@ -1,6 +1,6 @@ package payment -import "kra/internal/modules/system/utils/paymentutil" +import "kra/app/system/utils/paymentutil" func text(values map[string]any, key string) string { value, _ := values[key].(string) diff --git a/internal/modules/system/data/payment/payment_native_test.go b/app/system/data/payment/payment_native_test.go similarity index 99% rename from internal/modules/system/data/payment/payment_native_test.go rename to app/system/data/payment/payment_native_test.go index 5ec1513..6e96e5e 100644 --- a/internal/modules/system/data/payment/payment_native_test.go +++ b/app/system/data/payment/payment_native_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestMigrateSeedsPaymentProviders(t *testing.T) { diff --git a/internal/modules/system/data/payment/payment_order.go b/app/system/data/payment/payment_order.go similarity index 99% rename from internal/modules/system/data/payment/payment_order.go rename to app/system/data/payment/payment_order.go index 420e3be..8839ac3 100644 --- a/internal/modules/system/data/payment/payment_order.go +++ b/app/system/data/payment/payment_order.go @@ -10,8 +10,8 @@ import ( "github.com/google/uuid" "gorm.io/gorm" "gorm.io/gorm/clause" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" ) type paymentOrderPO struct { diff --git a/internal/modules/system/data/payment/payment_order_test.go b/app/system/data/payment/payment_order_test.go similarity index 99% rename from internal/modules/system/data/payment/payment_order_test.go rename to app/system/data/payment/payment_order_test.go index 23ab522..ef6fbf2 100644 --- a/internal/modules/system/data/payment/payment_order_test.go +++ b/app/system/data/payment/payment_order_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func newPaymentOrderRepoForTest(t *testing.T) *paymentOrderRepo { diff --git a/internal/modules/system/data/payment/provider.go b/app/system/data/payment/provider.go similarity index 100% rename from internal/modules/system/data/payment/provider.go rename to app/system/data/payment/provider.go diff --git a/internal/modules/system/data/payment/testing_support_test.go b/app/system/data/payment/testing_support_test.go similarity index 100% rename from internal/modules/system/data/payment/testing_support_test.go rename to app/system/data/payment/testing_support_test.go diff --git a/internal/modules/system/data/repository/announcement.go b/app/system/data/repository/announcement.go similarity index 96% rename from internal/modules/system/data/repository/announcement.go rename to app/system/data/repository/announcement.go index 05ac9dc..b2640d5 100644 --- a/internal/modules/system/data/repository/announcement.go +++ b/app/system/data/repository/announcement.go @@ -5,9 +5,9 @@ import ( "encoding/json" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/gormkit" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/gormkit" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/announcement_test.go b/app/system/data/repository/announcement_test.go similarity index 97% rename from internal/modules/system/data/repository/announcement_test.go rename to app/system/data/repository/announcement_test.go index e137db5..9ce0c3d 100644 --- a/internal/modules/system/data/repository/announcement_test.go +++ b/app/system/data/repository/announcement_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestAnnouncementRepositoryKeepsRawIDQuerySemantics(t *testing.T) { diff --git a/internal/modules/system/data/repository/api.go b/app/system/data/repository/api.go similarity index 98% rename from internal/modules/system/data/repository/api.go rename to app/system/data/repository/api.go index be92789..2c14f48 100644 --- a/internal/modules/system/data/repository/api.go +++ b/app/system/data/repository/api.go @@ -6,8 +6,8 @@ import ( "strconv" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/api_policy.go b/app/system/data/repository/api_policy.go similarity index 99% rename from internal/modules/system/data/repository/api_policy.go rename to app/system/data/repository/api_policy.go index e4f0617..b60a25a 100644 --- a/internal/modules/system/data/repository/api_policy.go +++ b/app/system/data/repository/api_policy.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/casbin/casbin/v3" casbinmodel "github.com/casbin/casbin/v3/model" diff --git a/internal/modules/system/data/repository/api_policy_test.go b/app/system/data/repository/api_policy_test.go similarity index 99% rename from internal/modules/system/data/repository/api_policy_test.go rename to app/system/data/repository/api_policy_test.go index 90ea4db..375dadc 100644 --- a/internal/modules/system/data/repository/api_policy_test.go +++ b/app/system/data/repository/api_policy_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) func newPolicyTestData(t *testing.T) *Data { diff --git a/internal/modules/system/data/repository/api_sync.go b/app/system/data/repository/api_sync.go similarity index 98% rename from internal/modules/system/data/repository/api_sync.go rename to app/system/data/repository/api_sync.go index d17ea9c..e0d1237 100644 --- a/internal/modules/system/data/repository/api_sync.go +++ b/app/system/data/repository/api_sync.go @@ -3,7 +3,7 @@ package system import ( "context" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/api_token.go b/app/system/data/repository/api_token.go similarity index 98% rename from internal/modules/system/data/repository/api_token.go rename to app/system/data/repository/api_token.go index 522e1ca..558717a 100644 --- a/internal/modules/system/data/repository/api_token.go +++ b/app/system/data/repository/api_token.go @@ -5,8 +5,8 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/audit.go b/app/system/data/repository/audit.go similarity index 91% rename from internal/modules/system/data/repository/audit.go rename to app/system/data/repository/audit.go index 7c6d3cf..e07ea56 100644 --- a/internal/modules/system/data/repository/audit.go +++ b/app/system/data/repository/audit.go @@ -1,6 +1,6 @@ package system -import "kra/internal/modules/system/biz" +import "kra/app/system/biz" type auditQueryRepo struct{ data Provider } type auditRecorderRepo struct{ data Provider } diff --git a/internal/modules/system/data/repository/audit_delete_test.go b/app/system/data/repository/audit_delete_test.go similarity index 100% rename from internal/modules/system/data/repository/audit_delete_test.go rename to app/system/data/repository/audit_delete_test.go diff --git a/internal/modules/system/data/repository/authority.go b/app/system/data/repository/authority.go similarity index 99% rename from internal/modules/system/data/repository/authority.go rename to app/system/data/repository/authority.go index 5625da4..392f303 100644 --- a/internal/modules/system/data/repository/authority.go +++ b/app/system/data/repository/authority.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/authority_test.go b/app/system/data/repository/authority_test.go similarity index 99% rename from internal/modules/system/data/repository/authority_test.go rename to app/system/data/repository/authority_test.go index 73c7761..9d336cd 100644 --- a/internal/modules/system/data/repository/authority_test.go +++ b/app/system/data/repository/authority_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/bootstrap.go b/app/system/data/repository/bootstrap.go similarity index 100% rename from internal/modules/system/data/repository/bootstrap.go rename to app/system/data/repository/bootstrap.go diff --git a/internal/modules/system/data/repository/casbin.go b/app/system/data/repository/casbin.go similarity index 100% rename from internal/modules/system/data/repository/casbin.go rename to app/system/data/repository/casbin.go diff --git a/internal/modules/system/data/repository/data_access_log.go b/app/system/data/repository/data_access_log.go similarity index 96% rename from internal/modules/system/data/repository/data_access_log.go rename to app/system/data/repository/data_access_log.go index b52c6a1..f5a41cd 100644 --- a/internal/modules/system/data/repository/data_access_log.go +++ b/app/system/data/repository/data_access_log.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/department.go b/app/system/data/repository/department.go similarity index 99% rename from internal/modules/system/data/repository/department.go rename to app/system/data/repository/department.go index dd41eeb..d0ff44a 100644 --- a/internal/modules/system/data/repository/department.go +++ b/app/system/data/repository/department.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/dictionary.go b/app/system/data/repository/dictionary.go similarity index 99% rename from internal/modules/system/data/repository/dictionary.go rename to app/system/data/repository/dictionary.go index 8959170..fc7eae5 100644 --- a/internal/modules/system/data/repository/dictionary.go +++ b/app/system/data/repository/dictionary.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/dictionary_department_parity_test.go b/app/system/data/repository/dictionary_department_parity_test.go similarity index 99% rename from internal/modules/system/data/repository/dictionary_department_parity_test.go rename to app/system/data/repository/dictionary_department_parity_test.go index 777a8cc..37f03aa 100644 --- a/internal/modules/system/data/repository/dictionary_department_parity_test.go +++ b/app/system/data/repository/dictionary_department_parity_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestDictionaryListPreservesPreloadCollectionShapes(t *testing.T) { diff --git a/internal/modules/system/data/repository/error_record.go b/app/system/data/repository/error_record.go similarity index 97% rename from internal/modules/system/data/repository/error_record.go rename to app/system/data/repository/error_record.go index 33b95f4..00a3b8f 100644 --- a/internal/modules/system/data/repository/error_record.go +++ b/app/system/data/repository/error_record.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/error_record_test.go b/app/system/data/repository/error_record_test.go similarity index 99% rename from internal/modules/system/data/repository/error_record_test.go rename to app/system/data/repository/error_record_test.go index 9237f9f..78171af 100644 --- a/internal/modules/system/data/repository/error_record_test.go +++ b/app/system/data/repository/error_record_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func errorString(value string) *string { return &value } diff --git a/internal/modules/system/data/repository/export.go b/app/system/data/repository/export.go similarity index 99% rename from internal/modules/system/data/repository/export.go rename to app/system/data/repository/export.go index d30c595..ad6b04e 100644 --- a/internal/modules/system/data/repository/export.go +++ b/app/system/data/repository/export.go @@ -7,7 +7,7 @@ import ( "fmt" "gorm.io/gorm" "gorm.io/gorm/clause" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "strconv" "strings" "time" diff --git a/internal/modules/system/data/repository/log_file.go b/app/system/data/repository/log_file.go similarity index 99% rename from internal/modules/system/data/repository/log_file.go rename to app/system/data/repository/log_file.go index 540bf45..690c0f5 100644 --- a/internal/modules/system/data/repository/log_file.go +++ b/app/system/data/repository/log_file.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) const ( diff --git a/internal/modules/system/data/repository/log_file_test.go b/app/system/data/repository/log_file_test.go similarity index 97% rename from internal/modules/system/data/repository/log_file_test.go rename to app/system/data/repository/log_file_test.go index 46f5565..d9f8efc 100644 --- a/internal/modules/system/data/repository/log_file_test.go +++ b/app/system/data/repository/log_file_test.go @@ -7,8 +7,8 @@ import ( "path/filepath" "testing" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) func TestLogViewerReadsNestedCategoryFiles(t *testing.T) { diff --git a/internal/modules/system/data/repository/login_log.go b/app/system/data/repository/login_log.go similarity index 96% rename from internal/modules/system/data/repository/login_log.go rename to app/system/data/repository/login_log.go index a4ca46b..9c30d59 100644 --- a/internal/modules/system/data/repository/login_log.go +++ b/app/system/data/repository/login_log.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/media.go b/app/system/data/repository/media.go similarity index 99% rename from internal/modules/system/data/repository/media.go rename to app/system/data/repository/media.go index 1144c95..2b6c824 100644 --- a/internal/modules/system/data/repository/media.go +++ b/app/system/data/repository/media.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/media_test.go b/app/system/data/repository/media_test.go similarity index 95% rename from internal/modules/system/data/repository/media_test.go rename to app/system/data/repository/media_test.go index 6f8a349..e9394dd 100644 --- a/internal/modules/system/data/repository/media_test.go +++ b/app/system/data/repository/media_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestMediaListKeepsZeroPageSizeContract(t *testing.T) { diff --git a/internal/modules/system/data/repository/media_upload.go b/app/system/data/repository/media_upload.go similarity index 99% rename from internal/modules/system/data/repository/media_upload.go rename to app/system/data/repository/media_upload.go index 822a7f3..b4484b5 100644 --- a/internal/modules/system/data/repository/media_upload.go +++ b/app/system/data/repository/media_upload.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" "gorm.io/gorm/clause" diff --git a/internal/modules/system/data/repository/menu.go b/app/system/data/repository/menu.go similarity index 99% rename from internal/modules/system/data/repository/menu.go rename to app/system/data/repository/menu.go index 8b11c2f..c2635f4 100644 --- a/internal/modules/system/data/repository/menu.go +++ b/app/system/data/repository/menu.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/menu_test.go b/app/system/data/repository/menu_test.go similarity index 99% rename from internal/modules/system/data/repository/menu_test.go rename to app/system/data/repository/menu_test.go index a4036e5..b2f4d36 100644 --- a/internal/modules/system/data/repository/menu_test.go +++ b/app/system/data/repository/menu_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) func newMenuTestData(t *testing.T) *Data { diff --git a/internal/modules/system/data/repository/migrations.go b/app/system/data/repository/migrations.go similarity index 96% rename from internal/modules/system/data/repository/migrations.go rename to app/system/data/repository/migrations.go index c98ae77..c5269e0 100644 --- a/internal/modules/system/data/repository/migrations.go +++ b/app/system/data/repository/migrations.go @@ -1,7 +1,7 @@ package system import ( - "kra/internal/platform/database/migration" + "kra/pkg/database/migration" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/migrations_test.go b/app/system/data/repository/migrations_test.go similarity index 100% rename from internal/modules/system/data/repository/migrations_test.go rename to app/system/data/repository/migrations_test.go diff --git a/internal/modules/system/data/repository/models.go b/app/system/data/repository/models.go similarity index 98% rename from internal/modules/system/data/repository/models.go rename to app/system/data/repository/models.go index f9dbb30..ac5edfd 100644 --- a/internal/modules/system/data/repository/models.go +++ b/app/system/data/repository/models.go @@ -3,7 +3,7 @@ package system import ( "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/operation_log.go b/app/system/data/repository/operation_log.go similarity index 97% rename from internal/modules/system/data/repository/operation_log.go rename to app/system/data/repository/operation_log.go index 8cdabe1..feb9afd 100644 --- a/internal/modules/system/data/repository/operation_log.go +++ b/app/system/data/repository/operation_log.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/organization_test.go b/app/system/data/repository/organization_test.go similarity index 100% rename from internal/modules/system/data/repository/organization_test.go rename to app/system/data/repository/organization_test.go diff --git a/internal/modules/system/data/repository/parameter.go b/app/system/data/repository/parameter.go similarity index 97% rename from internal/modules/system/data/repository/parameter.go rename to app/system/data/repository/parameter.go index 00c92d2..e2ceda1 100644 --- a/internal/modules/system/data/repository/parameter.go +++ b/app/system/data/repository/parameter.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "gorm.io/gorm" "gorm.io/gorm/clause" diff --git a/internal/modules/system/data/repository/parameter_test.go b/app/system/data/repository/parameter_test.go similarity index 98% rename from internal/modules/system/data/repository/parameter_test.go rename to app/system/data/repository/parameter_test.go index 3a259dc..10c6284 100644 --- a/internal/modules/system/data/repository/parameter_test.go +++ b/app/system/data/repository/parameter_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestParameterRepositoryPreservesModelMetadata(t *testing.T) { diff --git a/internal/modules/system/data/repository/permission.go b/app/system/data/repository/permission.go similarity index 99% rename from internal/modules/system/data/repository/permission.go rename to app/system/data/repository/permission.go index 297e98c..2e7cc30 100644 --- a/internal/modules/system/data/repository/permission.go +++ b/app/system/data/repository/permission.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/permission_test.go b/app/system/data/repository/permission_test.go similarity index 99% rename from internal/modules/system/data/repository/permission_test.go rename to app/system/data/repository/permission_test.go index 06c397d..c4ff916 100644 --- a/internal/modules/system/data/repository/permission_test.go +++ b/app/system/data/repository/permission_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) func TestPermissionSelectedButtonsEmptyShape(t *testing.T) { diff --git a/internal/modules/system/data/repository/position.go b/app/system/data/repository/position.go similarity index 99% rename from internal/modules/system/data/repository/position.go rename to app/system/data/repository/position.go index 8a4d0de..ba6cf32 100644 --- a/internal/modules/system/data/repository/position.go +++ b/app/system/data/repository/position.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/provider.go b/app/system/data/repository/provider.go similarity index 100% rename from internal/modules/system/data/repository/provider.go rename to app/system/data/repository/provider.go diff --git a/internal/modules/system/data/repository/runtime.go b/app/system/data/repository/runtime.go similarity index 98% rename from internal/modules/system/data/repository/runtime.go rename to app/system/data/repository/runtime.go index f709d49..b4ace01 100644 --- a/internal/modules/system/data/repository/runtime.go +++ b/app/system/data/repository/runtime.go @@ -6,9 +6,9 @@ import ( "errors" "time" + "kra/app/system/biz" + "kra/app/system/security/adminauth" "kra/internal/conf" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/security/adminauth" jwt "github.com/golang-jwt/jwt/v5" ) diff --git a/internal/modules/system/data/repository/security.go b/app/system/data/repository/security.go similarity index 99% rename from internal/modules/system/data/repository/security.go rename to app/system/data/repository/security.go index 49390d2..358fb76 100644 --- a/internal/modules/system/data/repository/security.go +++ b/app/system/data/repository/security.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/data/repository/seed.go b/app/system/data/repository/seed.go similarity index 84% rename from internal/modules/system/data/repository/seed.go rename to app/system/data/repository/seed.go index 69a12c8..5852cfa 100644 --- a/internal/modules/system/data/repository/seed.go +++ b/app/system/data/repository/seed.go @@ -5,15 +5,30 @@ import ( "strings" "time" - "kra/internal/modules/system/adminsurface" - "kra/internal/modules/system/biz" + "kra/app/system/biz" + platformmodule "kra/pkg/module" "github.com/google/uuid" "golang.org/x/crypto/bcrypt" "gorm.io/gorm" ) -func SeedSystem(ctx context.Context, db *gorm.DB, input *biz.DatabaseConfig, surfaces ...adminsurface.Surface) error { +func SeedSystem(ctx context.Context, db *gorm.DB, input *biz.DatabaseConfig, surfaces ...platformmodule.Surface) error { + return seedSystem(ctx, db, input, nil, surfaces...) +} + +// SeedSystemWithCatalog applies module-contributed administration surfaces and +// default timed tasks in one transaction. The system module remains the owner +// of the system tables, while other modules contribute through the catalog. +func SeedSystemWithCatalog(ctx context.Context, db *gorm.DB, input *biz.DatabaseConfig, catalog platformmodule.Catalog) error { + surfaces := make([]platformmodule.Surface, 0, len(catalog.Definitions)) + for _, definition := range catalog.Definitions { + surfaces = append(surfaces, definition.Surface) + } + return seedSystem(ctx, db, input, catalog.DefaultTimedTasks(), surfaces...) +} + +func seedSystem(ctx context.Context, db *gorm.DB, input *biz.DatabaseConfig, defaults []platformmodule.TimedTask, surfaces ...platformmodule.Surface) error { return db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { rootParentID := uint(0) authority := authorityPO{AuthorityID: 888, AuthorityName: "超级管理员", ParentID: &rootParentID, DataScope: 1, DefaultRouter: "dashboard"} @@ -97,7 +112,14 @@ func SeedSystem(ctx context.Context, db *gorm.DB, input *biz.DatabaseConfig, sur if err := tx.Where("template_id = ?", exportTemplate.TemplateID).FirstOrCreate(&exportTemplate).Error; err != nil { return err } - for _, task := range []taskPO{{Name: "ClearDB", Description: "定时清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Spec: "@daily", ExecutorType: "method", MethodName: "ClearDB", Enabled: true}, {Name: "CleanStaleUploads", Description: "定时清理过期大文件上传会话", Spec: "@hourly", ExecutorType: "method", MethodName: "CleanStaleUploads", Enabled: true}} { + var defaultTasks []taskPO + if defaults == nil { + defaultTasks = []taskPO{{Name: "ClearDB", Description: "定时清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Spec: "@daily", ExecutorType: "method", MethodName: "ClearDB", Enabled: true}, {Name: "CleanStaleUploads", Description: "定时清理过期大文件上传会话", Spec: "@hourly", ExecutorType: "method", MethodName: "CleanStaleUploads", Enabled: true}} + } + for _, item := range defaults { + defaultTasks = append(defaultTasks, taskPO{Name: item.Name, Description: item.Description, Spec: item.Spec, WithSeconds: item.WithSeconds, ExecutorType: "method", MethodName: item.MethodName, Enabled: item.Enabled}) + } + for _, task := range defaultTasks { if err := tx.Where("name = ?", task.Name).FirstOrCreate(&task).Error; err != nil { return err } @@ -146,7 +168,7 @@ func SeedSystem(ctx context.Context, db *gorm.DB, input *biz.DatabaseConfig, sur }) } -func seedAdminSurface(tx *gorm.DB, surface adminsurface.Surface) error { +func seedAdminSurface(tx *gorm.DB, surface platformmodule.Surface) error { for _, item := range surface.Menus { parentID := uint(0) if item.ParentName != "" { @@ -177,7 +199,7 @@ func seedAdminSurface(tx *gorm.DB, surface adminsurface.Surface) error { api := apiPO{ Path: item.Path, Method: strings.ToUpper(item.Method), - APIGroup: item.APIGroup, + APIGroup: item.Group, Description: item.Description, } if err := tx.Where("path = ? AND method = ?", api.Path, api.Method).FirstOrCreate(&api).Error; err != nil { diff --git a/internal/modules/system/data/repository/seed_test.go b/app/system/data/repository/seed_test.go similarity index 79% rename from internal/modules/system/data/repository/seed_test.go rename to app/system/data/repository/seed_test.go index 2c8bacf..223c3d9 100644 --- a/internal/modules/system/data/repository/seed_test.go +++ b/app/system/data/repository/seed_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "kra/internal/modules/system/adminsurface" - "kra/internal/modules/system/biz" + "kra/app/system/biz" + platformmodule "kra/pkg/module" ) func TestSeedSystemCreatesInitialDataAndModuleSurface(t *testing.T) { @@ -16,9 +16,9 @@ func TestSeedSystemCreatesInitialDataAndModuleSurface(t *testing.T) { if err = migrateAll(db); err != nil { t.Fatal(err) } - surface := adminsurface.Surface{ - Menus: []adminsurface.Menu{{Name: "orders", Path: "orders", ParentName: "extensions", Component: "view/orders.vue", Title: "订单", Sort: 6}}, - APIs: []adminsurface.API{{Path: "/orders", Method: "GET", APIGroup: "订单", Description: "订单列表"}}, + surface := platformmodule.Surface{ + Menus: []platformmodule.Menu{{Name: "orders", Path: "orders", ParentName: "extensions", Component: "view/orders.vue", Title: "订单", Sort: 6}}, + APIs: []platformmodule.API{{Path: "/orders", Method: "GET", Group: "订单", Description: "订单列表"}}, } input := &biz.DatabaseConfig{AdminPassword: "admin-password", APIs: []*biz.API{{Path: "/healthz", Method: "GET", APIGroup: "系统"}}} if err = SeedSystem(context.Background(), db, input, surface); err != nil { diff --git a/internal/modules/system/data/repository/system_init_ignore_test.go b/app/system/data/repository/system_init_ignore_test.go similarity index 100% rename from internal/modules/system/data/repository/system_init_ignore_test.go rename to app/system/data/repository/system_init_ignore_test.go diff --git a/internal/modules/system/data/repository/task.go b/app/system/data/repository/task.go similarity index 98% rename from internal/modules/system/data/repository/task.go rename to app/system/data/repository/task.go index 1a5a248..b03b177 100644 --- a/internal/modules/system/data/repository/task.go +++ b/app/system/data/repository/task.go @@ -2,9 +2,9 @@ package system import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/gormkit" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/gormkit" + "kra/pkg/database/pagination" "time" "gorm.io/gorm" diff --git a/internal/modules/system/data/repository/testing_support_test.go b/app/system/data/repository/testing_support_test.go similarity index 100% rename from internal/modules/system/data/repository/testing_support_test.go rename to app/system/data/repository/testing_support_test.go diff --git a/internal/modules/system/data/repository/transactions_test.go b/app/system/data/repository/transactions_test.go similarity index 99% rename from internal/modules/system/data/repository/transactions_test.go rename to app/system/data/repository/transactions_test.go index 12e95c3..a3f5a62 100644 --- a/internal/modules/system/data/repository/transactions_test.go +++ b/app/system/data/repository/transactions_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) func newTransactionTestData(t *testing.T) *Data { diff --git a/internal/modules/system/data/repository/user.go b/app/system/data/repository/user.go similarity index 99% rename from internal/modules/system/data/repository/user.go rename to app/system/data/repository/user.go index 3292a9b..5b866f9 100644 --- a/internal/modules/system/data/repository/user.go +++ b/app/system/data/repository/user.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" "github.com/google/uuid" "gorm.io/gorm" diff --git a/internal/modules/system/data/repository/user_strict_test.go b/app/system/data/repository/user_strict_test.go similarity index 99% rename from internal/modules/system/data/repository/user_strict_test.go rename to app/system/data/repository/user_strict_test.go index 63f54d4..f3b2467 100644 --- a/internal/modules/system/data/repository/user_strict_test.go +++ b/app/system/data/repository/user_strict_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func seedStrictUserTree(t *testing.T, data *Data) (actorID, childID, siblingID uint, users []userPO) { diff --git a/internal/modules/system/data/repository/version.go b/app/system/data/repository/version.go similarity index 99% rename from internal/modules/system/data/repository/version.go rename to app/system/data/repository/version.go index ab00ca3..ef79add 100644 --- a/internal/modules/system/data/repository/version.go +++ b/app/system/data/repository/version.go @@ -6,8 +6,8 @@ import ( "time" "gorm.io/gorm" - "kra/internal/modules/system/biz" - "kra/internal/platform/database/pagination" + "kra/app/system/biz" + "kra/pkg/database/pagination" ) type versionPO struct { diff --git a/internal/modules/system/data/repository/version_test.go b/app/system/data/repository/version_test.go similarity index 100% rename from internal/modules/system/data/repository/version_test.go rename to app/system/data/repository/version_test.go diff --git a/internal/modules/system/data/runtime_clients.go b/app/system/data/runtime_clients.go similarity index 100% rename from internal/modules/system/data/runtime_clients.go rename to app/system/data/runtime_clients.go diff --git a/internal/modules/system/dto/announcement.go b/app/system/dto/announcement.go similarity index 100% rename from internal/modules/system/dto/announcement.go rename to app/system/dto/announcement.go diff --git a/internal/modules/system/dto/api.go b/app/system/dto/api.go similarity index 100% rename from internal/modules/system/dto/api.go rename to app/system/dto/api.go diff --git a/internal/modules/system/dto/audit.go b/app/system/dto/audit.go similarity index 100% rename from internal/modules/system/dto/audit.go rename to app/system/dto/audit.go diff --git a/internal/modules/system/dto/audit_test.go b/app/system/dto/audit_test.go similarity index 100% rename from internal/modules/system/dto/audit_test.go rename to app/system/dto/audit_test.go diff --git a/internal/modules/system/dto/authentication.go b/app/system/dto/authentication.go similarity index 100% rename from internal/modules/system/dto/authentication.go rename to app/system/dto/authentication.go diff --git a/internal/modules/system/dto/authority.go b/app/system/dto/authority.go similarity index 100% rename from internal/modules/system/dto/authority.go rename to app/system/dto/authority.go diff --git a/internal/modules/system/dto/email.go b/app/system/dto/email.go similarity index 100% rename from internal/modules/system/dto/email.go rename to app/system/dto/email.go diff --git a/internal/modules/system/dto/export.go b/app/system/dto/export.go similarity index 100% rename from internal/modules/system/dto/export.go rename to app/system/dto/export.go diff --git a/internal/modules/system/dto/media.go b/app/system/dto/media.go similarity index 100% rename from internal/modules/system/dto/media.go rename to app/system/dto/media.go diff --git a/internal/modules/system/dto/menu.go b/app/system/dto/menu.go similarity index 100% rename from internal/modules/system/dto/menu.go rename to app/system/dto/menu.go diff --git a/internal/modules/system/dto/organization.go b/app/system/dto/organization.go similarity index 100% rename from internal/modules/system/dto/organization.go rename to app/system/dto/organization.go diff --git a/internal/modules/system/dto/payment.go b/app/system/dto/payment.go similarity index 100% rename from internal/modules/system/dto/payment.go rename to app/system/dto/payment.go diff --git a/internal/modules/system/dto/permission.go b/app/system/dto/permission.go similarity index 100% rename from internal/modules/system/dto/permission.go rename to app/system/dto/permission.go diff --git a/internal/modules/system/dto/settings.go b/app/system/dto/settings.go similarity index 100% rename from internal/modules/system/dto/settings.go rename to app/system/dto/settings.go diff --git a/internal/modules/system/dto/system.go b/app/system/dto/system.go similarity index 100% rename from internal/modules/system/dto/system.go rename to app/system/dto/system.go diff --git a/internal/modules/system/dto/system_config.go b/app/system/dto/system_config.go similarity index 100% rename from internal/modules/system/dto/system_config.go rename to app/system/dto/system_config.go diff --git a/internal/modules/system/dto/system_init.go b/app/system/dto/system_init.go similarity index 100% rename from internal/modules/system/dto/system_init.go rename to app/system/dto/system_init.go diff --git a/internal/modules/system/dto/task.go b/app/system/dto/task.go similarity index 100% rename from internal/modules/system/dto/task.go rename to app/system/dto/task.go diff --git a/internal/modules/system/dto/version.go b/app/system/dto/version.go similarity index 100% rename from internal/modules/system/dto/version.go rename to app/system/dto/version.go diff --git a/internal/modules/system/initialize/backend.go b/app/system/initialize/backend.go similarity index 95% rename from internal/modules/system/initialize/backend.go rename to app/system/initialize/backend.go index 345eaf5..335ed2b 100644 --- a/internal/modules/system/initialize/backend.go +++ b/app/system/initialize/backend.go @@ -3,8 +3,8 @@ package initialize import ( "context" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" "gorm.io/gorm" ) diff --git a/internal/modules/system/initialize/compatibility.go b/app/system/initialize/compatibility.go similarity index 100% rename from internal/modules/system/initialize/compatibility.go rename to app/system/initialize/compatibility.go diff --git a/internal/modules/system/initialize/configuration.go b/app/system/initialize/configuration.go similarity index 99% rename from internal/modules/system/initialize/configuration.go rename to app/system/initialize/configuration.go index b38032d..4b4a735 100644 --- a/internal/modules/system/initialize/configuration.go +++ b/app/system/initialize/configuration.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" + "kra/app/system/utils/configutil" "kra/internal/conf" - "kra/internal/modules/system/utils/configutil" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" diff --git a/internal/modules/system/initialize/initialize.go b/app/system/initialize/initialize.go similarity index 68% rename from internal/modules/system/initialize/initialize.go rename to app/system/initialize/initialize.go index e50718b..e8e46fe 100644 --- a/internal/modules/system/initialize/initialize.go +++ b/app/system/initialize/initialize.go @@ -3,17 +3,20 @@ package initialize import ( "context" - "kra/internal/modules/system/biz" - datapayment "kra/internal/modules/system/data/payment" - datasystem "kra/internal/modules/system/data/repository" + "kra/app/system/biz" + datasystem "kra/app/system/data/repository" + platformmodule "kra/pkg/module" "gorm.io/gorm" ) -type Repo struct{ backend Backend } +type Repo struct { + backend Backend + catalog platformmodule.Catalog +} -func NewRepo(backend Backend) biz.InitializationRepo { - return &Repo{backend: backend} +func NewRepo(backend Backend, catalog platformmodule.Catalog) biz.InitializationRepo { + return &Repo{backend: backend, catalog: catalog} } func (r *Repo) IsInitialized(ctx context.Context) (bool, error) { @@ -22,7 +25,7 @@ func (r *Repo) IsInitialized(ctx context.Context) (bool, error) { func (r *Repo) Initialize(ctx context.Context, input *biz.DatabaseConfig) error { return r.backend.InitializeDatabase(ctx, input, func(ctx context.Context, db *gorm.DB) error { - return datasystem.SeedSystem(ctx, db, input, datapayment.AdminSurface()) + return datasystem.SeedSystemWithCatalog(ctx, db, input, r.catalog) }) } diff --git a/internal/modules/system/initialize/provider.go b/app/system/initialize/provider.go similarity index 100% rename from internal/modules/system/initialize/provider.go rename to app/system/initialize/provider.go diff --git a/internal/modules/system/integration/README.md b/app/system/integration/README.md similarity index 100% rename from internal/modules/system/integration/README.md rename to app/system/integration/README.md diff --git a/internal/modules/system/integration/cache/cache.go b/app/system/integration/cache/cache.go similarity index 98% rename from internal/modules/system/integration/cache/cache.go rename to app/system/integration/cache/cache.go index cdc2cc5..0f39a40 100644 --- a/internal/modules/system/integration/cache/cache.go +++ b/app/system/integration/cache/cache.go @@ -7,7 +7,7 @@ import ( "time" "github.com/redis/go-redis/v9" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type RedisProvider interface { diff --git a/internal/modules/system/integration/email/email.go b/app/system/integration/email/email.go similarity index 99% rename from internal/modules/system/integration/email/email.go rename to app/system/integration/email/email.go index 2f40fe0..cad5e07 100644 --- a/internal/modules/system/integration/email/email.go +++ b/app/system/integration/email/email.go @@ -12,8 +12,8 @@ import ( "strings" "time" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type emailRepo struct { diff --git a/internal/modules/system/integration/payment/adapter.go b/app/system/integration/payment/adapter.go similarity index 98% rename from internal/modules/system/integration/payment/adapter.go rename to app/system/integration/payment/adapter.go index 6a3c03d..efd4e1f 100644 --- a/internal/modules/system/integration/payment/adapter.go +++ b/app/system/integration/payment/adapter.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) // Adapter is the provider boundary used by the payment repository. Provider diff --git a/internal/modules/system/integration/payment/adapter_test.go b/app/system/integration/payment/adapter_test.go similarity index 91% rename from internal/modules/system/integration/payment/adapter_test.go rename to app/system/integration/payment/adapter_test.go index 8b3c5c7..eeb1f51 100644 --- a/internal/modules/system/integration/payment/adapter_test.go +++ b/app/system/integration/payment/adapter_test.go @@ -3,7 +3,7 @@ package payment import ( "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestEverySupportedProviderHasAdapter(t *testing.T) { diff --git a/internal/modules/system/integration/payment/alipay.go b/app/system/integration/payment/alipay.go similarity index 99% rename from internal/modules/system/integration/payment/alipay.go rename to app/system/integration/payment/alipay.go index d7abcf5..1e4b8e3 100644 --- a/internal/modules/system/integration/payment/alipay.go +++ b/app/system/integration/payment/alipay.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" gopayAlipay "github.com/go-pay/gopay/alipay" diff --git a/internal/modules/system/integration/payment/alipay_v3.go b/app/system/integration/payment/alipay_v3.go similarity index 99% rename from internal/modules/system/integration/payment/alipay_v3.go rename to app/system/integration/payment/alipay_v3.go index f2220ee..0a46c15 100644 --- a/internal/modules/system/integration/payment/alipay_v3.go +++ b/app/system/integration/payment/alipay_v3.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" gopayAlipay "github.com/go-pay/gopay/alipay" diff --git a/internal/modules/system/integration/payment/alipay_v3_test.go b/app/system/integration/payment/alipay_v3_test.go similarity index 99% rename from internal/modules/system/integration/payment/alipay_v3_test.go rename to app/system/integration/payment/alipay_v3_test.go index 4ab24f7..1a38b0f 100644 --- a/internal/modules/system/integration/payment/alipay_v3_test.go +++ b/app/system/integration/payment/alipay_v3_test.go @@ -17,7 +17,7 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" gopayAlipay "github.com/go-pay/gopay/alipay" gopayAlipayV3 "github.com/go-pay/gopay/alipay/v3" diff --git a/internal/modules/system/integration/payment/allinpay.go b/app/system/integration/payment/allinpay.go similarity index 99% rename from internal/modules/system/integration/payment/allinpay.go rename to app/system/integration/payment/allinpay.go index 6ced397..f8920f9 100644 --- a/internal/modules/system/integration/payment/allinpay.go +++ b/app/system/integration/payment/allinpay.go @@ -15,7 +15,7 @@ import ( "strings" "sync" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/crypto/xpem" "github.com/go-pay/crypto/xrsa" diff --git a/internal/modules/system/integration/payment/allinpay_test.go b/app/system/integration/payment/allinpay_test.go similarity index 99% rename from internal/modules/system/integration/payment/allinpay_test.go rename to app/system/integration/payment/allinpay_test.go index 7ffae14..966d0ed 100644 --- a/internal/modules/system/integration/payment/allinpay_test.go +++ b/app/system/integration/payment/allinpay_test.go @@ -18,7 +18,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/allinpay" diff --git a/internal/modules/system/integration/payment/apple.go b/app/system/integration/payment/apple.go similarity index 99% rename from internal/modules/system/integration/payment/apple.go rename to app/system/integration/payment/apple.go index 54a5d48..34ada1c 100644 --- a/internal/modules/system/integration/payment/apple.go +++ b/app/system/integration/payment/apple.go @@ -8,7 +8,7 @@ import ( "math" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" gopayApple "github.com/go-pay/gopay/apple" "github.com/google/uuid" diff --git a/internal/modules/system/integration/payment/apple_jws.go b/app/system/integration/payment/apple_jws.go similarity index 100% rename from internal/modules/system/integration/payment/apple_jws.go rename to app/system/integration/payment/apple_jws.go diff --git a/internal/modules/system/integration/payment/apple_jws_test.go b/app/system/integration/payment/apple_jws_test.go similarity index 100% rename from internal/modules/system/integration/payment/apple_jws_test.go rename to app/system/integration/payment/apple_jws_test.go diff --git a/internal/modules/system/integration/payment/douyin.go b/app/system/integration/payment/douyin.go similarity index 99% rename from internal/modules/system/integration/payment/douyin.go rename to app/system/integration/payment/douyin.go index f237a48..3f0aaeb 100644 --- a/internal/modules/system/integration/payment/douyin.go +++ b/app/system/integration/payment/douyin.go @@ -7,7 +7,7 @@ import ( "fmt" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/douyin" diff --git a/internal/modules/system/integration/payment/gopay.go b/app/system/integration/payment/gopay.go similarity index 100% rename from internal/modules/system/integration/payment/gopay.go rename to app/system/integration/payment/gopay.go diff --git a/internal/modules/system/integration/payment/gopay_helpers.go b/app/system/integration/payment/gopay_helpers.go similarity index 99% rename from internal/modules/system/integration/payment/gopay_helpers.go rename to app/system/integration/payment/gopay_helpers.go index 1ba0678..2a1dcc3 100644 --- a/internal/modules/system/integration/payment/gopay_helpers.go +++ b/app/system/integration/payment/gopay_helpers.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/douyin" diff --git a/internal/modules/system/integration/payment/gopay_test.go b/app/system/integration/payment/gopay_test.go similarity index 99% rename from internal/modules/system/integration/payment/gopay_test.go rename to app/system/integration/payment/gopay_test.go index efe9638..f4c3f39 100644 --- a/internal/modules/system/integration/payment/gopay_test.go +++ b/app/system/integration/payment/gopay_test.go @@ -20,8 +20,8 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/utils/paymentutil" + "kra/app/system/biz" + "kra/app/system/utils/paymentutil" gopayAlipay "github.com/go-pay/gopay/alipay" gopayDouyin "github.com/go-pay/gopay/douyin" diff --git a/internal/modules/system/integration/payment/identity_test.go b/app/system/integration/payment/identity_test.go similarity index 99% rename from internal/modules/system/integration/payment/identity_test.go rename to app/system/integration/payment/identity_test.go index 73919fc..6bc43dc 100644 --- a/internal/modules/system/integration/payment/identity_test.go +++ b/app/system/integration/payment/identity_test.go @@ -18,7 +18,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/allinpay" diff --git a/internal/modules/system/integration/payment/lakala.go b/app/system/integration/payment/lakala.go similarity index 99% rename from internal/modules/system/integration/payment/lakala.go rename to app/system/integration/payment/lakala.go index d5faa55..95503ff 100644 --- a/internal/modules/system/integration/payment/lakala.go +++ b/app/system/integration/payment/lakala.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/lakala" diff --git a/internal/modules/system/integration/payment/lakala_test.go b/app/system/integration/payment/lakala_test.go similarity index 99% rename from internal/modules/system/integration/payment/lakala_test.go rename to app/system/integration/payment/lakala_test.go index 39faaa1..c5ea5ef 100644 --- a/internal/modules/system/integration/payment/lakala_test.go +++ b/app/system/integration/payment/lakala_test.go @@ -3,7 +3,7 @@ package payment import ( "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay/lakala" ) diff --git a/internal/modules/system/integration/payment/native_test.go b/app/system/integration/payment/native_test.go similarity index 99% rename from internal/modules/system/integration/payment/native_test.go rename to app/system/integration/payment/native_test.go index 462fb73..cab9999 100644 --- a/internal/modules/system/integration/payment/native_test.go +++ b/app/system/integration/payment/native_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestWechatV2SignOfficialStyle(t *testing.T) { diff --git a/internal/modules/system/integration/payment/paypal.go b/app/system/integration/payment/paypal.go similarity index 99% rename from internal/modules/system/integration/payment/paypal.go rename to app/system/integration/payment/paypal.go index c4c9f97..c426d71 100644 --- a/internal/modules/system/integration/payment/paypal.go +++ b/app/system/integration/payment/paypal.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/paypal" diff --git a/internal/modules/system/integration/payment/paypal_test.go b/app/system/integration/payment/paypal_test.go similarity index 99% rename from internal/modules/system/integration/payment/paypal_test.go rename to app/system/integration/payment/paypal_test.go index f355317..6ec61b5 100644 --- a/internal/modules/system/integration/payment/paypal_test.go +++ b/app/system/integration/payment/paypal_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay/paypal" ) diff --git a/internal/modules/system/integration/payment/qq.go b/app/system/integration/payment/qq.go similarity index 99% rename from internal/modules/system/integration/payment/qq.go rename to app/system/integration/payment/qq.go index b54474a..94822ca 100644 --- a/internal/modules/system/integration/payment/qq.go +++ b/app/system/integration/payment/qq.go @@ -7,7 +7,7 @@ import ( "fmt" "strings" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" gopayQQ "github.com/go-pay/gopay/qq" diff --git a/internal/modules/system/integration/payment/qq_test.go b/app/system/integration/payment/qq_test.go similarity index 98% rename from internal/modules/system/integration/payment/qq_test.go rename to app/system/integration/payment/qq_test.go index 3b00be5..3fe2d28 100644 --- a/internal/modules/system/integration/payment/qq_test.go +++ b/app/system/integration/payment/qq_test.go @@ -11,8 +11,8 @@ import ( "net/http/httptest" "testing" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/utils/paymentutil" + "kra/app/system/biz" + "kra/app/system/utils/paymentutil" "github.com/go-pay/gopay" gopayQQ "github.com/go-pay/gopay/qq" diff --git a/internal/modules/system/integration/payment/refund_boundary_test.go b/app/system/integration/payment/refund_boundary_test.go similarity index 99% rename from internal/modules/system/integration/payment/refund_boundary_test.go rename to app/system/integration/payment/refund_boundary_test.go index 87f8cb8..235dc4d 100644 --- a/internal/modules/system/integration/payment/refund_boundary_test.go +++ b/app/system/integration/payment/refund_boundary_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" gopayQQ "github.com/go-pay/gopay/qq" diff --git a/internal/modules/system/integration/payment/response_validation_test.go b/app/system/integration/payment/response_validation_test.go similarity index 99% rename from internal/modules/system/integration/payment/response_validation_test.go rename to app/system/integration/payment/response_validation_test.go index 0e406f9..9a334b7 100644 --- a/internal/modules/system/integration/payment/response_validation_test.go +++ b/app/system/integration/payment/response_validation_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" gopayAlipay "github.com/go-pay/gopay/alipay" "github.com/go-pay/gopay/douyin" diff --git a/internal/modules/system/integration/payment/result.go b/app/system/integration/payment/result.go similarity index 98% rename from internal/modules/system/integration/payment/result.go rename to app/system/integration/payment/result.go index a0df671..89e6be5 100644 --- a/internal/modules/system/integration/payment/result.go +++ b/app/system/integration/payment/result.go @@ -7,8 +7,8 @@ import ( "net/url" "strings" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/utils/paymentutil" + "kra/app/system/biz" + "kra/app/system/utils/paymentutil" ) func callbackFields(callback *biz.PaymentCallback) map[string]string { diff --git a/internal/modules/system/integration/payment/result_test.go b/app/system/integration/payment/result_test.go similarity index 92% rename from internal/modules/system/integration/payment/result_test.go rename to app/system/integration/payment/result_test.go index ed301ff..fe8a230 100644 --- a/internal/modules/system/integration/payment/result_test.go +++ b/app/system/integration/payment/result_test.go @@ -3,7 +3,7 @@ package payment import ( "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestCallbackFieldsAcceptsCaseInsensitiveContentType(t *testing.T) { diff --git a/internal/modules/system/integration/payment/saobei.go b/app/system/integration/payment/saobei.go similarity index 99% rename from internal/modules/system/integration/payment/saobei.go rename to app/system/integration/payment/saobei.go index 5fba22a..f95a8a9 100644 --- a/internal/modules/system/integration/payment/saobei.go +++ b/app/system/integration/payment/saobei.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/saobei" diff --git a/internal/modules/system/integration/payment/saobei_test.go b/app/system/integration/payment/saobei_test.go similarity index 99% rename from internal/modules/system/integration/payment/saobei_test.go rename to app/system/integration/payment/saobei_test.go index 558176d..0eeabad 100644 --- a/internal/modules/system/integration/payment/saobei_test.go +++ b/app/system/integration/payment/saobei_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/saobei" diff --git a/internal/modules/system/integration/payment/vendor.go b/app/system/integration/payment/vendor.go similarity index 99% rename from internal/modules/system/integration/payment/vendor.go rename to app/system/integration/payment/vendor.go index 4a6dd11..6777d6b 100644 --- a/internal/modules/system/integration/payment/vendor.go +++ b/app/system/integration/payment/vendor.go @@ -14,8 +14,8 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/utils/paymentutil" + "kra/app/system/biz" + "kra/app/system/utils/paymentutil" ) type vendorProfile string diff --git a/internal/modules/system/integration/payment/vendor_test.go b/app/system/integration/payment/vendor_test.go similarity index 100% rename from internal/modules/system/integration/payment/vendor_test.go rename to app/system/integration/payment/vendor_test.go diff --git a/internal/modules/system/integration/payment/wechat_v2.go b/app/system/integration/payment/wechat_v2.go similarity index 99% rename from internal/modules/system/integration/payment/wechat_v2.go rename to app/system/integration/payment/wechat_v2.go index 51a9f0d..dc3df38 100644 --- a/internal/modules/system/integration/payment/wechat_v2.go +++ b/app/system/integration/payment/wechat_v2.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" "github.com/go-pay/gopay/pkg/xhttp" diff --git a/internal/modules/system/integration/payment/wechat_v3.go b/app/system/integration/payment/wechat_v3.go similarity index 99% rename from internal/modules/system/integration/payment/wechat_v3.go rename to app/system/integration/payment/wechat_v3.go index f708b77..e5807e3 100644 --- a/internal/modules/system/integration/payment/wechat_v3.go +++ b/app/system/integration/payment/wechat_v3.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" "github.com/go-pay/gopay" gopayWechatV3 "github.com/go-pay/gopay/wechat/v3" diff --git a/internal/modules/system/integration/payment/wechat_v3_codepay_test.go b/app/system/integration/payment/wechat_v3_codepay_test.go similarity index 99% rename from internal/modules/system/integration/payment/wechat_v3_codepay_test.go rename to app/system/integration/payment/wechat_v3_codepay_test.go index 840b347..7898cb6 100644 --- a/internal/modules/system/integration/payment/wechat_v3_codepay_test.go +++ b/app/system/integration/payment/wechat_v3_codepay_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" gopayWechatV3 "github.com/go-pay/gopay/wechat/v3" ) diff --git a/internal/modules/system/integration/payment/wechat_v3_douyin_refund_test.go b/app/system/integration/payment/wechat_v3_douyin_refund_test.go similarity index 99% rename from internal/modules/system/integration/payment/wechat_v3_douyin_refund_test.go rename to app/system/integration/payment/wechat_v3_douyin_refund_test.go index 2ef5eaa..996d1ee 100644 --- a/internal/modules/system/integration/payment/wechat_v3_douyin_refund_test.go +++ b/app/system/integration/payment/wechat_v3_douyin_refund_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" gopayDouyin "github.com/go-pay/gopay/douyin" gopayWechatV3 "github.com/go-pay/gopay/wechat/v3" diff --git a/internal/modules/system/integration/provider.go b/app/system/integration/provider.go similarity index 70% rename from internal/modules/system/integration/provider.go rename to app/system/integration/provider.go index 0d02f84..084f129 100644 --- a/internal/modules/system/integration/provider.go +++ b/app/system/integration/provider.go @@ -4,10 +4,10 @@ package integration import ( - "kra/internal/modules/system/biz" - "kra/internal/modules/system/integration/cache" - "kra/internal/modules/system/integration/email" - "kra/internal/modules/system/integration/storage" + "kra/app/system/biz" + "kra/app/system/integration/cache" + "kra/app/system/integration/email" + "kra/app/system/integration/storage" "github.com/google/wire" ) diff --git a/internal/modules/system/integration/storage/aliyun_storage.go b/app/system/integration/storage/aliyun_storage.go similarity index 98% rename from internal/modules/system/integration/storage/aliyun_storage.go rename to app/system/integration/storage/aliyun_storage.go index 7748720..d609050 100644 --- a/internal/modules/system/integration/storage/aliyun_storage.go +++ b/app/system/integration/storage/aliyun_storage.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/aliyun/aliyun-oss-go-sdk/oss" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type aliyunStorage struct { diff --git a/internal/modules/system/integration/storage/aws_storage.go b/app/system/integration/storage/aws_storage.go similarity index 99% rename from internal/modules/system/integration/storage/aws_storage.go rename to app/system/integration/storage/aws_storage.go index fcd3ed7..3771f13 100644 --- a/internal/modules/system/integration/storage/aws_storage.go +++ b/app/system/integration/storage/aws_storage.go @@ -12,8 +12,8 @@ import ( "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type awsStorage struct { diff --git a/internal/modules/system/integration/storage/compose.go b/app/system/integration/storage/compose.go similarity index 100% rename from internal/modules/system/integration/storage/compose.go rename to app/system/integration/storage/compose.go diff --git a/internal/modules/system/integration/storage/compose_test.go b/app/system/integration/storage/compose_test.go similarity index 100% rename from internal/modules/system/integration/storage/compose_test.go rename to app/system/integration/storage/compose_test.go diff --git a/internal/modules/system/integration/storage/huawei_storage.go b/app/system/integration/storage/huawei_storage.go similarity index 99% rename from internal/modules/system/integration/storage/huawei_storage.go rename to app/system/integration/storage/huawei_storage.go index 823ba02..11a39f9 100644 --- a/internal/modules/system/integration/storage/huawei_storage.go +++ b/app/system/integration/storage/huawei_storage.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/huaweicloud/huaweicloud-sdk-go-obs/obs" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type huaweiStorage struct { diff --git a/internal/modules/system/integration/storage/local.go b/app/system/integration/storage/local.go similarity index 99% rename from internal/modules/system/integration/storage/local.go rename to app/system/integration/storage/local.go index 1eca0ad..998b4e7 100644 --- a/internal/modules/system/integration/storage/local.go +++ b/app/system/integration/storage/local.go @@ -10,8 +10,8 @@ import ( "sort" "strings" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type fileStorage struct { diff --git a/internal/modules/system/integration/storage/qiniu_storage.go b/app/system/integration/storage/qiniu_storage.go similarity index 99% rename from internal/modules/system/integration/storage/qiniu_storage.go rename to app/system/integration/storage/qiniu_storage.go index d29497b..c14b80c 100644 --- a/internal/modules/system/integration/storage/qiniu_storage.go +++ b/app/system/integration/storage/qiniu_storage.go @@ -12,8 +12,8 @@ import ( "github.com/qiniu/go-sdk/v7/auth/qbox" qstorage "github.com/qiniu/go-sdk/v7/storage" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type qiniuStorage struct { diff --git a/internal/modules/system/integration/storage/reloadable.go b/app/system/integration/storage/reloadable.go similarity index 97% rename from internal/modules/system/integration/storage/reloadable.go rename to app/system/integration/storage/reloadable.go index f3221ff..040b821 100644 --- a/internal/modules/system/integration/storage/reloadable.go +++ b/app/system/integration/storage/reloadable.go @@ -5,8 +5,8 @@ import ( "io" "sync" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type Reloadable struct { diff --git a/internal/modules/system/integration/storage/s3_storage.go b/app/system/integration/storage/s3_storage.go similarity index 99% rename from internal/modules/system/integration/storage/s3_storage.go rename to app/system/integration/storage/s3_storage.go index cc33c4a..b113a59 100644 --- a/internal/modules/system/integration/storage/s3_storage.go +++ b/app/system/integration/storage/s3_storage.go @@ -10,8 +10,8 @@ import ( "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type s3Storage struct { diff --git a/internal/modules/system/integration/storage/tencent_storage.go b/app/system/integration/storage/tencent_storage.go similarity index 99% rename from internal/modules/system/integration/storage/tencent_storage.go rename to app/system/integration/storage/tencent_storage.go index 3296764..1cecc1c 100644 --- a/internal/modules/system/integration/storage/tencent_storage.go +++ b/app/system/integration/storage/tencent_storage.go @@ -11,8 +11,8 @@ import ( "time" cos "github.com/tencentyun/cos-go-sdk-v5" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type tencentStorage struct { diff --git a/app/system/module.go b/app/system/module.go new file mode 100644 index 0000000..c680c04 --- /dev/null +++ b/app/system/module.go @@ -0,0 +1,21 @@ +package system + +import ( + datapayment "kra/app/system/data/payment" + datasystem "kra/app/system/data/repository" + "kra/pkg/module" +) + +// Definition describes the built-in system contribution to the application +// catalog. Other business modules can expose the same shape independently. +func Definition() module.Definition { + return module.Definition{ + Name: "system", + Migrations: append(datasystem.Migrations(), datapayment.Migrations()...), + Surface: datapayment.AdminSurface(), + TimedTasks: []module.TimedTask{ + {Name: "ClearDB", Description: "定时清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Spec: "@daily", MethodName: "ClearDB", Enabled: true}, + {Name: "CleanStaleUploads", Description: "定时清理过期大文件上传会话", Spec: "@hourly", MethodName: "CleanStaleUploads", Enabled: true}, + }, + } +} diff --git a/internal/modules/system/routeinfo/metadata.go b/app/system/routeinfo/metadata.go similarity index 100% rename from internal/modules/system/routeinfo/metadata.go rename to app/system/routeinfo/metadata.go diff --git a/internal/modules/system/security/adminauth/token.go b/app/system/security/adminauth/token.go similarity index 100% rename from internal/modules/system/security/adminauth/token.go rename to app/system/security/adminauth/token.go diff --git a/internal/modules/system/service/access_control.go b/app/system/service/access_control.go similarity index 96% rename from internal/modules/system/service/access_control.go rename to app/system/service/access_control.go index b97d25c..d234382 100644 --- a/internal/modules/system/service/access_control.go +++ b/app/system/service/access_control.go @@ -3,7 +3,7 @@ package service import ( "context" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type AccessControlService struct{ uc *biz.AccessControlUsecase } diff --git a/internal/modules/system/service/announcement.go b/app/system/service/announcement.go similarity index 97% rename from internal/modules/system/service/announcement.go rename to app/system/service/announcement.go index b1477b8..7032269 100644 --- a/internal/modules/system/service/announcement.go +++ b/app/system/service/announcement.go @@ -5,8 +5,8 @@ import ( "encoding/json" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type AnnouncementInput struct { diff --git a/internal/modules/system/service/api.go b/app/system/service/api.go similarity index 98% rename from internal/modules/system/service/api.go rename to app/system/service/api.go index 35bc2fe..573fa53 100644 --- a/internal/modules/system/service/api.go +++ b/app/system/service/api.go @@ -4,8 +4,8 @@ import ( "context" "strings" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type APIService struct { diff --git a/internal/modules/system/service/api_token.go b/app/system/service/api_token.go similarity index 96% rename from internal/modules/system/service/api_token.go rename to app/system/service/api_token.go index 0559c0f..c14f1c2 100644 --- a/internal/modules/system/service/api_token.go +++ b/app/system/service/api_token.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type TokenService struct { diff --git a/internal/modules/system/service/audit.go b/app/system/service/audit.go similarity index 98% rename from internal/modules/system/service/audit.go rename to app/system/service/audit.go index f266d6e..a984d13 100644 --- a/internal/modules/system/service/audit.go +++ b/app/system/service/audit.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type AuditService struct{ uc *biz.AuditUsecase } diff --git a/internal/modules/system/service/audit_error.go b/app/system/service/audit_error.go similarity index 97% rename from internal/modules/system/service/audit_error.go rename to app/system/service/audit_error.go index 4f55841..cdbd8ef 100644 --- a/internal/modules/system/service/audit_error.go +++ b/app/system/service/audit_error.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) func errorDTO(v *biz.ErrorRecord) *dto.ErrorRecordResponse { diff --git a/internal/modules/system/service/audit_log_file.go b/app/system/service/audit_log_file.go similarity index 95% rename from internal/modules/system/service/audit_log_file.go rename to app/system/service/audit_log_file.go index b498c56..c4c43db 100644 --- a/internal/modules/system/service/audit_log_file.go +++ b/app/system/service/audit_log_file.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type LogViewerService struct{ uc *biz.LogViewerUsecase } diff --git a/internal/modules/system/service/authentication.go b/app/system/service/authentication.go similarity index 94% rename from internal/modules/system/service/authentication.go rename to app/system/service/authentication.go index 85a75aa..da61600 100644 --- a/internal/modules/system/service/authentication.go +++ b/app/system/service/authentication.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type AuthService struct { diff --git a/internal/modules/system/service/authority.go b/app/system/service/authority.go similarity index 97% rename from internal/modules/system/service/authority.go rename to app/system/service/authority.go index 4c8d2c0..1727818 100644 --- a/internal/modules/system/service/authority.go +++ b/app/system/service/authority.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type AuthorityService struct{ uc *biz.AuthorityUsecase } diff --git a/internal/modules/system/service/department.go b/app/system/service/department.go similarity index 97% rename from internal/modules/system/service/department.go rename to app/system/service/department.go index 1dc4f67..164eabd 100644 --- a/internal/modules/system/service/department.go +++ b/app/system/service/department.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type DepartmentService struct{ uc *biz.DepartmentUsecase } diff --git a/internal/modules/system/service/department_test.go b/app/system/service/department_test.go similarity index 92% rename from internal/modules/system/service/department_test.go rename to app/system/service/department_test.go index 9ae3fc2..e76bcb1 100644 --- a/internal/modules/system/service/department_test.go +++ b/app/system/service/department_test.go @@ -3,7 +3,7 @@ package service import ( "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestDepartmentResponsePreservesNilAndEmptyChildren(t *testing.T) { diff --git a/internal/modules/system/service/dictionary.go b/app/system/service/dictionary.go similarity index 99% rename from internal/modules/system/service/dictionary.go rename to app/system/service/dictionary.go index 602d4f5..dc4eee5 100644 --- a/internal/modules/system/service/dictionary.go +++ b/app/system/service/dictionary.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type DictionaryService struct{ uc *biz.DictionaryUsecase } diff --git a/internal/modules/system/service/dictionary_import.go b/app/system/service/dictionary_import.go similarity index 95% rename from internal/modules/system/service/dictionary_import.go rename to app/system/service/dictionary_import.go index 307d937..9b59f93 100644 --- a/internal/modules/system/service/dictionary_import.go +++ b/app/system/service/dictionary_import.go @@ -5,8 +5,8 @@ import ( "encoding/json" "errors" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) func (s *DictionaryService) ImportDictionaryJSON(ctx context.Context, raw string) error { diff --git a/internal/modules/system/service/dictionary_test.go b/app/system/service/dictionary_test.go similarity index 95% rename from internal/modules/system/service/dictionary_test.go rename to app/system/service/dictionary_test.go index 87d8e26..b65ed57 100644 --- a/internal/modules/system/service/dictionary_test.go +++ b/app/system/service/dictionary_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type dictionaryExportRepo struct { diff --git a/internal/modules/system/service/email.go b/app/system/service/email.go similarity index 93% rename from internal/modules/system/service/email.go rename to app/system/service/email.go index 638ebb3..9f1e4cf 100644 --- a/internal/modules/system/service/email.go +++ b/app/system/service/email.go @@ -2,7 +2,7 @@ package service import ( "context" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type EmailService struct{ uc *biz.EmailUsecase } diff --git a/internal/modules/system/service/export.go b/app/system/service/export.go similarity index 98% rename from internal/modules/system/service/export.go rename to app/system/service/export.go index a33ed2b..a57d113 100644 --- a/internal/modules/system/service/export.go +++ b/app/system/service/export.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" "github.com/google/uuid" ) diff --git a/internal/modules/system/service/export_excel.go b/app/system/service/export_excel.go similarity index 100% rename from internal/modules/system/service/export_excel.go rename to app/system/service/export_excel.go diff --git a/internal/modules/system/service/media.go b/app/system/service/media.go similarity index 98% rename from internal/modules/system/service/media.go rename to app/system/service/media.go index d329e4f..5dd6b58 100644 --- a/internal/modules/system/service/media.go +++ b/app/system/service/media.go @@ -4,8 +4,8 @@ import ( "context" "io" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type MediaService struct { diff --git a/internal/modules/system/service/media_upload.go b/app/system/service/media_upload.go similarity index 97% rename from internal/modules/system/service/media_upload.go rename to app/system/service/media_upload.go index ea14221..c744c55 100644 --- a/internal/modules/system/service/media_upload.go +++ b/app/system/service/media_upload.go @@ -4,7 +4,7 @@ import ( "context" "io" - "kra/internal/modules/system/dto" + "kra/app/system/dto" ) func (s *MediaService) InitUpload(ctx context.Context, userID uint, name, hash string, size, chunkSize int64, total int) (*dto.InitUploadResponse, error) { diff --git a/internal/modules/system/service/menu.go b/app/system/service/menu.go similarity index 99% rename from internal/modules/system/service/menu.go rename to app/system/service/menu.go index 198ec0f..1c06165 100644 --- a/internal/modules/system/service/menu.go +++ b/app/system/service/menu.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type MenuService struct{ uc *biz.MenuUsecase } diff --git a/internal/modules/system/service/menu_test.go b/app/system/service/menu_test.go similarity index 97% rename from internal/modules/system/service/menu_test.go rename to app/system/service/menu_test.go index 79acf3d..7f10143 100644 --- a/internal/modules/system/service/menu_test.go +++ b/app/system/service/menu_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) func TestMenuDomainPreservesRelationIdentity(t *testing.T) { diff --git a/internal/modules/system/service/parameter.go b/app/system/service/parameter.go similarity index 97% rename from internal/modules/system/service/parameter.go rename to app/system/service/parameter.go index 2fa955e..6ce531f 100644 --- a/internal/modules/system/service/parameter.go +++ b/app/system/service/parameter.go @@ -4,8 +4,8 @@ import ( "context" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type ParameterService struct{ uc *biz.ParameterUsecase } diff --git a/internal/modules/system/service/payment.go b/app/system/service/payment.go similarity index 99% rename from internal/modules/system/service/payment.go rename to app/system/service/payment.go index 4568246..fe96b5d 100644 --- a/internal/modules/system/service/payment.go +++ b/app/system/service/payment.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type PaymentService struct{ uc *biz.PaymentUsecase } diff --git a/internal/modules/system/service/permission.go b/app/system/service/permission.go similarity index 95% rename from internal/modules/system/service/permission.go rename to app/system/service/permission.go index 5afe964..4a0775a 100644 --- a/internal/modules/system/service/permission.go +++ b/app/system/service/permission.go @@ -3,7 +3,7 @@ package service import ( "context" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type PermissionService struct{ uc *biz.PermissionUsecase } diff --git a/internal/modules/system/service/position.go b/app/system/service/position.go similarity index 96% rename from internal/modules/system/service/position.go rename to app/system/service/position.go index 63b5ae0..fa8a176 100644 --- a/internal/modules/system/service/position.go +++ b/app/system/service/position.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type PositionService struct{ uc *biz.PositionUsecase } diff --git a/internal/modules/system/service/route_path.go b/app/system/service/route_path.go similarity index 100% rename from internal/modules/system/service/route_path.go rename to app/system/service/route_path.go diff --git a/internal/modules/system/service/route_path_test.go b/app/system/service/route_path_test.go similarity index 100% rename from internal/modules/system/service/route_path_test.go rename to app/system/service/route_path_test.go diff --git a/internal/modules/system/service/security.go b/app/system/service/security.go similarity index 97% rename from internal/modules/system/service/security.go rename to app/system/service/security.go index 67dca75..38dd562 100644 --- a/internal/modules/system/service/security.go +++ b/app/system/service/security.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type PasswordPolicyError struct{ Err error } diff --git a/internal/modules/system/service/security_session.go b/app/system/service/security_session.go similarity index 98% rename from internal/modules/system/service/security_session.go rename to app/system/service/security_session.go index 97f2419..9a3cd67 100644 --- a/internal/modules/system/service/security_session.go +++ b/app/system/service/security_session.go @@ -4,7 +4,7 @@ import ( "context" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type SecurityService struct { diff --git a/internal/modules/system/service/service.go b/app/system/service/service.go similarity index 100% rename from internal/modules/system/service/service.go rename to app/system/service/service.go diff --git a/internal/modules/system/service/system.go b/app/system/service/system.go similarity index 92% rename from internal/modules/system/service/system.go rename to app/system/service/system.go index 5edc4e3..0f54c15 100644 --- a/internal/modules/system/service/system.go +++ b/app/system/service/system.go @@ -3,7 +3,7 @@ package service import ( "context" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type SystemConfigService struct { diff --git a/internal/modules/system/service/system_config.go b/app/system/service/system_config.go similarity index 94% rename from internal/modules/system/service/system_config.go rename to app/system/service/system_config.go index 0201336..2c65492 100644 --- a/internal/modules/system/service/system_config.go +++ b/app/system/service/system_config.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "kra/internal/modules/system/dto" + "kra/app/system/dto" ) func (s *SystemConfigService) PersistConfig(ctx context.Context) error { diff --git a/internal/modules/system/service/system_info.go b/app/system/service/system_info.go similarity index 97% rename from internal/modules/system/service/system_info.go rename to app/system/service/system_info.go index cba5569..9f391ef 100644 --- a/internal/modules/system/service/system_info.go +++ b/app/system/service/system_info.go @@ -4,7 +4,7 @@ import ( "runtime" "time" - "kra/internal/modules/system/dto" + "kra/app/system/dto" "github.com/shirou/gopsutil/v4/cpu" "github.com/shirou/gopsutil/v4/disk" diff --git a/internal/modules/system/service/system_init.go b/app/system/service/system_init.go similarity index 92% rename from internal/modules/system/service/system_init.go rename to app/system/service/system_init.go index 99efca2..878ced6 100644 --- a/internal/modules/system/service/system_init.go +++ b/app/system/service/system_init.go @@ -3,9 +3,9 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/routeinfo" + "kra/app/system/biz" + "kra/app/system/dto" + "kra/app/system/routeinfo" ) func (s *SystemConfigService) Initialize(ctx context.Context, input *dto.DatabaseInitRequest, apis []*biz.API) error { diff --git a/internal/modules/system/service/task.go b/app/system/service/task.go similarity index 97% rename from internal/modules/system/service/task.go rename to app/system/service/task.go index 2b326b6..5ee06ed 100644 --- a/internal/modules/system/service/task.go +++ b/app/system/service/task.go @@ -5,8 +5,8 @@ import ( "encoding/json" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type TaskService struct { @@ -82,7 +82,7 @@ func (s *TaskService) Subscribe(userID uint) chan []byte { return s.uc func (s *TaskService) Unsubscribe(userID uint, events chan []byte) { s.uc.Unsubscribe(userID, events) } func (s *TaskService) RegisteredMethods() []*dto.TaskMethodResponse { - methods := biz.RegisteredTaskMethods() + methods := s.uc.RegisteredMethods() out := make([]*dto.TaskMethodResponse, 0, len(methods)) for _, method := range methods { out = append(out, &dto.TaskMethodResponse{Name: method.Name, Description: method.Description}) diff --git a/internal/modules/system/service/user.go b/app/system/service/user.go similarity index 98% rename from internal/modules/system/service/user.go rename to app/system/service/user.go index fd1c933..61459f3 100644 --- a/internal/modules/system/service/user.go +++ b/app/system/service/user.go @@ -3,8 +3,8 @@ package service import ( "context" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type userInput struct { diff --git a/internal/modules/system/service/user_conversion.go b/app/system/service/user_conversion.go similarity index 96% rename from internal/modules/system/service/user_conversion.go rename to app/system/service/user_conversion.go index 6b141a8..859f21f 100644 --- a/internal/modules/system/service/user_conversion.go +++ b/app/system/service/user_conversion.go @@ -1,8 +1,8 @@ package service import ( - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) func convertAuthority(value biz.Authority) *dto.AuthorityResponse { diff --git a/internal/modules/system/service/version.go b/app/system/service/version.go similarity index 99% rename from internal/modules/system/service/version.go rename to app/system/service/version.go index 721928c..966be36 100644 --- a/internal/modules/system/service/version.go +++ b/app/system/service/version.go @@ -5,8 +5,8 @@ import ( "encoding/json" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" + "kra/app/system/biz" + "kra/app/system/dto" ) type VersionService struct{ uc *biz.VersionUsecase } diff --git a/internal/modules/system/transport/handler/announcement.go b/app/system/transport/handler/announcement.go similarity index 96% rename from internal/modules/system/transport/handler/announcement.go rename to app/system/transport/handler/announcement.go index 6dd8759..d43332e 100644 --- a/internal/modules/system/transport/handler/announcement.go +++ b/app/system/transport/handler/announcement.go @@ -3,9 +3,9 @@ package handler import ( "time" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/api.go b/app/system/transport/handler/api.go similarity index 98% rename from internal/modules/system/transport/handler/api.go rename to app/system/transport/handler/api.go index f98ba06..dce1fb0 100644 --- a/internal/modules/system/transport/handler/api.go +++ b/app/system/transport/handler/api.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/api_token.go b/app/system/transport/handler/api_token.go similarity index 92% rename from internal/modules/system/transport/handler/api_token.go rename to app/system/transport/handler/api_token.go index 5498dde..2679f63 100644 --- a/internal/modules/system/transport/handler/api_token.go +++ b/app/system/transport/handler/api_token.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/audit.go b/app/system/transport/handler/audit.go similarity index 98% rename from internal/modules/system/transport/handler/audit.go rename to app/system/transport/handler/audit.go index ea28531..730d45b 100644 --- a/internal/modules/system/transport/handler/audit.go +++ b/app/system/transport/handler/audit.go @@ -6,10 +6,10 @@ import ( "strconv" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/biz" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/authority.go b/app/system/transport/handler/authority.go similarity index 97% rename from internal/modules/system/transport/handler/authority.go rename to app/system/transport/handler/authority.go index 62362f4..dc38376 100644 --- a/internal/modules/system/transport/handler/authority.go +++ b/app/system/transport/handler/authority.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/dictionary.go b/app/system/transport/handler/dictionary.go similarity index 98% rename from internal/modules/system/transport/handler/dictionary.go rename to app/system/transport/handler/dictionary.go index a92abb0..21117f1 100644 --- a/internal/modules/system/transport/handler/dictionary.go +++ b/app/system/transport/handler/dictionary.go @@ -3,9 +3,9 @@ package handler import ( "strconv" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/email.go b/app/system/transport/handler/email.go similarity index 86% rename from internal/modules/system/transport/handler/email.go rename to app/system/transport/handler/email.go index e6cfe44..befb71d 100644 --- a/internal/modules/system/transport/handler/email.go +++ b/app/system/transport/handler/email.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/export.go b/app/system/transport/handler/export.go similarity index 98% rename from internal/modules/system/transport/handler/export.go rename to app/system/transport/handler/export.go index f42b883..3d90c51 100644 --- a/internal/modules/system/transport/handler/export.go +++ b/app/system/transport/handler/export.go @@ -6,9 +6,9 @@ import ( "net/url" "strings" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" "github.com/google/uuid" diff --git a/internal/modules/system/transport/handler/export_test.go b/app/system/transport/handler/export_test.go similarity index 100% rename from internal/modules/system/transport/handler/export_test.go rename to app/system/transport/handler/export_test.go diff --git a/internal/modules/system/transport/handler/media.go b/app/system/transport/handler/media.go similarity index 97% rename from internal/modules/system/transport/handler/media.go rename to app/system/transport/handler/media.go index dcdc5e9..909d362 100644 --- a/internal/modules/system/transport/handler/media.go +++ b/app/system/transport/handler/media.go @@ -5,10 +5,10 @@ import ( "net/http" "strconv" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" - servermiddleware "kra/internal/modules/system/transport/middleware" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" + servermiddleware "kra/app/system/transport/middleware" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/menu.go b/app/system/transport/handler/menu.go similarity index 97% rename from internal/modules/system/transport/handler/menu.go rename to app/system/transport/handler/menu.go index 19f3d09..1b7a761 100644 --- a/internal/modules/system/transport/handler/menu.go +++ b/app/system/transport/handler/menu.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/navigation.go b/app/system/transport/handler/navigation.go similarity index 80% rename from internal/modules/system/transport/handler/navigation.go rename to app/system/transport/handler/navigation.go index 651e3fc..645d5dd 100644 --- a/internal/modules/system/transport/handler/navigation.go +++ b/app/system/transport/handler/navigation.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" - "kra/internal/modules/system/transport/middleware" + "kra/app/system/service" + "kra/app/system/transport/httpx" + "kra/app/system/transport/middleware" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/organization.go b/app/system/transport/handler/organization.go similarity index 98% rename from internal/modules/system/transport/handler/organization.go rename to app/system/transport/handler/organization.go index ed04b9b..a9b88cf 100644 --- a/internal/modules/system/transport/handler/organization.go +++ b/app/system/transport/handler/organization.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/parameter.go b/app/system/transport/handler/parameter.go similarity index 95% rename from internal/modules/system/transport/handler/parameter.go rename to app/system/transport/handler/parameter.go index 8158754..d5c68c6 100644 --- a/internal/modules/system/transport/handler/parameter.go +++ b/app/system/transport/handler/parameter.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/payment.go b/app/system/transport/handler/payment.go similarity index 96% rename from internal/modules/system/transport/handler/payment.go rename to app/system/transport/handler/payment.go index 576973c..c6b1246 100644 --- a/internal/modules/system/transport/handler/payment.go +++ b/app/system/transport/handler/payment.go @@ -4,9 +4,9 @@ import ( "io" "net/http" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/payment_test.go b/app/system/transport/handler/payment_test.go similarity index 95% rename from internal/modules/system/transport/handler/payment_test.go rename to app/system/transport/handler/payment_test.go index 4b3a26f..d125b18 100644 --- a/internal/modules/system/transport/handler/payment_test.go +++ b/app/system/transport/handler/payment_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "kra/internal/modules/system/dto" + "kra/app/system/dto" ) func TestWritePaymentCallbackAckDoesNotExposeError(t *testing.T) { diff --git a/internal/modules/system/transport/handler/permission.go b/app/system/transport/handler/permission.go similarity index 91% rename from internal/modules/system/transport/handler/permission.go rename to app/system/transport/handler/permission.go index 79834aa..7895b1a 100644 --- a/internal/modules/system/transport/handler/permission.go +++ b/app/system/transport/handler/permission.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/public.go b/app/system/transport/handler/public.go similarity index 97% rename from internal/modules/system/transport/handler/public.go rename to app/system/transport/handler/public.go index 4025730..f30d0dd 100644 --- a/internal/modules/system/transport/handler/public.go +++ b/app/system/transport/handler/public.go @@ -7,10 +7,10 @@ import ( "strings" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/biz" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" "github.com/mojocn/base64Captcha" diff --git a/internal/modules/system/transport/handler/query.go b/app/system/transport/handler/query.go similarity index 100% rename from internal/modules/system/transport/handler/query.go rename to app/system/transport/handler/query.go diff --git a/internal/modules/system/transport/handler/session.go b/app/system/transport/handler/session.go similarity index 86% rename from internal/modules/system/transport/handler/session.go rename to app/system/transport/handler/session.go index 193fc9e..554d223 100644 --- a/internal/modules/system/transport/handler/session.go +++ b/app/system/transport/handler/session.go @@ -1,8 +1,8 @@ package handler import ( - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/set.go b/app/system/transport/handler/set.go similarity index 100% rename from internal/modules/system/transport/handler/set.go rename to app/system/transport/handler/set.go diff --git a/internal/modules/system/transport/handler/system_config.go b/app/system/transport/handler/system_config.go similarity index 94% rename from internal/modules/system/transport/handler/system_config.go rename to app/system/transport/handler/system_config.go index 182d96c..85c803e 100644 --- a/internal/modules/system/transport/handler/system_config.go +++ b/app/system/transport/handler/system_config.go @@ -1,9 +1,9 @@ package handler import ( - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/task.go b/app/system/transport/handler/task.go similarity index 96% rename from internal/modules/system/transport/handler/task.go rename to app/system/transport/handler/task.go index 96845cd..96f7ba7 100644 --- a/internal/modules/system/transport/handler/task.go +++ b/app/system/transport/handler/task.go @@ -5,10 +5,10 @@ import ( "net/http" "time" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" - "kra/internal/modules/system/transport/middleware" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" + "kra/app/system/transport/middleware" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/user.go b/app/system/transport/handler/user.go similarity index 97% rename from internal/modules/system/transport/handler/user.go rename to app/system/transport/handler/user.go index ac81a44..13f6325 100644 --- a/internal/modules/system/transport/handler/user.go +++ b/app/system/transport/handler/user.go @@ -4,10 +4,10 @@ import ( "strconv" "time" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" - "kra/internal/modules/system/transport/middleware" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" + "kra/app/system/transport/middleware" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/handler/version.go b/app/system/transport/handler/version.go similarity index 96% rename from internal/modules/system/transport/handler/version.go rename to app/system/transport/handler/version.go index 1b027df..bc21a4a 100644 --- a/internal/modules/system/transport/handler/version.go +++ b/app/system/transport/handler/version.go @@ -7,10 +7,10 @@ import ( "strconv" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/biz" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/httpx/cookie.go b/app/system/transport/httpx/cookie.go similarity index 100% rename from internal/modules/system/transport/httpx/cookie.go rename to app/system/transport/httpx/cookie.go diff --git a/internal/modules/system/transport/httpx/response.go b/app/system/transport/httpx/response.go similarity index 100% rename from internal/modules/system/transport/httpx/response.go rename to app/system/transport/httpx/response.go diff --git a/internal/modules/system/transport/middleware/access.go b/app/system/transport/middleware/access.go similarity index 92% rename from internal/modules/system/transport/middleware/access.go rename to app/system/transport/middleware/access.go index f28ddef..cd96573 100644 --- a/internal/modules/system/transport/middleware/access.go +++ b/app/system/transport/middleware/access.go @@ -3,10 +3,10 @@ package middleware import ( "context" + "kra/app/system/biz" + "kra/app/system/service" + "kra/app/system/transport/httpx" "kra/internal/conf" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/access_log.go b/app/system/transport/middleware/access_log.go similarity index 98% rename from internal/modules/system/transport/middleware/access_log.go rename to app/system/transport/middleware/access_log.go index 81c8398..e5cdb68 100644 --- a/internal/modules/system/transport/middleware/access_log.go +++ b/app/system/transport/middleware/access_log.go @@ -9,9 +9,9 @@ import ( "strings" "time" + "kra/app/system/biz" + "kra/app/system/transport/httpx" "kra/internal/conf" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/access_log_test.go b/app/system/transport/middleware/access_log_test.go similarity index 100% rename from internal/modules/system/transport/middleware/access_log_test.go rename to app/system/transport/middleware/access_log_test.go diff --git a/internal/modules/system/transport/middleware/access_test.go b/app/system/transport/middleware/access_test.go similarity index 97% rename from internal/modules/system/transport/middleware/access_test.go rename to app/system/transport/middleware/access_test.go index 8a2d5b6..dc07439 100644 --- a/internal/modules/system/transport/middleware/access_test.go +++ b/app/system/transport/middleware/access_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/audit.go b/app/system/transport/middleware/audit.go similarity index 99% rename from internal/modules/system/transport/middleware/audit.go rename to app/system/transport/middleware/audit.go index 3684759..b305574 100644 --- a/internal/modules/system/transport/middleware/audit.go +++ b/app/system/transport/middleware/audit.go @@ -12,9 +12,9 @@ import ( "strings" "time" + "kra/app/system/dto" + "kra/app/system/service" "kra/internal/conf" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/auth.go b/app/system/transport/middleware/auth.go similarity index 95% rename from internal/modules/system/transport/middleware/auth.go rename to app/system/transport/middleware/auth.go index 149c0ae..d9e349a 100644 --- a/internal/modules/system/transport/middleware/auth.go +++ b/app/system/transport/middleware/auth.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/biz" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" "golang.org/x/sync/singleflight" diff --git a/internal/modules/system/transport/middleware/capture.go b/app/system/transport/middleware/capture.go similarity index 100% rename from internal/modules/system/transport/middleware/capture.go rename to app/system/transport/middleware/capture.go diff --git a/internal/modules/system/transport/middleware/cors.go b/app/system/transport/middleware/cors.go similarity index 100% rename from internal/modules/system/transport/middleware/cors.go rename to app/system/transport/middleware/cors.go diff --git a/internal/modules/system/transport/middleware/cors_test.go b/app/system/transport/middleware/cors_test.go similarity index 100% rename from internal/modules/system/transport/middleware/cors_test.go rename to app/system/transport/middleware/cors_test.go diff --git a/internal/modules/system/transport/middleware/error_audit.go b/app/system/transport/middleware/error_audit.go similarity index 98% rename from internal/modules/system/transport/middleware/error_audit.go rename to app/system/transport/middleware/error_audit.go index 2239ac2..d8e2da4 100644 --- a/internal/modules/system/transport/middleware/error_audit.go +++ b/app/system/transport/middleware/error_audit.go @@ -6,7 +6,7 @@ import ( "log/slog" "strings" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/error_audit_test.go b/app/system/transport/middleware/error_audit_test.go similarity index 100% rename from internal/modules/system/transport/middleware/error_audit_test.go rename to app/system/transport/middleware/error_audit_test.go diff --git a/internal/modules/system/transport/middleware/rate_limit.go b/app/system/transport/middleware/rate_limit.go similarity index 93% rename from internal/modules/system/transport/middleware/rate_limit.go rename to app/system/transport/middleware/rate_limit.go index 93e1334..b51afd3 100644 --- a/internal/modules/system/transport/middleware/rate_limit.go +++ b/app/system/transport/middleware/rate_limit.go @@ -5,8 +5,8 @@ import ( "strings" "time" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/httpx" + "kra/app/system/service" + "kra/app/system/transport/httpx" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/rate_limit_test.go b/app/system/transport/middleware/rate_limit_test.go similarity index 97% rename from internal/modules/system/transport/middleware/rate_limit_test.go rename to app/system/transport/middleware/rate_limit_test.go index 38b15e0..1bfaf8c 100644 --- a/internal/modules/system/transport/middleware/rate_limit_test.go +++ b/app/system/transport/middleware/rate_limit_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/service" + "kra/app/system/biz" + "kra/app/system/service" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/middleware/recovery.go b/app/system/transport/middleware/recovery.go similarity index 100% rename from internal/modules/system/transport/middleware/recovery.go rename to app/system/transport/middleware/recovery.go diff --git a/internal/modules/system/transport/middleware/request.go b/app/system/transport/middleware/request.go similarity index 100% rename from internal/modules/system/transport/middleware/request.go rename to app/system/transport/middleware/request.go diff --git a/internal/modules/system/transport/router/announcement.go b/app/system/transport/router/announcement.go similarity index 92% rename from internal/modules/system/transport/router/announcement.go rename to app/system/transport/router/announcement.go index 1c9fd9b..f436d04 100644 --- a/internal/modules/system/transport/router/announcement.go +++ b/app/system/transport/router/announcement.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/api.go b/app/system/transport/router/api.go similarity index 94% rename from internal/modules/system/transport/router/api.go rename to app/system/transport/router/api.go index e8c4279..d5abd0f 100644 --- a/internal/modules/system/transport/router/api.go +++ b/app/system/transport/router/api.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/api_token.go b/app/system/transport/router/api_token.go similarity index 86% rename from internal/modules/system/transport/router/api_token.go rename to app/system/transport/router/api_token.go index 2962b30..d9f847e 100644 --- a/internal/modules/system/transport/router/api_token.go +++ b/app/system/transport/router/api_token.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/audit.go b/app/system/transport/router/audit.go similarity index 96% rename from internal/modules/system/transport/router/audit.go rename to app/system/transport/router/audit.go index 842a7a2..7d14014 100644 --- a/internal/modules/system/transport/router/audit.go +++ b/app/system/transport/router/audit.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/authority.go b/app/system/transport/router/authority.go similarity index 92% rename from internal/modules/system/transport/router/authority.go rename to app/system/transport/router/authority.go index 91bc7ec..6f52dea 100644 --- a/internal/modules/system/transport/router/authority.go +++ b/app/system/transport/router/authority.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/dictionary.go b/app/system/transport/router/dictionary.go similarity index 96% rename from internal/modules/system/transport/router/dictionary.go rename to app/system/transport/router/dictionary.go index ea405f6..4ec048e 100644 --- a/internal/modules/system/transport/router/dictionary.go +++ b/app/system/transport/router/dictionary.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/email.go b/app/system/transport/router/email.go similarity index 81% rename from internal/modules/system/transport/router/email.go rename to app/system/transport/router/email.go index 804e556..d760374 100644 --- a/internal/modules/system/transport/router/email.go +++ b/app/system/transport/router/email.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/export.go b/app/system/transport/router/export.go similarity index 94% rename from internal/modules/system/transport/router/export.go rename to app/system/transport/router/export.go index bd9377f..f0b2344 100644 --- a/internal/modules/system/transport/router/export.go +++ b/app/system/transport/router/export.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/media.go b/app/system/transport/router/media.go similarity index 94% rename from internal/modules/system/transport/router/media.go rename to app/system/transport/router/media.go index dc73366..0c324ba 100644 --- a/internal/modules/system/transport/router/media.go +++ b/app/system/transport/router/media.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/menu.go b/app/system/transport/router/menu.go similarity index 92% rename from internal/modules/system/transport/router/menu.go rename to app/system/transport/router/menu.go index afd9eda..bfa0d64 100644 --- a/internal/modules/system/transport/router/menu.go +++ b/app/system/transport/router/menu.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/organization.go b/app/system/transport/router/organization.go similarity index 95% rename from internal/modules/system/transport/router/organization.go rename to app/system/transport/router/organization.go index 6e39c6c..d73ce84 100644 --- a/internal/modules/system/transport/router/organization.go +++ b/app/system/transport/router/organization.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/parameter.go b/app/system/transport/router/parameter.go similarity index 91% rename from internal/modules/system/transport/router/parameter.go rename to app/system/transport/router/parameter.go index df86ed1..4a5b3b8 100644 --- a/internal/modules/system/transport/router/parameter.go +++ b/app/system/transport/router/parameter.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/payment.go b/app/system/transport/router/payment.go similarity index 90% rename from internal/modules/system/transport/router/payment.go rename to app/system/transport/router/payment.go index 6a5e904..8a291da 100644 --- a/internal/modules/system/transport/router/payment.go +++ b/app/system/transport/router/payment.go @@ -2,7 +2,7 @@ package router import ( "github.com/gin-gonic/gin" - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" ) func RegisterPayment(group, public *gin.RouterGroup, h *handler.Payment) { diff --git a/internal/modules/system/transport/router/permission.go b/app/system/transport/router/permission.go similarity index 86% rename from internal/modules/system/transport/router/permission.go rename to app/system/transport/router/permission.go index f94ca84..d51b93f 100644 --- a/internal/modules/system/transport/router/permission.go +++ b/app/system/transport/router/permission.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/public.go b/app/system/transport/router/public.go similarity index 88% rename from internal/modules/system/transport/router/public.go rename to app/system/transport/router/public.go index 758dd5a..280e829 100644 --- a/internal/modules/system/transport/router/public.go +++ b/app/system/transport/router/public.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/system_config.go b/app/system/transport/router/system_config.go similarity index 91% rename from internal/modules/system/transport/router/system_config.go rename to app/system/transport/router/system_config.go index 43c18bc..6ae244f 100644 --- a/internal/modules/system/transport/router/system_config.go +++ b/app/system/transport/router/system_config.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/task.go b/app/system/transport/router/task.go similarity index 91% rename from internal/modules/system/transport/router/task.go rename to app/system/transport/router/task.go index dafa329..64a0084 100644 --- a/internal/modules/system/transport/router/task.go +++ b/app/system/transport/router/task.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/user.go b/app/system/transport/router/user.go similarity index 95% rename from internal/modules/system/transport/router/user.go rename to app/system/transport/router/user.go index 5231121..9ade4d0 100644 --- a/internal/modules/system/transport/router/user.go +++ b/app/system/transport/router/user.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/internal/modules/system/transport/router/version.go b/app/system/transport/router/version.go similarity index 90% rename from internal/modules/system/transport/router/version.go rename to app/system/transport/router/version.go index ad3eaf4..d9ec575 100644 --- a/internal/modules/system/transport/router/version.go +++ b/app/system/transport/router/version.go @@ -1,7 +1,7 @@ package router import ( - "kra/internal/modules/system/transport/handler" + "kra/app/system/transport/handler" "github.com/gin-gonic/gin" ) diff --git a/app/system/transport/server/routes.go b/app/system/transport/server/routes.go new file mode 100644 index 0000000..d67b630 --- /dev/null +++ b/app/system/transport/server/routes.go @@ -0,0 +1,44 @@ +package server + +import ( + "kra/app/system/transport/handler" + serverrouter "kra/app/system/transport/router" + platformmodule "kra/pkg/module" + + "github.com/gin-gonic/gin" +) + +type Routes struct { + handlers *handler.Set +} + +func NewRoutes(handlers *handler.Set) *Routes { return &Routes{handlers: handlers} } + +var _ platformmodule.RouteRegistrar = (*Routes)(nil) + +func (r *Routes) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.Engine) { + if r == nil || r.handlers == nil { + return + } + serverrouter.RegisterPublic(public, engine, r.handlers.Public) + serverrouter.RegisterUser(private, r.handlers.User) + serverrouter.RegisterNavigation(private, r.handlers.Navigation) + serverrouter.RegisterSession(private, r.handlers.Session) + serverrouter.RegisterAuthority(private, r.handlers.Authority) + serverrouter.RegisterMenu(private, r.handlers.Menu) + serverrouter.RegisterAPI(private, public, engine, r.handlers.API) + serverrouter.RegisterPermission(private, r.handlers.Permission) + serverrouter.RegisterOrganization(private, r.handlers.Organization) + serverrouter.RegisterDictionary(private, r.handlers.Dictionary) + serverrouter.RegisterParameter(private, r.handlers.Parameter) + serverrouter.RegisterAPIToken(private, r.handlers.APIToken) + serverrouter.RegisterSystemConfig(private, r.handlers.SystemConfig) + serverrouter.RegisterVersion(private, r.handlers.Version) + serverrouter.RegisterExport(private, public, r.handlers.Export) + serverrouter.RegisterAudit(private, public, r.handlers.Audit) + serverrouter.RegisterTask(private, r.handlers.Task) + serverrouter.RegisterMedia(private, r.handlers.Media) + serverrouter.RegisterAnnouncement(private, public, r.handlers.Announcement) + serverrouter.RegisterEmail(private, r.handlers.Email) + serverrouter.RegisterPayment(private, public, r.handlers.Payment) +} diff --git a/app/system/transport/server/server.go b/app/system/transport/server/server.go new file mode 100644 index 0000000..abe2465 --- /dev/null +++ b/app/system/transport/server/server.go @@ -0,0 +1,10 @@ +package server + +import ( + "kra/app/system/transport/handler" + + "github.com/google/wire" +) + +// ProviderSet is server providers. +var ProviderSet = wire.NewSet(NewGinEngineWithRuntime, NewGinServer, NewRoutes, handler.NewAuthority, handler.NewMenu, handler.NewAPI, handler.NewPermission, handler.NewOrganization, handler.NewAnnouncement, handler.NewEmail, handler.NewPayment, handler.NewTask, handler.NewMedia, handler.NewAudit, handler.NewExport, handler.NewVersion, handler.NewDictionary, handler.NewParameter, handler.NewAPIToken, handler.NewSystemConfig, handler.NewPublic, handler.NewUser, handler.NewNavigation, handler.NewSession, handler.NewSet) diff --git a/internal/modules/system/utils/configutil/json.go b/app/system/utils/configutil/json.go similarity index 100% rename from internal/modules/system/utils/configutil/json.go rename to app/system/utils/configutil/json.go diff --git a/internal/modules/system/utils/configutil/json_test.go b/app/system/utils/configutil/json_test.go similarity index 100% rename from internal/modules/system/utils/configutil/json_test.go rename to app/system/utils/configutil/json_test.go diff --git a/internal/modules/system/utils/paymentutil/README.md b/app/system/utils/paymentutil/README.md similarity index 100% rename from internal/modules/system/utils/paymentutil/README.md rename to app/system/utils/paymentutil/README.md diff --git a/internal/modules/system/utils/paymentutil/amount.go b/app/system/utils/paymentutil/amount.go similarity index 100% rename from internal/modules/system/utils/paymentutil/amount.go rename to app/system/utils/paymentutil/amount.go diff --git a/internal/modules/system/utils/paymentutil/amount_test.go b/app/system/utils/paymentutil/amount_test.go similarity index 100% rename from internal/modules/system/utils/paymentutil/amount_test.go rename to app/system/utils/paymentutil/amount_test.go diff --git a/internal/modules/system/utils/paymentutil/json.go b/app/system/utils/paymentutil/json.go similarity index 100% rename from internal/modules/system/utils/paymentutil/json.go rename to app/system/utils/paymentutil/json.go diff --git a/internal/modules/system/utils/paymentutil/json_test.go b/app/system/utils/paymentutil/json_test.go similarity index 100% rename from internal/modules/system/utils/paymentutil/json_test.go rename to app/system/utils/paymentutil/json_test.go diff --git a/internal/modules/system/utils/paymentutil/signing.go b/app/system/utils/paymentutil/signing.go similarity index 100% rename from internal/modules/system/utils/paymentutil/signing.go rename to app/system/utils/paymentutil/signing.go diff --git a/internal/modules/system/utils/paymentutil/signing_test.go b/app/system/utils/paymentutil/signing_test.go similarity index 100% rename from internal/modules/system/utils/paymentutil/signing_test.go rename to app/system/utils/paymentutil/signing_test.go diff --git a/internal/modules/system/utils/paymentutil/status.go b/app/system/utils/paymentutil/status.go similarity index 100% rename from internal/modules/system/utils/paymentutil/status.go rename to app/system/utils/paymentutil/status.go diff --git a/internal/modules/system/utils/paymentutil/xml.go b/app/system/utils/paymentutil/xml.go similarity index 100% rename from internal/modules/system/utils/paymentutil/xml.go rename to app/system/utils/paymentutil/xml.go diff --git a/internal/modules/system/worker/task_executor.go b/app/system/worker/task_executor.go similarity index 86% rename from internal/modules/system/worker/task_executor.go rename to app/system/worker/task_executor.go index 85e39c5..0c31fb6 100644 --- a/internal/modules/system/worker/task_executor.go +++ b/app/system/worker/task_executor.go @@ -14,20 +14,26 @@ import ( "syscall" "time" + "kra/app/system/biz" "kra/internal/conf" - "kra/internal/modules/system/biz" ) type TaskExecutor struct { tasks *biz.TaskUsecase media *biz.MediaUsecase runtime *conf.Runtime + methods biz.TaskMethodRegistry } func NewTaskExecutor(tasks *biz.TaskUsecase, media *biz.MediaUsecase, runtime *conf.Runtime) *TaskExecutor { - executor := &TaskExecutor{tasks: tasks, media: media, runtime: runtime} - registerTaskMethods(executor) - return executor + return NewTaskExecutorWithRegistry(tasks, media, runtime, biz.DefaultTaskMethodRegistry()) +} + +func NewTaskExecutorWithRegistry(tasks *biz.TaskUsecase, media *biz.MediaUsecase, runtime *conf.Runtime, methods biz.TaskMethodRegistry) *TaskExecutor { + if methods == nil { + methods = biz.DefaultTaskMethodRegistry() + } + return &TaskExecutor{tasks: tasks, media: media, runtime: runtime, methods: methods} } func privateIP(ip net.IP) bool { @@ -104,9 +110,15 @@ func truncateTaskText(value string) string { } func (e *TaskExecutor) runMethod(ctx context.Context, task *biz.TimedTask) error { - method, ok := biz.TaskMethodByName(task.MethodName) + var method biz.TaskMethodFunc + var ok bool + if e.methods != nil { + method, ok = e.methods.Lookup(task.MethodName) + } else { + method, ok = biz.TaskMethodByName(task.MethodName) + } if !ok { - return fmt.Errorf("方法 %s 未注册(需在 internal/worker/task_registry.go 经 biz.RegisterTaskMethod 注册)", task.MethodName) + return fmt.Errorf("方法 %s 未注册(需通过 platform/task.Registry 注册)", task.MethodName) } runCtx, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() diff --git a/internal/modules/system/worker/task_executor_test.go b/app/system/worker/task_executor_test.go similarity index 98% rename from internal/modules/system/worker/task_executor_test.go rename to app/system/worker/task_executor_test.go index e48477c..525697e 100644 --- a/internal/modules/system/worker/task_executor_test.go +++ b/app/system/worker/task_executor_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) func TestPrivateIP(t *testing.T) { diff --git a/app/system/worker/task_registry.go b/app/system/worker/task_registry.go new file mode 100644 index 0000000..65cdc0c --- /dev/null +++ b/app/system/worker/task_registry.go @@ -0,0 +1,45 @@ +package worker + +import ( + "context" + "encoding/json" + + "kra/app/system/biz" + "kra/internal/conf" + platformtask "kra/pkg/task" +) + +// TaskMethods is the system module's dependency-bearing task contribution. +// Other modules provide their own contributor instead of editing this file. +type TaskMethods struct { + tasks *biz.TaskUsecase + media *biz.MediaUsecase + runtime *conf.Runtime +} + +func NewTaskMethods(tasks *biz.TaskUsecase, media *biz.MediaUsecase, runtime *conf.Runtime) *TaskMethods { + return &TaskMethods{tasks: tasks, media: media, runtime: runtime} +} + +var _ platformtask.Contributor = (*TaskMethods)(nil) + +func (methods *TaskMethods) RegisterTasks(registry *platformtask.Registry) { + if methods == nil || registry == nil { + return + } + registry.Register(platformtask.Method{ + Name: biz.TaskMethodClearDB, Description: "清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Run: func(ctx context.Context, _ json.RawMessage) error { + return methods.tasks.CleanupLogs(ctx) + }, + }) + registry.Register(platformtask.Method{ + Name: biz.TaskMethodUploads, Description: "清理过期大文件上传会话", Run: func(ctx context.Context, _ json.RawMessage) error { + ttl := 24 + config := methods.runtime.Admin() + if config != nil && config.Media != nil && config.Media.SessionTtl > 0 { + ttl = int(config.Media.SessionTtl) + } + return methods.media.CleanupStale(ctx, ttl) + }, + }) +} diff --git a/internal/modules/system/worker/task_runtime_test.go b/app/system/worker/task_runtime_test.go similarity index 99% rename from internal/modules/system/worker/task_runtime_test.go rename to app/system/worker/task_runtime_test.go index 9fa260f..8095f35 100644 --- a/internal/modules/system/worker/task_runtime_test.go +++ b/app/system/worker/task_runtime_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type workerTaskRepo struct { diff --git a/internal/modules/system/worker/task_scheduler.go b/app/system/worker/task_scheduler.go similarity index 99% rename from internal/modules/system/worker/task_scheduler.go rename to app/system/worker/task_scheduler.go index 6753f20..89f9ae0 100644 --- a/internal/modules/system/worker/task_scheduler.go +++ b/app/system/worker/task_scheduler.go @@ -10,7 +10,7 @@ import ( "time" "github.com/robfig/cron/v3" - "kra/internal/modules/system/biz" + "kra/app/system/biz" ) type TaskScheduler struct { diff --git a/internal/modules/system/worker/task_scheduler_test.go b/app/system/worker/task_scheduler_test.go similarity index 100% rename from internal/modules/system/worker/task_scheduler_test.go rename to app/system/worker/task_scheduler_test.go diff --git a/app/system/worker/worker.go b/app/system/worker/worker.go new file mode 100644 index 0000000..816ea4e --- /dev/null +++ b/app/system/worker/worker.go @@ -0,0 +1,6 @@ +package worker + +import "github.com/google/wire" + +// ProviderSet contains background task runtime providers. +var ProviderSet = wire.NewSet(NewTaskMethods, NewTaskExecutorWithRegistry, NewTaskScheduler, NewTaskRuntime) diff --git a/cmd/kratos-admin/main.go b/cmd/kratos-admin/main.go index ea39c0c..0dc24b3 100644 --- a/cmd/kratos-admin/main.go +++ b/cmd/kratos-admin/main.go @@ -9,11 +9,11 @@ import ( "path/filepath" "strings" + "kra/app/system/dto" + "kra/app/system/service" + "kra/app/system/worker" "kra/internal/conf" "kra/internal/logging" - "kra/internal/modules/system/dto" - "kra/internal/modules/system/service" - "kra/internal/modules/system/worker" "github.com/go-kratos/kratos/v3" "github.com/go-kratos/kratos/v3/config" diff --git a/cmd/kratos-admin/wire.go b/cmd/kratos-admin/wire.go index e3df191..b3761a2 100644 --- a/cmd/kratos-admin/wire.go +++ b/cmd/kratos-admin/wire.go @@ -8,16 +8,18 @@ package main import ( "log/slog" + "kra/app/admin" + "kra/app/system/biz" + "kra/app/system/data" + "kra/app/system/initialize" + "kra/app/system/integration" + "kra/app/system/integration/cache" + "kra/app/system/service" + "kra/app/system/transport/server" + "kra/app/system/worker" "kra/internal/conf" "kra/internal/logging" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/data" - "kra/internal/modules/system/initialize" - "kra/internal/modules/system/integration" - "kra/internal/modules/system/integration/cache" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/server" - "kra/internal/modules/system/worker" + platformtask "kra/pkg/task" "github.com/go-kratos/kratos/v3" "github.com/google/wire" @@ -28,11 +30,15 @@ func wireApp(*conf.Server, *conf.Runtime, *slog.Logger, *logging.ReloadableLogge panic(wire.Build( server.ProviderSet, worker.ProviderSet, + app.Catalog, + app.TaskRegistry, + app.Runtime, data.ProviderSet, integration.ProviderSet, initialize.ProviderSet, wire.Bind(new(initialize.Backend), new(*data.Data)), wire.Bind(new(cache.RedisProvider), new(*data.Data)), + wire.Bind(new(biz.TaskMethodRegistry), new(*platformtask.Registry)), biz.ProviderSet, service.ProviderSet, newApp, diff --git a/cmd/kratos-admin/wire_gen.go b/cmd/kratos-admin/wire_gen.go index eb6c3cd..23a2c83 100644 --- a/cmd/kratos-admin/wire_gen.go +++ b/cmd/kratos-admin/wire_gen.go @@ -8,20 +8,21 @@ package main import ( "github.com/go-kratos/kratos/v3" + "kra/app/admin" + "kra/app/system/biz" + "kra/app/system/data" + "kra/app/system/data/payment" + "kra/app/system/data/repository" + "kra/app/system/initialize" + "kra/app/system/integration/cache" + "kra/app/system/integration/email" + "kra/app/system/integration/storage" + "kra/app/system/service" + "kra/app/system/transport/handler" + "kra/app/system/transport/server" + "kra/app/system/worker" "kra/internal/conf" "kra/internal/logging" - "kra/internal/modules/system/biz" - "kra/internal/modules/system/data" - "kra/internal/modules/system/data/payment" - "kra/internal/modules/system/data/repository" - "kra/internal/modules/system/initialize" - "kra/internal/modules/system/integration/cache" - "kra/internal/modules/system/integration/email" - "kra/internal/modules/system/integration/storage" - "kra/internal/modules/system/service" - "kra/internal/modules/system/transport/handler" - "kra/internal/modules/system/transport/server" - "kra/internal/modules/system/worker" "log/slog" ) @@ -37,7 +38,8 @@ func wireApp(confServer *conf.Server, runtime *conf.Runtime, logger *slog.Logger if err != nil { return nil, nil, err } - dataData, cleanup, err := data.NewData(runtime, logger, reloadable) + catalog := app.Catalog() + dataData, cleanup, err := data.NewData(runtime, logger, reloadable, catalog) if err != nil { return nil, nil, err } @@ -45,6 +47,21 @@ func wireApp(confServer *conf.Server, runtime *conf.Runtime, logger *slog.Logger apiRepo := system.NewAPIRepo(dataData) accessControlUsecase := biz.NewAccessControlUsecase(authorityAccessRepo, apiRepo) accessControlService := service.NewAccessControlService(accessControlUsecase) + userRepo := system.NewUserRepo(dataData) + userUsecase := biz.NewUserUsecase(userRepo) + securityRepo := system.NewSecurityRepo(dataData) + bizCache := cache.New(dataData) + runtimeSettings := system.NewRuntimeSettings(runtime) + apiTokenRepo := system.NewAPITokenRepo(dataData) + tokenUsecase := biz.NewTokenUsecase(apiTokenRepo) + securityUsecase := biz.NewSecurityUsecase(securityRepo, bizCache, runtimeSettings, tokenUsecase) + tokenIssuer := system.NewTokenIssuer(runtimeSettings) + auditRecordRepo := system.NewAuditRecorderRepo(dataData) + authenticationUsecase := biz.NewAuthenticationUsecase(userUsecase, securityUsecase, tokenIssuer, auditRecordRepo) + authService := service.NewAuthService(authenticationUsecase) + securityService := service.NewSecurityService(securityUsecase) + auditRecorderUsecase := biz.NewAuditRecorderUsecase(auditRecordRepo) + auditRecorder := service.NewAuditRecorder(auditRecorderUsecase) authorityUsecase := biz.NewAuthorityUsecase(authorityAccessRepo) authorityService := service.NewAuthorityService(authorityUsecase) authority := handler.NewAuthority(authorityService) @@ -53,7 +70,6 @@ func wireApp(confServer *conf.Server, runtime *conf.Runtime, logger *slog.Logger menuService := service.NewMenuService(menuUsecase) menu := handler.NewMenu(menuService) apiUsecase := biz.NewAPIUsecase(apiRepo) - runtimeSettings := system.NewRuntimeSettings(runtime) apiService := service.NewAPIService(apiUsecase, runtimeSettings) api := handler.NewAPI(apiService) permissionRepo := system.NewPermissionRepo(dataData) @@ -81,10 +97,11 @@ func wireApp(confServer *conf.Server, runtime *conf.Runtime, logger *slog.Logger paymentService := service.NewPaymentService(paymentUsecase) handlerPayment := handler.NewPayment(paymentService) taskRepo := system.NewTaskRepo(dataData) - taskUsecase := biz.NewTaskUsecase(taskRepo) + registry := app.TaskRegistry(catalog) + taskUsecase := biz.NewTaskUsecaseWithRegistry(taskRepo, registry) mediaRepo := system.NewMediaRepo(dataData) mediaUsecase := biz.NewMediaUsecase(mediaRepo, reloadable, runtimeSettings) - taskExecutor := worker.NewTaskExecutor(taskUsecase, mediaUsecase, runtime) + taskExecutor := worker.NewTaskExecutorWithRegistry(taskUsecase, mediaUsecase, runtime, registry) taskScheduler := worker.NewTaskScheduler(taskUsecase, authorityUsecase, taskExecutor, logger) taskRuntime := worker.NewTaskRuntime(taskScheduler) taskApplicationUsecase := biz.NewTaskApplicationUsecase(taskUsecase, taskRuntime) @@ -95,16 +112,12 @@ func wireApp(confServer *conf.Server, runtime *conf.Runtime, logger *slog.Logger auditQueryRepo := system.NewAuditRepo(dataData) auditUsecase := biz.NewAuditUsecase(auditQueryRepo) auditService := service.NewAuditService(auditUsecase) - auditRecordRepo := system.NewAuditRecorderRepo(dataData) - auditRecorderUsecase := biz.NewAuditRecorderUsecase(auditRecordRepo) - auditRecorder := service.NewAuditRecorder(auditRecorderUsecase) logFileRepo := system.NewLogFileRepo(dataData) logViewerUsecase := biz.NewLogViewerUsecase(logFileRepo) logViewerService := service.NewLogViewerService(logViewerUsecase) audit := handler.NewAudit(auditService, auditRecorder, logViewerService, logger) exportRepo := system.NewExportRepo(dataData) exportUsecase := biz.NewExportUsecase(exportRepo) - bizCache := cache.New(dataData) exportService := service.NewExportService(exportUsecase, bizCache) export := handler.NewExport(exportService) versionRepo := system.NewVersionRepo(dataData) @@ -119,32 +132,25 @@ func wireApp(confServer *conf.Server, runtime *conf.Runtime, logger *slog.Logger parameterUsecase := biz.NewParameterUsecase(parameterRepo) parameterService := service.NewParameterService(parameterUsecase) parameter := handler.NewParameter(parameterService) - apiTokenRepo := system.NewAPITokenRepo(dataData) - tokenUsecase := biz.NewTokenUsecase(apiTokenRepo) - tokenIssuer := system.NewTokenIssuer(runtimeSettings) tokenService := service.NewTokenService(tokenUsecase, tokenIssuer) apiToken := handler.NewAPIToken(tokenService) - initializationRepo := initialize.NewRepo(dataData) + initializationRepo := initialize.NewRepo(dataData, catalog) systemConfigUsecase := biz.NewSystemConfigUsecase(initializationRepo, taskRuntime) systemConfigService := service.NewSystemConfigService(systemConfigUsecase, runtimeSettings) - securityRepo := system.NewSecurityRepo(dataData) - securityUsecase := biz.NewSecurityUsecase(securityRepo, bizCache, runtimeSettings, tokenUsecase) - securityService := service.NewSecurityService(securityUsecase) systemConfig := handler.NewSystemConfig(systemConfigService, securityService) - userRepo := system.NewUserRepo(dataData) - userUsecase := biz.NewUserUsecase(userRepo) - authenticationUsecase := biz.NewAuthenticationUsecase(userUsecase, securityUsecase, tokenIssuer, auditRecordRepo) - authService := service.NewAuthService(authenticationUsecase) public := handler.NewPublic(authService, systemConfigService, securityService) userService := service.NewUserService(userUsecase, securityService) user := handler.NewUser(userService, authService) navigation := handler.NewNavigation(userService) session := handler.NewSession(tokenService) set := handler.NewSet(authority, menu, api, permission, organization, announcement, handlerEmail, handlerPayment, task, media, audit, export, version, dictionary, parameter, apiToken, systemConfig, public, user, navigation, session) - engine := server.NewGinEngine(runtime, accessControlService, set, authService, securityService, auditRecorder, logger, string2) + routes := server.NewRoutes(set) + taskMethods := worker.NewTaskMethods(taskUsecase, mediaUsecase, runtime) + moduleRuntime := app.Runtime(routes, taskMethods, registry) + engine := server.NewGinEngineWithRuntime(runtime, accessControlService, authService, securityService, auditRecorder, logger, string2, moduleRuntime) httpServer := server.NewGinServer(confServer, engine) - app := newApp(logger, httpServer, taskScheduler, auditRecorder, reloadableLogger) - return app, func() { + kratosApp := newApp(logger, httpServer, taskScheduler, auditRecorder, reloadableLogger) + return kratosApp, func() { cleanup() }, nil } diff --git a/internal/README.md b/internal/README.md new file mode 100644 index 0000000..f563e98 --- /dev/null +++ b/internal/README.md @@ -0,0 +1,31 @@ +# Internal Architecture + +本项目采用参考 Kratos beer-shop 的模块化单体结构:先按业务边界垂直拆分,再在 +模块内部保持 Kratos 的 `service -> biz <- data` 依赖方向。 + +```text +internal/ + app/ 应用组合根,只决定启用哪些模块 + conf/ 运行配置 + logging/ 公共日志基础设施 + modules/ + system/ 稳定的后台系统能力 + biz/ 领域对象、用例、仓储接口 + data/ PO、仓储实现、系统持久化 + service/ DTO 与 DO 转换 + transport/ HTTP handler、router、middleware + initialize/ system 首次安装编排 + integration/ 外部服务适配器 + worker/ system 后台任务 + platform/ 不含业务语义的跨模块机制 + database/ + module/ + task/ +``` + +依赖方向:`cmd -> app -> modules -> platform`。`platform` 不得引用业务模块;业务 +模块之间优先通过 `biz` 接口协作,不直接引用对方的 `data` 或 `transport`。 + +新增模块时,在 `internal/modules/` 内完成自己的分层,并在 +`internal/app/catalog.go` 注册迁移、菜单/API、默认任务、任务实现和路由。组合根 +是唯一允许同时知道多个模块具体类型的位置。 diff --git a/internal/logging/zap_test.go b/internal/logging/zap_test.go index 42e076f..2a9700f 100644 --- a/internal/logging/zap_test.go +++ b/internal/logging/zap_test.go @@ -89,7 +89,7 @@ func TestErrorEntryIncludesFinalApplicationSource(t *testing.T) { if err := os.WriteFile(filename, []byte(content), 0o600); err != nil { t.Fatal(err) } - entry := errorEntryFromZap(zapcore.Entry{Message: "task failed", Level: zapcore.ErrorLevel, Stack: "kra/internal/modules/system/worker.execute\n" + filename + ":4"}, nil) + entry := errorEntryFromZap(zapcore.Entry{Message: "task failed", Level: zapcore.ErrorLevel, Stack: "kra/app/system/worker.execute\n" + filename + ":4"}, nil) if !strings.Contains(entry.Info, "最终调用方法:"+filename+":4 (execute lines 3-5)") || !strings.Contains(entry.Info, "func execute()") { t.Fatalf("expected final caller source in error entry: %s", entry.Info) } diff --git a/internal/modules/README.md b/internal/modules/README.md index ef8e86d..b05c72d 100644 --- a/internal/modules/README.md +++ b/internal/modules/README.md @@ -1,7 +1,8 @@ # Internal Modules -业务代码按模块组织在 `internal/modules/` 下。每个模块可以拥有自己的 -`biz`、`data`、`service` 和 `transport`,模块之间通过接口和集成层协作。 +参考 Kratos beer-shop 的垂直业务拆分方式,业务代码按模块组织在 +`internal/modules/` 下。当前项目是模块化单体,因此共享一个进程和组合根, +但每个模块仍独立拥有 `biz`、`data`、`service`、`transport` 和初始化贡献。 ## 当前模块 @@ -14,3 +15,18 @@ 处理器继续添加到 `internal/biz`、`internal/data`、`internal/service` 等根目录。 数据库表和迁移由业务模块自己的 `data` 包负责;只有数据库连接生命周期和通用 迁移执行器属于 `internal/platform/database`。 + +模块通过 `internal/app/catalog.go` 接入组合根: + +- `module.Definition.Migrations`:模块自己的表结构迁移 +- `module.Definition.Surface`:菜单和 API 元数据,首次初始化时统一写入系统表 +- `module.Definition.TimedTasks`:模块默认定时任务记录 +- `module.Definition.Tasks`:无状态的进程内任务方法 +- `module.RouteRegistrar`:需要依赖 Handler 的路由注册器,在 `app.Runtime` 中组合 + +无依赖的任务方法可以放进 `Definition.Tasks`。需要仓储或用例依赖的任务方法由 +模块实现 `task.Contributor`,再由 `internal/app` 激活。新增模块只修改应用组合根, +不修改 `system` 的初始化、worker、路由或数据层。 + +`integration` 是外部系统适配器,不是通用工具;只有实现了稳定跨模块协议的能力 +才上移到 `platform`。`utils` 仅保留无状态、无业务语义且确实被本模块复用的函数。 diff --git a/internal/modules/system/adminsurface/surface.go b/internal/modules/system/adminsurface/surface.go deleted file mode 100644 index bc2ad92..0000000 --- a/internal/modules/system/adminsurface/surface.go +++ /dev/null @@ -1,25 +0,0 @@ -// Package adminsurface defines administration UI metadata contributed by -// business modules. The system data module owns how this metadata is stored. -package adminsurface - -type Menu struct { - Name string - Path string - ParentName string - Component string - Title string - Icon string - Sort int -} - -type API struct { - Path string - Method string - APIGroup string - Description string -} - -type Surface struct { - Menus []Menu - APIs []API -} diff --git a/internal/modules/system/biz/task_registry.go b/internal/modules/system/biz/task_registry.go deleted file mode 100644 index ac9f7c1..0000000 --- a/internal/modules/system/biz/task_registry.go +++ /dev/null @@ -1,66 +0,0 @@ -package biz - -import ( - "context" - "encoding/json" - "sort" - "sync" -) - -// TaskMethodFunc is the execution contract for a registered in-process task. -// Implementations are responsible for decoding params and honoring ctx cancellation. -type TaskMethodFunc func(ctx context.Context, params json.RawMessage) error - -type TaskMethod struct { - Name string - Description string -} - -type taskMethodEntry struct { - meta TaskMethod - fn TaskMethodFunc -} - -var taskMethodRegistry = struct { - sync.RWMutex - methods map[string]taskMethodEntry -}{methods: make(map[string]taskMethodEntry)} - -// RegisterTaskMethod registers an in-process task. Re-registering the same name -// replaces the previous implementation so startup registration remains idempotent. -func RegisterTaskMethod(name, description string, fn TaskMethodFunc) { - taskMethodRegistry.Lock() - defer taskMethodRegistry.Unlock() - taskMethodRegistry.methods[name] = taskMethodEntry{ - meta: TaskMethod{Name: name, Description: description}, - fn: fn, - } -} - -// TaskMethodByName returns the registered function for name. -func TaskMethodByName(name string) (TaskMethodFunc, bool) { - taskMethodRegistry.RLock() - defer taskMethodRegistry.RUnlock() - method, ok := taskMethodRegistry.methods[name] - if !ok { - return nil, false - } - return method.fn, true -} - -// RegisteredTaskMethods returns task metadata in a stable name order. -func RegisteredTaskMethods() []TaskMethod { - taskMethodRegistry.RLock() - defer taskMethodRegistry.RUnlock() - methods := make([]TaskMethod, 0, len(taskMethodRegistry.methods)) - for _, method := range taskMethodRegistry.methods { - methods = append(methods, method.meta) - } - sort.Slice(methods, func(i, j int) bool { return methods[i].Name < methods[j].Name }) - return methods -} - -func registeredTaskMethod(name string) bool { - _, ok := TaskMethodByName(name) - return ok -} diff --git a/internal/modules/system/data/migrations.go b/internal/modules/system/data/migrations.go deleted file mode 100644 index 41f1d01..0000000 --- a/internal/modules/system/data/migrations.go +++ /dev/null @@ -1,23 +0,0 @@ -package data - -import ( - datapayment "kra/internal/modules/system/data/payment" - datasystem "kra/internal/modules/system/data/repository" - "kra/internal/platform/database/migration" - - "gorm.io/gorm" -) - -// migrateAll is the single data-layer migration entry point. Module-specific -// schema work stays with the module that owns its persistent objects. -func migrateAll(db *gorm.DB) error { - steps := []migration.Step{{ - ID: "202608200001_data_infrastructure", - Migrate: func(db *gorm.DB) error { - return migration.CreateMissingTables(db, &integrationConfigPO{}) - }, - }} - steps = append(steps, datasystem.Migrations()...) - steps = append(steps, datapayment.Migrations()...) - return migration.Run(db, steps) -} diff --git a/internal/modules/system/transport/server/server.go b/internal/modules/system/transport/server/server.go deleted file mode 100644 index 714a93a..0000000 --- a/internal/modules/system/transport/server/server.go +++ /dev/null @@ -1,10 +0,0 @@ -package server - -import ( - "kra/internal/modules/system/transport/handler" - - "github.com/google/wire" -) - -// ProviderSet is server providers. -var ProviderSet = wire.NewSet(NewGinEngine, NewGinServer, handler.NewAuthority, handler.NewMenu, handler.NewAPI, handler.NewPermission, handler.NewOrganization, handler.NewAnnouncement, handler.NewEmail, handler.NewPayment, handler.NewTask, handler.NewMedia, handler.NewAudit, handler.NewExport, handler.NewVersion, handler.NewDictionary, handler.NewParameter, handler.NewAPIToken, handler.NewSystemConfig, handler.NewPublic, handler.NewUser, handler.NewNavigation, handler.NewSession, handler.NewSet) diff --git a/internal/modules/system/worker/task_registry.go b/internal/modules/system/worker/task_registry.go deleted file mode 100644 index a083a27..0000000 --- a/internal/modules/system/worker/task_registry.go +++ /dev/null @@ -1,32 +0,0 @@ -package worker - -import ( - "context" - "encoding/json" - - "kra/internal/modules/system/biz" -) - -// registerTaskMethods defines the in-process methods available to the task -// management page. Add application-specific registrations here. -func registerTaskMethods(executor *TaskExecutor) { - biz.RegisterTaskMethod( - biz.TaskMethodClearDB, - "清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", - func(ctx context.Context, _ json.RawMessage) error { - return executor.tasks.CleanupLogs(ctx) - }, - ) - biz.RegisterTaskMethod( - biz.TaskMethodUploads, - "清理过期大文件上传会话", - func(ctx context.Context, _ json.RawMessage) error { - ttl := 24 - config := executor.runtime.Admin() - if config != nil && config.Media != nil && config.Media.SessionTtl > 0 { - ttl = int(config.Media.SessionTtl) - } - return executor.media.CleanupStale(ctx, ttl) - }, - ) -} diff --git a/internal/modules/system/worker/worker.go b/internal/modules/system/worker/worker.go deleted file mode 100644 index 9a4a5d6..0000000 --- a/internal/modules/system/worker/worker.go +++ /dev/null @@ -1,6 +0,0 @@ -package worker - -import "github.com/google/wire" - -// ProviderSet contains background task runtime providers. -var ProviderSet = wire.NewSet(NewTaskExecutor, NewTaskScheduler, NewTaskRuntime) diff --git a/internal/platform/README.md b/internal/platform/README.md deleted file mode 100644 index eb1bae3..0000000 --- a/internal/platform/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Platform - -这里放跨业务模块的基础设施,不放具体业务表或业务用例。 - -当前包含 `database`:数据库驱动、连接生命周期、GORM 日志、分页和迁移执行器。 diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 0000000..986e4b3 --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,13 @@ +# Platform + +这里放跨业务模块的基础设施,不放具体业务表或业务用例。 + +当前包含: + +- `database`:跨模块共享的 GORM 支持、分页和迁移执行器 +- `module`:模块迁移、后台元数据和路由注册协议 +- `task`:跨模块共享的进程内任务注册表和贡献协议 + +平台层只能提供机制,不能引用 `internal/modules/*`。数据库配置加载、系统集成配置 +和系统表仍由 system 模块负责;未来提炼公共连接管理时,也必须先形成不带系统 +业务语义的稳定接口,再移动到这里。 diff --git a/internal/platform/database/gormkit/README.md b/pkg/database/gormkit/README.md similarity index 100% rename from internal/platform/database/gormkit/README.md rename to pkg/database/gormkit/README.md diff --git a/internal/platform/database/gormkit/logger.go b/pkg/database/gormkit/logger.go similarity index 100% rename from internal/platform/database/gormkit/logger.go rename to pkg/database/gormkit/logger.go diff --git a/internal/platform/database/migration/runner.go b/pkg/database/migration/runner.go similarity index 100% rename from internal/platform/database/migration/runner.go rename to pkg/database/migration/runner.go diff --git a/internal/platform/database/migration/schema.go b/pkg/database/migration/schema.go similarity index 100% rename from internal/platform/database/migration/schema.go rename to pkg/database/migration/schema.go diff --git a/internal/platform/database/migration/schema_test.go b/pkg/database/migration/schema_test.go similarity index 100% rename from internal/platform/database/migration/schema_test.go rename to pkg/database/migration/schema_test.go diff --git a/internal/platform/database/pagination/pagination.go b/pkg/database/pagination/pagination.go similarity index 100% rename from internal/platform/database/pagination/pagination.go rename to pkg/database/pagination/pagination.go diff --git a/pkg/module/module.go b/pkg/module/module.go new file mode 100644 index 0000000..432943e --- /dev/null +++ b/pkg/module/module.go @@ -0,0 +1,102 @@ +// Package module defines the small contracts shared by application modules. +// A module contributes its own schema, seed data, admin surface and runtime +// hooks without depending on the built-in system implementation. +package module + +import ( + "github.com/gin-gonic/gin" + "kra/pkg/database/migration" + "kra/pkg/task" +) + +type Menu struct { + Name, Path, ParentName, Component, Title, Icon string + Sort int +} + +type API struct { + Path, Method, Group, Description string +} + +type Surface struct { + Menus []Menu + APIs []API +} + +type TimedTask struct { + Name, Description, Spec, MethodName string + WithSeconds, Enabled bool +} + +type Definition struct { + Name string + Migrations []migration.Step + Surface Surface + TimedTasks []TimedTask + Tasks []task.Method +} + +type Catalog struct { + Definitions []Definition +} + +func (c Catalog) MigrationSteps() []migration.Step { + var steps []migration.Step + for _, item := range c.Definitions { + steps = append(steps, item.Migrations...) + } + return steps +} + +func (c Catalog) Surface() Surface { + var surface Surface + for _, item := range c.Definitions { + surface.Menus = append(surface.Menus, item.Surface.Menus...) + surface.APIs = append(surface.APIs, item.Surface.APIs...) + } + return surface +} + +func (c Catalog) DefaultTimedTasks() []TimedTask { + var tasks []TimedTask + for _, item := range c.Definitions { + tasks = append(tasks, item.TimedTasks...) + } + return tasks +} + +func (c Catalog) TaskMethods() []task.Method { + var methods []task.Method + for _, item := range c.Definitions { + methods = append(methods, item.Tasks...) + } + return methods +} + +type RouteRegistrar interface { + RegisterRoutes(public, private *gin.RouterGroup, engine *gin.Engine) +} + +type Runtime struct { + routes []RouteRegistrar +} + +func NewRuntime(routes ...RouteRegistrar) *Runtime { + return &Runtime{routes: append([]RouteRegistrar(nil), routes...)} +} + +func (r *Runtime) Add(routes ...RouteRegistrar) { + if r == nil { + return + } + r.routes = append(r.routes, routes...) +} + +func (r *Runtime) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.Engine) { + if r == nil { + return + } + for _, registrar := range r.routes { + registrar.RegisterRoutes(public, private, engine) + } +} diff --git a/pkg/module/module_test.go b/pkg/module/module_test.go new file mode 100644 index 0000000..b0f98c0 --- /dev/null +++ b/pkg/module/module_test.go @@ -0,0 +1,43 @@ +package module + +import ( + "context" + "encoding/json" + "testing" + + "kra/pkg/database/migration" + "kra/pkg/task" +) + +func TestCatalogCollectsContributions(t *testing.T) { + run := func(context.Context, json.RawMessage) error { return nil } + catalog := Catalog{Definitions: []Definition{ + { + Name: "system", + Migrations: []migration.Step{{ID: "system_schema"}}, + Surface: Surface{Menus: []Menu{{Name: "users"}}, APIs: []API{{Path: "/users"}}}, + TimedTasks: []TimedTask{{Name: "system.cleanup"}}, + Tasks: []task.Method{{Name: "system.cleanup", Run: run}}, + }, + { + Name: "orders", + Migrations: []migration.Step{{ID: "orders_schema"}}, + Surface: Surface{Menus: []Menu{{Name: "orders"}}, APIs: []API{{Path: "/orders"}}}, + TimedTasks: []TimedTask{{Name: "orders.expire"}}, + Tasks: []task.Method{{Name: "orders.expire", Run: run}}, + }, + }} + + if got := catalog.MigrationSteps(); len(got) != 2 || got[0].ID != "system_schema" || got[1].ID != "orders_schema" { + t.Fatalf("unexpected migrations: %#v", got) + } + if got := catalog.Surface(); len(got.Menus) != 2 || len(got.APIs) != 2 || got.Menus[1].Name != "orders" { + t.Fatalf("unexpected surface: %#v", got) + } + if got := catalog.DefaultTimedTasks(); len(got) != 2 || got[1].Name != "orders.expire" { + t.Fatalf("unexpected default tasks: %#v", got) + } + if got := catalog.TaskMethods(); len(got) != 2 || got[1].Name != "orders.expire" { + t.Fatalf("unexpected task methods: %#v", got) + } +} diff --git a/pkg/task/provider.go b/pkg/task/provider.go new file mode 100644 index 0000000..5f0e549 --- /dev/null +++ b/pkg/task/provider.go @@ -0,0 +1,5 @@ +package task + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewRegistry) diff --git a/pkg/task/registry.go b/pkg/task/registry.go new file mode 100644 index 0000000..cfafad2 --- /dev/null +++ b/pkg/task/registry.go @@ -0,0 +1,88 @@ +// Package task contains the process-wide task method contract. It is an +// infrastructure registry, not a system business package, so any module can +// contribute an in-process scheduled task. +package task + +import ( + "context" + "encoding/json" + "sort" + "sync" +) + +type MethodFunc func(context.Context, json.RawMessage) error + +type Method struct { + Name, Description string + Run MethodFunc +} + +// Contributor registers task methods whose handlers need constructed runtime +// dependencies. Modules expose a contributor and the application composition +// root activates it; the task runtime never imports business modules. +type Contributor interface { + RegisterTasks(*Registry) +} + +type Registry struct { + mu sync.RWMutex + methods map[string]Method +} + +func NewRegistry() *Registry { return &Registry{methods: make(map[string]Method)} } + +func Apply(registry *Registry, contributors ...Contributor) { + if registry == nil { + return + } + for _, contributor := range contributors { + if contributor != nil { + contributor.RegisterTasks(registry) + } + } +} + +func (r *Registry) Register(method Method) { + if r == nil || method.Name == "" || method.Run == nil { + return + } + r.mu.Lock() + defer r.mu.Unlock() + if r.methods == nil { + r.methods = make(map[string]Method) + } + r.methods[method.Name] = method +} + +func (r *Registry) RegisterAll(methods []Method) { + for _, method := range methods { + r.Register(method) + } +} + +func (r *Registry) Lookup(name string) (MethodFunc, bool) { + if r == nil { + return nil, false + } + r.mu.RLock() + defer r.mu.RUnlock() + method, ok := r.methods[name] + if !ok { + return nil, false + } + return method.Run, true +} + +func (r *Registry) List() []Method { + if r == nil { + return nil + } + r.mu.RLock() + defer r.mu.RUnlock() + methods := make([]Method, 0, len(r.methods)) + for _, method := range r.methods { + methods = append(methods, method) + } + sort.Slice(methods, func(i, j int) bool { return methods[i].Name < methods[j].Name }) + return methods +} diff --git a/pkg/task/registry_test.go b/pkg/task/registry_test.go new file mode 100644 index 0000000..b5bdb6c --- /dev/null +++ b/pkg/task/registry_test.go @@ -0,0 +1,32 @@ +package task + +import ( + "context" + "encoding/json" + "testing" +) + +func TestRegistryIsComposableAndIdempotent(t *testing.T) { + registry := NewRegistry() + registry.RegisterAll([]Method{{Name: "orders.sync", Run: func(context.Context, json.RawMessage) error { return nil }}, {Name: "system.cleanup", Run: func(context.Context, json.RawMessage) error { return nil }}}) + registry.Register(Method{Name: "orders.sync", Description: "updated", Run: func(context.Context, json.RawMessage) error { return nil }}) + methods := registry.List() + if len(methods) != 2 || methods[0].Name != "orders.sync" || methods[0].Description != "updated" { + t.Fatalf("unexpected methods: %#v", methods) + } +} + +type testContributor struct{ name string } + +func (contributor testContributor) RegisterTasks(registry *Registry) { + registry.Register(Method{Name: contributor.name, Run: func(context.Context, json.RawMessage) error { return nil }}) +} + +func TestApplyCollectsModuleContributors(t *testing.T) { + registry := NewRegistry() + Apply(registry, testContributor{name: "system.cleanup"}, testContributor{name: "orders.expire"}) + methods := registry.List() + if len(methods) != 2 || methods[0].Name != "orders.expire" || methods[1].Name != "system.cleanup" { + t.Fatalf("unexpected contributed methods: %#v", methods) + } +}