This commit is contained in:
2025-07-11 21:05:58 +08:00
parent 5b4392894f
commit e3d64e7485
74 changed files with 14379 additions and 697 deletions

View File

@@ -43,6 +43,9 @@ func NewConnection(config Config) (*DB, error) {
SingularTable: true, // 使用单数表名
},
DisableForeignKeyConstraintWhenMigrating: true,
NowFunc: func() time.Time {
return time.Now().In(time.FixedZone("CST", 8*3600)) // 强制使用北京时间
},
}
// 连接数据库
@@ -76,7 +79,7 @@ func NewConnection(config Config) (*DB, error) {
// buildDSN 构建数据库连接字符串
func buildDSN(config Config) string {
return fmt.Sprintf(
"host=%s user=%s password=%s dbname=%s port=%s sslmode=%s TimeZone=%s",
"host=%s user=%s password=%s dbname=%s port=%s sslmode=%s TimeZone=%s options='-c timezone=%s'",
config.Host,
config.User,
config.Password,
@@ -84,6 +87,7 @@ func buildDSN(config Config) string {
config.Port,
config.SSLMode,
config.Timezone,
config.Timezone,
)
}