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"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
"gorm.io/gorm"
|
||||
|
@ -267,11 +268,17 @@ func (u *userToRole) fillFieldMap() {
|
|||
|
||||
func (u userToRole) clone(db *gorm.DB) userToRole {
|
||||
u.userToRoleDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
u.User.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.User.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
u.Role.db = db.Session(&gorm.Session{Initialized: true})
|
||||
u.Role.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userToRole) replaceDB(db *gorm.DB) userToRole {
|
||||
u.userToRoleDo.ReplaceDB(db)
|
||||
u.User.db = db.Session(&gorm.Session{})
|
||||
u.Role.db = db.Session(&gorm.Session{})
|
||||
return u
|
||||
}
|
||||
|
||||
|
@ -384,6 +391,11 @@ func (a userToRoleBelongsToUser) Model(m *models.UserToRole) *userToRoleBelongsT
|
|||
return &userToRoleBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUser) Unscoped() *userToRoleBelongsToUser {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userToRoleBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToRoleBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
|
@ -422,6 +434,11 @@ func (a userToRoleBelongsToUserTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUserTx) Unscoped() *userToRoleBelongsToUserTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userToRoleBelongsToRole struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -455,6 +472,11 @@ func (a userToRoleBelongsToRole) Model(m *models.UserToRole) *userToRoleBelongsT
|
|||
return &userToRoleBelongsToRoleTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRole) Unscoped() *userToRoleBelongsToRole {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userToRoleBelongsToRoleTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Find() (result *models.Role, err error) {
|
||||
|
@ -493,6 +515,11 @@ func (a userToRoleBelongsToRoleTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Unscoped() *userToRoleBelongsToRoleTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type userToRoleDo struct{ gen.DO }
|
||||
|
||||
type IUserToRoleDo interface {
|
||||
|
@ -550,6 +577,8 @@ type IUserToRoleDo interface {
|
|||
FirstOrCreate() (*models.UserToRole, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserToRole, 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) IUserToRoleDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue