feat: add gormv2 and support sqlite
This commit is contained in:
+2
-1
@@ -50,7 +50,8 @@ func loadConfigFromEnv() {
|
||||
ServerSetting.ReadTimeout = 60
|
||||
ServerSetting.WriteTimeout = 60
|
||||
|
||||
DatabaseSetting.Type = "mysql"
|
||||
DatabaseSetting.Type = getOptionEnvValue("DB_TYPE", "sqlite")
|
||||
|
||||
DatabaseSetting.Host = getMustEnvValue("MYSQL_HOST")
|
||||
DatabaseSetting.Port = com.StrTo(getMustEnvValue("MYSQL_PORT")).MustInt()
|
||||
DatabaseSetting.User = getMustEnvValue("MYSQL_USER")
|
||||
|
||||
@@ -72,6 +72,8 @@ func Setup() {
|
||||
ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second
|
||||
ServerSetting.WriteTimeout = ServerSetting.WriteTimeout * time.Second
|
||||
|
||||
log.Printf("[message-nest] DB type: %s", DatabaseSetting.Type)
|
||||
|
||||
}
|
||||
|
||||
// mapTo map section
|
||||
|
||||
+8
-2
@@ -56,8 +56,14 @@ func (t *Time) Scan(v interface{}) error {
|
||||
|
||||
// GetNowTimeStr 获取当前的时间字符串
|
||||
func GetNowTimeStr() string {
|
||||
currentTimeUTC := time.Now().UTC()
|
||||
chinaTime := currentTimeUTC.Add(8 * time.Hour)
|
||||
chinaTime := GetNowTime()
|
||||
formattedTime := chinaTime.Format("2006-01-02 15:04:05")
|
||||
return formattedTime
|
||||
}
|
||||
|
||||
// GetNowTimeStr 获取当前的时间字符串
|
||||
func GetNowTime() time.Time {
|
||||
currentTimeUTC := time.Now().UTC()
|
||||
chinaTime := currentTimeUTC.Add(8 * time.Hour)
|
||||
return chinaTime
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user