迁移配置文件, 实现从json文件中读取原材料营养预设值, 并自动写入数据库
This commit is contained in:
@@ -14,9 +14,10 @@ import (
|
||||
|
||||
// Application 是整个应用的核心,封装了所有组件和生命周期。
|
||||
type Application struct {
|
||||
Config *config.Config
|
||||
Ctx context.Context
|
||||
API *api.API
|
||||
cfgPath string
|
||||
Config *config.Config
|
||||
Ctx context.Context
|
||||
API *api.API
|
||||
|
||||
Infra *Infrastructure
|
||||
Domain *DomainServices
|
||||
@@ -68,12 +69,13 @@ func NewApplication(configPath string) (*Application, error) {
|
||||
|
||||
// 4. 组装 Application 对象
|
||||
app := &Application{
|
||||
Config: cfg,
|
||||
Ctx: selfCtx,
|
||||
API: apiServer,
|
||||
Infra: infra,
|
||||
Domain: domain,
|
||||
App: appServices,
|
||||
cfgPath: configPath,
|
||||
Config: cfg,
|
||||
Ctx: selfCtx,
|
||||
API: apiServer,
|
||||
Infra: infra,
|
||||
Domain: domain,
|
||||
App: appServices,
|
||||
}
|
||||
|
||||
return app, nil
|
||||
@@ -90,7 +92,7 @@ func (app *Application) Start() error {
|
||||
}
|
||||
|
||||
// 2. 初始化应用状态 (清理、刷新任务等)
|
||||
if err := app.initializeState(startCtx); err != nil {
|
||||
if err := app.initializeState(startCtx, app.cfgPath); err != nil {
|
||||
return fmt.Errorf("初始化应用状态失败: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user