feat: 新增财务应用的核心数据模型定义,包含账户、交易类型、货币等枚举。
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"accounting-app/internal/config"
|
"accounting-app/internal/config"
|
||||||
@@ -14,19 +15,36 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
// Load .env file from project root (try multiple locations)
|
// Load .env file from project root (try multiple locations)
|
||||||
envPaths := []string{
|
envPaths := []string{
|
||||||
".env", // Current directory
|
".env", // Current directory
|
||||||
"../.env", // Parent directory (when running from backend/)
|
"../.env", // Parent directory (when running from backend/)
|
||||||
"../../.env", // Two levels up (when running from backend/cmd/migrate/)
|
"../../.env", // Two levels up (when running from backend/cmd/migrate/)
|
||||||
filepath.Join("..", "..", ".env"), // Explicit path
|
filepath.Join("..", "..", ".env"), // Explicit path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var envDir string
|
||||||
for _, envPath := range envPaths {
|
for _, envPath := range envPaths {
|
||||||
if err := godotenv.Load(envPath); err == nil {
|
if err := godotenv.Load(envPath); err == nil {
|
||||||
log.Printf("Loaded environment from: %s", envPath)
|
log.Printf("Loaded base environment from: %s", envPath)
|
||||||
|
envDir = filepath.Dir(envPath)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load specific environment file if APP_ENV is set (e.g. .env.dev, .env.prod)
|
||||||
|
if appEnv := os.Getenv("APP_ENV"); appEnv != "" {
|
||||||
|
targetEnvFile := ".env." + appEnv
|
||||||
|
targetEnvPath := targetEnvFile
|
||||||
|
if envDir != "" && envDir != "." {
|
||||||
|
targetEnvPath = filepath.Join(envDir, targetEnvFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := godotenv.Overload(targetEnvPath); err == nil {
|
||||||
|
log.Printf("Loaded specific environment config from: %s", targetEnvPath)
|
||||||
|
} else {
|
||||||
|
log.Printf("Note: Specific environment file %s not found or could not be loaded", targetEnvPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load configuration
|
// Load configuration
|
||||||
cfg := config.Load()
|
cfg := config.Load()
|
||||||
|
|
||||||
|
|||||||
@@ -861,11 +861,12 @@ func AllModels() []interface{} {
|
|||||||
&OAuthAccount{},
|
&OAuthAccount{},
|
||||||
&TransactionTemplate{},
|
&TransactionTemplate{},
|
||||||
&UserPreference{},
|
&UserPreference{},
|
||||||
&Ledger{}, // Feature: accounting-feature-upgrade
|
&Ledger{}, // Feature: accounting-feature-upgrade
|
||||||
&SystemCategory{}, // Feature: accounting-feature-upgrade
|
&SystemCategory{}, // Feature: accounting-feature-upgrade
|
||||||
&TransactionImage{}, // Feature: accounting-feature-upgrade
|
&TransactionImage{}, // Feature: accounting-feature-upgrade
|
||||||
&UserSettings{}, // Feature: accounting-feature-upgrade
|
&UserSettings{}, // Feature: accounting-feature-upgrade
|
||||||
&Notification{}, // Feature: notification-center
|
&Notification{}, // Feature: notification-center
|
||||||
|
&SystemAnnouncement{}, // Feature: system-announcement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user