Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2309da7b0 | |||
|
|
46229c5edf | ||
|
|
c2202be655 |
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
4
go.mod
4
go.mod
@ -3,8 +3,8 @@ module qoobing.com/gomod/model
|
||||
go 1.19.2
|
||||
|
||||
require (
|
||||
qoobing.com/gomod/gorm v0.0.3
|
||||
qoobing.com/gomod/log v1.4.1
|
||||
qoobing.com/gomod/gorm v0.0.4
|
||||
qoobing.com/gomod/log v1.4.2
|
||||
qoobing.com/gomod/redis v1.3.9
|
||||
)
|
||||
|
||||
|
||||
8
go.sum
8
go.sum
@ -42,10 +42,10 @@ gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSk
|
||||
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.3 h1:rQa+QhsrwTNANd5FnGvHRREi/oS7bfaLwZwDGp8qP68=
|
||||
qoobing.com/gomod/gorm v0.0.3/go.mod h1:grapOzvbrAB6giqyDvq3DRTn5jW8OAL7nbO8H3YH370=
|
||||
qoobing.com/gomod/log v1.4.1 h1:JAjnwlJuEy32t/mJNYJaXLGmuRrlfpczgfaLDiHniUk=
|
||||
qoobing.com/gomod/log v1.4.1/go.mod h1:rNXuq0d/EWog4+8hIEVGvkusLD/pzafYBQo6w+Evv6A=
|
||||
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