This commit is contained in:
parent
d32818af09
commit
cfa0566c6d
39 changed files with 2276 additions and 183 deletions
|
@ -6,6 +6,7 @@ package dbgen
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
|
@ -501,11 +502,47 @@ func (u *user) fillFieldMap() {
|
|||
|
||||
func (u user) clone(db *gorm.DB) user {
|
||||
u.userDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
u.RemoteInfo.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.RemoteInfo.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.InfoFields.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.InfoFields.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.BeingTypes.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.BeingTypes.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Tags.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Tags.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Relations.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Relations.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Pronouns.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Pronouns.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Roles.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Roles.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.AuthMethods.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.AuthMethods.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Server.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Server.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Icon.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Icon.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Background.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Background.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Banner.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Banner.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return u
|
||||
}
|
||||
|
||||
func (u user) replaceDB(db *gorm.DB) user {
|
||||
u.userDo.ReplaceDB(db)
|
||||
u.RemoteInfo.db = db.Session(&gorm.Session{})
|
||||
u.InfoFields.db = db.Session(&gorm.Session{})
|
||||
u.BeingTypes.db = db.Session(&gorm.Session{})
|
||||
u.Tags.db = db.Session(&gorm.Session{})
|
||||
u.Relations.db = db.Session(&gorm.Session{})
|
||||
u.Pronouns.db = db.Session(&gorm.Session{})
|
||||
u.Roles.db = db.Session(&gorm.Session{})
|
||||
u.AuthMethods.db = db.Session(&gorm.Session{})
|
||||
u.Server.db = db.Session(&gorm.Session{})
|
||||
u.Icon.db = db.Session(&gorm.Session{})
|
||||
u.Background.db = db.Session(&gorm.Session{})
|
||||
u.Banner.db = db.Session(&gorm.Session{})
|
||||
return u
|
||||
}
|
||||
|
||||
|
@ -618,6 +655,11 @@ func (a userHasOneRemoteInfo) Model(m *models.User) *userHasOneRemoteInfoTx {
|
|||
return &userHasOneRemoteInfoTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasOneRemoteInfo) Unscoped() *userHasOneRemoteInfo {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasOneRemoteInfoTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasOneRemoteInfoTx) Find() (result *models.UserRemoteLinks, err error) {
|
||||
|
@ -656,6 +698,11 @@ func (a userHasOneRemoteInfoTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasOneRemoteInfoTx) Unscoped() *userHasOneRemoteInfoTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyInfoFields struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -689,6 +736,11 @@ func (a userHasManyInfoFields) Model(m *models.User) *userHasManyInfoFieldsTx {
|
|||
return &userHasManyInfoFieldsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyInfoFields) Unscoped() *userHasManyInfoFields {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyInfoFieldsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyInfoFieldsTx) Find() (result []*models.UserInfoField, err error) {
|
||||
|
@ -727,6 +779,11 @@ func (a userHasManyInfoFieldsTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyInfoFieldsTx) Unscoped() *userHasManyInfoFieldsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyBeingTypes struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -760,6 +817,11 @@ func (a userHasManyBeingTypes) Model(m *models.User) *userHasManyBeingTypesTx {
|
|||
return &userHasManyBeingTypesTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyBeingTypes) Unscoped() *userHasManyBeingTypes {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyBeingTypesTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyBeingTypesTx) Find() (result []*models.UserToBeing, err error) {
|
||||
|
@ -798,6 +860,11 @@ func (a userHasManyBeingTypesTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyBeingTypesTx) Unscoped() *userHasManyBeingTypesTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyTags struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -831,6 +898,11 @@ func (a userHasManyTags) Model(m *models.User) *userHasManyTagsTx {
|
|||
return &userHasManyTagsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyTags) Unscoped() *userHasManyTags {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyTagsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyTagsTx) Find() (result []*models.UserToTag, err error) {
|
||||
|
@ -869,6 +941,11 @@ func (a userHasManyTagsTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyTagsTx) Unscoped() *userHasManyTagsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyRelations struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -902,6 +979,11 @@ func (a userHasManyRelations) Model(m *models.User) *userHasManyRelationsTx {
|
|||
return &userHasManyRelationsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyRelations) Unscoped() *userHasManyRelations {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyRelationsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyRelationsTx) Find() (result []*models.UserToUserRelation, err error) {
|
||||
|
@ -940,6 +1022,11 @@ func (a userHasManyRelationsTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyRelationsTx) Unscoped() *userHasManyRelationsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyPronouns struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -973,6 +1060,11 @@ func (a userHasManyPronouns) Model(m *models.User) *userHasManyPronounsTx {
|
|||
return &userHasManyPronounsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyPronouns) Unscoped() *userHasManyPronouns {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyPronounsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyPronounsTx) Find() (result []*models.UserToPronoun, err error) {
|
||||
|
@ -1011,6 +1103,11 @@ func (a userHasManyPronounsTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyPronounsTx) Unscoped() *userHasManyPronounsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyRoles struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -1044,6 +1141,11 @@ func (a userHasManyRoles) Model(m *models.User) *userHasManyRolesTx {
|
|||
return &userHasManyRolesTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyRoles) Unscoped() *userHasManyRoles {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyRolesTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyRolesTx) Find() (result []*models.UserToRole, err error) {
|
||||
|
@ -1082,6 +1184,11 @@ func (a userHasManyRolesTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyRolesTx) Unscoped() *userHasManyRolesTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyAuthMethods struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -1115,6 +1222,11 @@ func (a userHasManyAuthMethods) Model(m *models.User) *userHasManyAuthMethodsTx
|
|||
return &userHasManyAuthMethodsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userHasManyAuthMethods) Unscoped() *userHasManyAuthMethods {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userHasManyAuthMethodsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userHasManyAuthMethodsTx) Find() (result []*models.UserAuthMethod, err error) {
|
||||
|
@ -1153,6 +1265,11 @@ func (a userHasManyAuthMethodsTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userHasManyAuthMethodsTx) Unscoped() *userHasManyAuthMethodsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToServer struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -1186,6 +1303,11 @@ func (a userBelongsToServer) Model(m *models.User) *userBelongsToServerTx {
|
|||
return &userBelongsToServerTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userBelongsToServer) Unscoped() *userBelongsToServer {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToServerTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userBelongsToServerTx) Find() (result *models.RemoteServer, err error) {
|
||||
|
@ -1224,6 +1346,11 @@ func (a userBelongsToServerTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userBelongsToServerTx) Unscoped() *userBelongsToServerTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToIcon struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -1257,6 +1384,11 @@ func (a userBelongsToIcon) Model(m *models.User) *userBelongsToIconTx {
|
|||
return &userBelongsToIconTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userBelongsToIcon) Unscoped() *userBelongsToIcon {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToIconTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userBelongsToIconTx) Find() (result *models.MediaMetadata, err error) {
|
||||
|
@ -1295,6 +1427,11 @@ func (a userBelongsToIconTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userBelongsToIconTx) Unscoped() *userBelongsToIconTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToBackground struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -1328,6 +1465,11 @@ func (a userBelongsToBackground) Model(m *models.User) *userBelongsToBackgroundT
|
|||
return &userBelongsToBackgroundTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userBelongsToBackground) Unscoped() *userBelongsToBackground {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToBackgroundTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userBelongsToBackgroundTx) Find() (result *models.MediaMetadata, err error) {
|
||||
|
@ -1366,6 +1508,11 @@ func (a userBelongsToBackgroundTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userBelongsToBackgroundTx) Unscoped() *userBelongsToBackgroundTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToBanner struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -1399,6 +1546,11 @@ func (a userBelongsToBanner) Model(m *models.User) *userBelongsToBannerTx {
|
|||
return &userBelongsToBannerTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userBelongsToBanner) Unscoped() *userBelongsToBanner {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userBelongsToBannerTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userBelongsToBannerTx) Find() (result *models.MediaMetadata, err error) {
|
||||
|
@ -1437,6 +1589,11 @@ func (a userBelongsToBannerTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userBelongsToBannerTx) Unscoped() *userBelongsToBannerTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userDo struct{ gen.DO }
|
||||
|
||||
type IUserDo interface {
|
||||
|
@ -1494,6 +1651,8 @@ type IUserDo interface {
|
|||
FirstOrCreate() (*models.User, error)
|
||||
FindByPage(offset int, limit int) (result []*models.User, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IUserDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue