-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
钟永标
committed
Apr 7, 2024
1 parent
c218cd6
commit 48d9e34
Showing
11 changed files
with
106 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package consts | ||
|
||
const ( | ||
DevMode = "development" | ||
GrayMode = "gray" | ||
ProMode = "production" | ||
DevMode = "development" // 开发环境 | ||
TestMode = "test" // 测试环境 | ||
GrayMode = "gray" // 预发布环境 | ||
ProMode = "production" // 生产环境 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package consts | ||
|
||
const ( | ||
NormalFormat = "2006-01-02 15:04:05" | ||
LogTimeFormat = "2006/01/02 15:04:05.000" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,68 @@ | ||
module github.com/ZYallers/zgin | ||
|
||
go 1.15 | ||
go 1.17 | ||
|
||
require ( | ||
github.com/ZYallers/golib v1.3.30 | ||
github.com/ZYallers/golib v1.3.40 | ||
github.com/arl/statsviz v0.2.2 | ||
github.com/gin-gonic/gin v1.5.0 | ||
github.com/go-redis/redis v6.15.9+incompatible | ||
github.com/prometheus/client_golang v1.8.0 | ||
github.com/spf13/viper v1.7.1 | ||
github.com/syyongx/php2go v0.9.7 | ||
go.uber.org/zap v1.21.0 | ||
gorm.io/gorm v1.20.8 | ||
) | ||
|
||
require ( | ||
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect | ||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||
github.com/coocood/freecache v1.2.4 // indirect | ||
github.com/fsnotify/fsnotify v1.4.9 // indirect | ||
github.com/gin-contrib/sse v0.1.0 // indirect | ||
github.com/go-playground/locales v0.12.1 // indirect | ||
github.com/go-playground/universal-translator v0.16.0 // indirect | ||
github.com/go-sql-driver/mysql v1.5.0 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/uuid v1.5.0 // indirect | ||
github.com/gorilla/websocket v1.4.2 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/jinzhu/inflection v1.0.0 // indirect | ||
github.com/jinzhu/now v1.1.1 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/leodido/go-urn v1.1.0 // indirect | ||
github.com/magiconair/properties v1.8.1 // indirect | ||
github.com/mattn/go-isatty v0.0.9 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect | ||
github.com/mitchellh/mapstructure v1.1.2 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect | ||
github.com/pelletier/go-toml v1.2.0 // indirect | ||
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.14.0 // indirect | ||
github.com/prometheus/procfs v0.2.0 // indirect | ||
github.com/spf13/afero v1.1.2 // indirect | ||
github.com/spf13/cast v1.3.0 // indirect | ||
github.com/spf13/jwalterweatherman v1.0.0 // indirect | ||
github.com/spf13/pflag v1.0.3 // indirect | ||
github.com/subosito/gotenv v1.2.0 // indirect | ||
github.com/techoner/gophp v0.2.0 // indirect | ||
github.com/tidwall/gjson v1.6.1 // indirect | ||
github.com/tidwall/match v1.0.1 // indirect | ||
github.com/tidwall/pretty v1.0.2 // indirect | ||
github.com/ugorji/go/codec v1.1.7 // indirect | ||
go.uber.org/atomic v1.7.0 // indirect | ||
go.uber.org/multierr v1.6.0 // indirect | ||
golang.org/x/sys v0.14.0 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/go-playground/validator.v9 v9.29.1 // indirect | ||
gopkg.in/ini.v1 v1.51.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gorm.io/driver/mysql v1.0.3 // indirect | ||
gorm.io/gorm v1.20.8 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,9 @@ | ||
package types | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ZYallers/golib/utils/logger" | ||
"github.com/ZYallers/golib/utils/mysql" | ||
"github.com/gin-gonic/gin" | ||
"gorm.io/gorm" | ||
gormLogger "gorm.io/gorm/logger" | ||
) | ||
|
||
type Model struct { | ||
mysql.Model | ||
} | ||
|
||
func (m *Model) Config(db string, options ...interface{}) func() *gorm.Config { | ||
logLevel := gormLogger.Warn | ||
slowThreshold := 500 * time.Millisecond | ||
ol := len(options) | ||
if ol == 0 && gin.IsDebugging() { | ||
logLevel = gormLogger.Info | ||
} | ||
if ol > 0 { | ||
logLevel = options[0].(gormLogger.LogLevel) | ||
} | ||
if ol > 1 { | ||
slowThreshold = options[1].(time.Duration) | ||
} | ||
return func() *gorm.Config { | ||
return &gorm.Config{Logger: logger.NewGormLogger(db, slowThreshold, logLevel, &Sender{})} | ||
} | ||
} |