Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2309da7b0 | |||
|
|
46229c5edf | ||
|
|
c2202be655 | ||
|
|
ebb768db26 | ||
|
|
5fce3a13f3 |
17
error.go
Normal file
17
error.go
Normal file
@ -0,0 +1,17 @@
|
||||
package model
|
||||
|
||||
import "strings"
|
||||
|
||||
func IsDuplicateError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
var errstr = strings.ToLower(err.Error())
|
||||
if strings.HasPrefix(errstr, "error 1062 (23000): duplicate entry") {
|
||||
return true
|
||||
} else if strings.Contains(errstr, "error") && strings.Contains(errstr, "duplicate entry") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
1
example/model/dao/dao.go
Normal file
1
example/model/dao/dao.go
Normal file
@ -0,0 +1 @@
|
||||
package dao
|
||||
22
example/model/model.go
Normal file
22
example/model/model.go
Normal file
@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"qoobing.ai/payserver/config"
|
||||
"qoobing.com/gomod/log"
|
||||
"qoobing.com/gomod/model"
|
||||
)
|
||||
|
||||
var (
|
||||
Db = model.Db
|
||||
DbOf = model.DbOf
|
||||
Redis = model.Redis
|
||||
RedisPool = model.RedisPool
|
||||
RedisPoolOf = model.RedisPoolOf
|
||||
)
|
||||
|
||||
func init() {
|
||||
cfg := config.Instance()
|
||||
model.Init("pay", &cfg.PayDb)
|
||||
model.Init("pay", &cfg.PayRedis)
|
||||
log.Infof("model initlized")
|
||||
}
|
||||
0
example/model/tables/t_user/t_user.go
Normal file
0
example/model/tables/t_user/t_user.go
Normal file
6
go.mod
6
go.mod
@ -3,15 +3,15 @@ module qoobing.com/gomod/model
|
||||
go 1.19.2
|
||||
|
||||
require (
|
||||
qoobing.com/gomod/gorm v0.0.2
|
||||
qoobing.com/gomod/log v1.4.0
|
||||
qoobing.com/gomod/gorm v0.0.4
|
||||
qoobing.com/gomod/log v1.4.2
|
||||
qoobing.com/gomod/redis v1.3.9
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/driver/postgres v1.5.9 // indirect
|
||||
gorm.io/driver/postgres v1.5.11 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
||||
|
||||
|
||||
14
go.sum
14
go.sum
@ -37,17 +37,15 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||
gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8=
|
||||
gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
|
||||
gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314=
|
||||
gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
qoobing.com/gomod/gorm v0.0.2 h1:bFf2YNZaqk67Yt1eqUq7n00iPhIh5BGxz1yMlm9lwBQ=
|
||||
qoobing.com/gomod/gorm v0.0.2/go.mod h1:Z9XzL+UnobxmXcVarjTUVurM1SI6Mep4Wq5Qrj1HTBU=
|
||||
qoobing.com/gomod/log v1.4.0 h1:VSdV8Fm2roCkSwOTunmNrH2kl14KOCYavsh4tJ/SGj0=
|
||||
qoobing.com/gomod/log v1.4.0/go.mod h1:rNXuq0d/EWog4+8hIEVGvkusLD/pzafYBQo6w+Evv6A=
|
||||
qoobing.com/gomod/redis v1.3.8 h1:9REpvyKXsOWBl3KG1oCGpJcITf7Mz1SjqCeIM65k9cQ=
|
||||
qoobing.com/gomod/redis v1.3.8/go.mod h1:5j9kopj3CY1qf70OQ8IHQjDKHUl72rj0LhQgTBpl2BU=
|
||||
qoobing.com/gomod/gorm v0.0.4 h1:tKBkL2AtMiB9txb3XsLll5+1NK5oIyJIuBGgm4N6OAQ=
|
||||
qoobing.com/gomod/gorm v0.0.4/go.mod h1:dGaviTlwtQl1amgr+DUmovoxk779WLL4+js7f2hvSwA=
|
||||
qoobing.com/gomod/log v1.4.2 h1:BR6WA79nUfvYhHww/Nbzu/iM9RdCfx3G3hg1XusjIIM=
|
||||
qoobing.com/gomod/log v1.4.2/go.mod h1:rNXuq0d/EWog4+8hIEVGvkusLD/pzafYBQo6w+Evv6A=
|
||||
qoobing.com/gomod/redis v1.3.9 h1:wtojzRP7T+p+MAzkAUrU8GLNDUMU84ZJ3U/cWPrDby8=
|
||||
qoobing.com/gomod/redis v1.3.9/go.mod h1:5j9kopj3CY1qf70OQ8IHQjDKHUl72rj0LhQgTBpl2BU=
|
||||
qoobing.com/gomod/str v1.0.1/go.mod h1:gbhN2dba/P5gFRGVJvEI57KEJLlMHHAd6Kuuxn4GlMY=
|
||||
|
||||
1
model_test.go
Normal file
1
model_test.go
Normal file
@ -0,0 +1 @@
|
||||
package model
|
||||
Loading…
Reference in New Issue
Block a user