850 lines
22 KiB
Go
850 lines
22 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package queries
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"platform/web/models"
|
|
)
|
|
|
|
func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
|
|
_channel := channel{}
|
|
|
|
_channel.channelDo.UseDB(db, opts...)
|
|
_channel.channelDo.UseModel(&models.Channel{})
|
|
|
|
tableName := _channel.channelDo.TableName()
|
|
_channel.ALL = field.NewAsterisk(tableName)
|
|
_channel.ID = field.NewInt32(tableName, "id")
|
|
_channel.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_channel.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_channel.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
_channel.UserID = field.NewInt32(tableName, "user_id")
|
|
_channel.ResourceID = field.NewInt32(tableName, "resource_id")
|
|
_channel.BatchNo = field.NewString(tableName, "batch_no")
|
|
_channel.ProxyID = field.NewInt32(tableName, "proxy_id")
|
|
_channel.Host = field.NewString(tableName, "host")
|
|
_channel.Port = field.NewUint16(tableName, "port")
|
|
_channel.EdgeID = field.NewInt32(tableName, "edge_id")
|
|
_channel.EdgeRef = field.NewString(tableName, "edge_ref")
|
|
_channel.FilterISP = field.NewInt(tableName, "filter_isp")
|
|
_channel.FilterProv = field.NewString(tableName, "filter_prov")
|
|
_channel.FilterCity = field.NewString(tableName, "filter_city")
|
|
_channel.IP = field.NewField(tableName, "ip")
|
|
_channel.Whitelists = field.NewString(tableName, "whitelists")
|
|
_channel.Username = field.NewString(tableName, "username")
|
|
_channel.Password = field.NewString(tableName, "password")
|
|
_channel.ExpiredAt = field.NewTime(tableName, "expired_at")
|
|
_channel.User = channelBelongsToUser{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("User", "models.User"),
|
|
Admin: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("User.Admin", "models.Admin"),
|
|
},
|
|
}
|
|
|
|
_channel.Resource = channelBelongsToResource{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Resource", "models.Resource"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Resource.User", "models.User"),
|
|
},
|
|
Short: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Resource.Short", "models.ResourceShort"),
|
|
},
|
|
Long: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Resource.Long", "models.ResourceLong"),
|
|
},
|
|
}
|
|
|
|
_channel.Proxy = channelBelongsToProxy{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Proxy", "models.Proxy"),
|
|
Channels: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
Resource struct {
|
|
field.RelationField
|
|
}
|
|
Proxy struct {
|
|
field.RelationField
|
|
}
|
|
Edge struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Proxy.Channels", "models.Channel"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Proxy.Channels.User", "models.User"),
|
|
},
|
|
Resource: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Proxy.Channels.Resource", "models.Resource"),
|
|
},
|
|
Proxy: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Proxy.Channels.Proxy", "models.Proxy"),
|
|
},
|
|
Edge: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Proxy.Channels.Edge", "models.Edge"),
|
|
},
|
|
},
|
|
}
|
|
|
|
_channel.Edge = channelBelongsToEdge{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Edge", "models.Edge"),
|
|
}
|
|
|
|
_channel.fillFieldMap()
|
|
|
|
return _channel
|
|
}
|
|
|
|
type channel struct {
|
|
channelDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32
|
|
CreatedAt field.Time
|
|
UpdatedAt field.Time
|
|
DeletedAt field.Field
|
|
UserID field.Int32
|
|
ResourceID field.Int32
|
|
BatchNo field.String
|
|
ProxyID field.Int32
|
|
Host field.String
|
|
Port field.Uint16
|
|
EdgeID field.Int32
|
|
EdgeRef field.String
|
|
FilterISP field.Int
|
|
FilterProv field.String
|
|
FilterCity field.String
|
|
IP field.Field
|
|
Whitelists field.String
|
|
Username field.String
|
|
Password field.String
|
|
ExpiredAt field.Time
|
|
User channelBelongsToUser
|
|
|
|
Resource channelBelongsToResource
|
|
|
|
Proxy channelBelongsToProxy
|
|
|
|
Edge channelBelongsToEdge
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (c channel) Table(newTableName string) *channel {
|
|
c.channelDo.UseTable(newTableName)
|
|
return c.updateTableName(newTableName)
|
|
}
|
|
|
|
func (c channel) As(alias string) *channel {
|
|
c.channelDo.DO = *(c.channelDo.As(alias).(*gen.DO))
|
|
return c.updateTableName(alias)
|
|
}
|
|
|
|
func (c *channel) updateTableName(table string) *channel {
|
|
c.ALL = field.NewAsterisk(table)
|
|
c.ID = field.NewInt32(table, "id")
|
|
c.CreatedAt = field.NewTime(table, "created_at")
|
|
c.UpdatedAt = field.NewTime(table, "updated_at")
|
|
c.DeletedAt = field.NewField(table, "deleted_at")
|
|
c.UserID = field.NewInt32(table, "user_id")
|
|
c.ResourceID = field.NewInt32(table, "resource_id")
|
|
c.BatchNo = field.NewString(table, "batch_no")
|
|
c.ProxyID = field.NewInt32(table, "proxy_id")
|
|
c.Host = field.NewString(table, "host")
|
|
c.Port = field.NewUint16(table, "port")
|
|
c.EdgeID = field.NewInt32(table, "edge_id")
|
|
c.EdgeRef = field.NewString(table, "edge_ref")
|
|
c.FilterISP = field.NewInt(table, "filter_isp")
|
|
c.FilterProv = field.NewString(table, "filter_prov")
|
|
c.FilterCity = field.NewString(table, "filter_city")
|
|
c.IP = field.NewField(table, "ip")
|
|
c.Whitelists = field.NewString(table, "whitelists")
|
|
c.Username = field.NewString(table, "username")
|
|
c.Password = field.NewString(table, "password")
|
|
c.ExpiredAt = field.NewTime(table, "expired_at")
|
|
|
|
c.fillFieldMap()
|
|
|
|
return c
|
|
}
|
|
|
|
func (c *channel) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := c.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (c *channel) fillFieldMap() {
|
|
c.fieldMap = make(map[string]field.Expr, 24)
|
|
c.fieldMap["id"] = c.ID
|
|
c.fieldMap["created_at"] = c.CreatedAt
|
|
c.fieldMap["updated_at"] = c.UpdatedAt
|
|
c.fieldMap["deleted_at"] = c.DeletedAt
|
|
c.fieldMap["user_id"] = c.UserID
|
|
c.fieldMap["resource_id"] = c.ResourceID
|
|
c.fieldMap["batch_no"] = c.BatchNo
|
|
c.fieldMap["proxy_id"] = c.ProxyID
|
|
c.fieldMap["host"] = c.Host
|
|
c.fieldMap["port"] = c.Port
|
|
c.fieldMap["edge_id"] = c.EdgeID
|
|
c.fieldMap["edge_ref"] = c.EdgeRef
|
|
c.fieldMap["filter_isp"] = c.FilterISP
|
|
c.fieldMap["filter_prov"] = c.FilterProv
|
|
c.fieldMap["filter_city"] = c.FilterCity
|
|
c.fieldMap["ip"] = c.IP
|
|
c.fieldMap["whitelists"] = c.Whitelists
|
|
c.fieldMap["username"] = c.Username
|
|
c.fieldMap["password"] = c.Password
|
|
c.fieldMap["expired_at"] = c.ExpiredAt
|
|
|
|
}
|
|
|
|
func (c channel) clone(db *gorm.DB) channel {
|
|
c.channelDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
c.User.db = db.Session(&gorm.Session{Initialized: true})
|
|
c.User.db.Statement.ConnPool = db.Statement.ConnPool
|
|
c.Resource.db = db.Session(&gorm.Session{Initialized: true})
|
|
c.Resource.db.Statement.ConnPool = db.Statement.ConnPool
|
|
c.Proxy.db = db.Session(&gorm.Session{Initialized: true})
|
|
c.Proxy.db.Statement.ConnPool = db.Statement.ConnPool
|
|
c.Edge.db = db.Session(&gorm.Session{Initialized: true})
|
|
c.Edge.db.Statement.ConnPool = db.Statement.ConnPool
|
|
return c
|
|
}
|
|
|
|
func (c channel) replaceDB(db *gorm.DB) channel {
|
|
c.channelDo.ReplaceDB(db)
|
|
c.User.db = db.Session(&gorm.Session{})
|
|
c.Resource.db = db.Session(&gorm.Session{})
|
|
c.Proxy.db = db.Session(&gorm.Session{})
|
|
c.Edge.db = db.Session(&gorm.Session{})
|
|
return c
|
|
}
|
|
|
|
type channelBelongsToUser struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
|
|
Admin struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
|
|
func (a channelBelongsToUser) Where(conds ...field.Expr) *channelBelongsToUser {
|
|
if len(conds) == 0 {
|
|
return &a
|
|
}
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
for _, cond := range conds {
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
}
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToUser) WithContext(ctx context.Context) *channelBelongsToUser {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToUser) Session(session *gorm.Session) *channelBelongsToUser {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToUser) Model(m *models.Channel) *channelBelongsToUserTx {
|
|
return &channelBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
func (a channelBelongsToUser) Unscoped() *channelBelongsToUser {
|
|
a.db = a.db.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToUserTx struct{ tx *gorm.Association }
|
|
|
|
func (a channelBelongsToUserTx) Find() (result *models.User, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a channelBelongsToUserTx) Append(values ...*models.User) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToUserTx) Replace(values ...*models.User) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToUserTx) Delete(values ...*models.User) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToUserTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a channelBelongsToUserTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
func (a channelBelongsToUserTx) Unscoped() *channelBelongsToUserTx {
|
|
a.tx = a.tx.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToResource struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
Short struct {
|
|
field.RelationField
|
|
}
|
|
Long struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
|
|
func (a channelBelongsToResource) Where(conds ...field.Expr) *channelBelongsToResource {
|
|
if len(conds) == 0 {
|
|
return &a
|
|
}
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
for _, cond := range conds {
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
}
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToResource) WithContext(ctx context.Context) *channelBelongsToResource {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToResource) Session(session *gorm.Session) *channelBelongsToResource {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToResource) Model(m *models.Channel) *channelBelongsToResourceTx {
|
|
return &channelBelongsToResourceTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
func (a channelBelongsToResource) Unscoped() *channelBelongsToResource {
|
|
a.db = a.db.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToResourceTx struct{ tx *gorm.Association }
|
|
|
|
func (a channelBelongsToResourceTx) Find() (result *models.Resource, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a channelBelongsToResourceTx) Append(values ...*models.Resource) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToResourceTx) Replace(values ...*models.Resource) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToResourceTx) Delete(values ...*models.Resource) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToResourceTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a channelBelongsToResourceTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
func (a channelBelongsToResourceTx) Unscoped() *channelBelongsToResourceTx {
|
|
a.tx = a.tx.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToProxy struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
|
|
Channels struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
Resource struct {
|
|
field.RelationField
|
|
}
|
|
Proxy struct {
|
|
field.RelationField
|
|
}
|
|
Edge struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}
|
|
|
|
func (a channelBelongsToProxy) Where(conds ...field.Expr) *channelBelongsToProxy {
|
|
if len(conds) == 0 {
|
|
return &a
|
|
}
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
for _, cond := range conds {
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
}
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToProxy) WithContext(ctx context.Context) *channelBelongsToProxy {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToProxy) Session(session *gorm.Session) *channelBelongsToProxy {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToProxy) Model(m *models.Channel) *channelBelongsToProxyTx {
|
|
return &channelBelongsToProxyTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
func (a channelBelongsToProxy) Unscoped() *channelBelongsToProxy {
|
|
a.db = a.db.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToProxyTx struct{ tx *gorm.Association }
|
|
|
|
func (a channelBelongsToProxyTx) Find() (result *models.Proxy, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a channelBelongsToProxyTx) Append(values ...*models.Proxy) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToProxyTx) Replace(values ...*models.Proxy) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToProxyTx) Delete(values ...*models.Proxy) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToProxyTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a channelBelongsToProxyTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
func (a channelBelongsToProxyTx) Unscoped() *channelBelongsToProxyTx {
|
|
a.tx = a.tx.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToEdge struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a channelBelongsToEdge) Where(conds ...field.Expr) *channelBelongsToEdge {
|
|
if len(conds) == 0 {
|
|
return &a
|
|
}
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
for _, cond := range conds {
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
}
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToEdge) WithContext(ctx context.Context) *channelBelongsToEdge {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToEdge) Session(session *gorm.Session) *channelBelongsToEdge {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a channelBelongsToEdge) Model(m *models.Channel) *channelBelongsToEdgeTx {
|
|
return &channelBelongsToEdgeTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
func (a channelBelongsToEdge) Unscoped() *channelBelongsToEdge {
|
|
a.db = a.db.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelBelongsToEdgeTx struct{ tx *gorm.Association }
|
|
|
|
func (a channelBelongsToEdgeTx) Find() (result *models.Edge, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a channelBelongsToEdgeTx) Append(values ...*models.Edge) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToEdgeTx) Replace(values ...*models.Edge) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToEdgeTx) Delete(values ...*models.Edge) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a channelBelongsToEdgeTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a channelBelongsToEdgeTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
func (a channelBelongsToEdgeTx) Unscoped() *channelBelongsToEdgeTx {
|
|
a.tx = a.tx.Unscoped()
|
|
return &a
|
|
}
|
|
|
|
type channelDo struct{ gen.DO }
|
|
|
|
func (c channelDo) Debug() *channelDo {
|
|
return c.withDO(c.DO.Debug())
|
|
}
|
|
|
|
func (c channelDo) WithContext(ctx context.Context) *channelDo {
|
|
return c.withDO(c.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (c channelDo) ReadDB() *channelDo {
|
|
return c.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (c channelDo) WriteDB() *channelDo {
|
|
return c.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (c channelDo) Session(config *gorm.Session) *channelDo {
|
|
return c.withDO(c.DO.Session(config))
|
|
}
|
|
|
|
func (c channelDo) Clauses(conds ...clause.Expression) *channelDo {
|
|
return c.withDO(c.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (c channelDo) Returning(value interface{}, columns ...string) *channelDo {
|
|
return c.withDO(c.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (c channelDo) Not(conds ...gen.Condition) *channelDo {
|
|
return c.withDO(c.DO.Not(conds...))
|
|
}
|
|
|
|
func (c channelDo) Or(conds ...gen.Condition) *channelDo {
|
|
return c.withDO(c.DO.Or(conds...))
|
|
}
|
|
|
|
func (c channelDo) Select(conds ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.Select(conds...))
|
|
}
|
|
|
|
func (c channelDo) Where(conds ...gen.Condition) *channelDo {
|
|
return c.withDO(c.DO.Where(conds...))
|
|
}
|
|
|
|
func (c channelDo) Order(conds ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.Order(conds...))
|
|
}
|
|
|
|
func (c channelDo) Distinct(cols ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (c channelDo) Omit(cols ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.Omit(cols...))
|
|
}
|
|
|
|
func (c channelDo) Join(table schema.Tabler, on ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.Join(table, on...))
|
|
}
|
|
|
|
func (c channelDo) LeftJoin(table schema.Tabler, on ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (c channelDo) RightJoin(table schema.Tabler, on ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (c channelDo) Group(cols ...field.Expr) *channelDo {
|
|
return c.withDO(c.DO.Group(cols...))
|
|
}
|
|
|
|
func (c channelDo) Having(conds ...gen.Condition) *channelDo {
|
|
return c.withDO(c.DO.Having(conds...))
|
|
}
|
|
|
|
func (c channelDo) Limit(limit int) *channelDo {
|
|
return c.withDO(c.DO.Limit(limit))
|
|
}
|
|
|
|
func (c channelDo) Offset(offset int) *channelDo {
|
|
return c.withDO(c.DO.Offset(offset))
|
|
}
|
|
|
|
func (c channelDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *channelDo {
|
|
return c.withDO(c.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (c channelDo) Unscoped() *channelDo {
|
|
return c.withDO(c.DO.Unscoped())
|
|
}
|
|
|
|
func (c channelDo) Create(values ...*models.Channel) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return c.DO.Create(values)
|
|
}
|
|
|
|
func (c channelDo) CreateInBatches(values []*models.Channel, batchSize int) error {
|
|
return c.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (c channelDo) Save(values ...*models.Channel) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return c.DO.Save(values)
|
|
}
|
|
|
|
func (c channelDo) First() (*models.Channel, error) {
|
|
if result, err := c.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Channel), nil
|
|
}
|
|
}
|
|
|
|
func (c channelDo) Take() (*models.Channel, error) {
|
|
if result, err := c.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Channel), nil
|
|
}
|
|
}
|
|
|
|
func (c channelDo) Last() (*models.Channel, error) {
|
|
if result, err := c.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Channel), nil
|
|
}
|
|
}
|
|
|
|
func (c channelDo) Find() ([]*models.Channel, error) {
|
|
result, err := c.DO.Find()
|
|
return result.([]*models.Channel), err
|
|
}
|
|
|
|
func (c channelDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Channel, err error) {
|
|
buf := make([]*models.Channel, 0, batchSize)
|
|
err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (c channelDo) FindInBatches(result *[]*models.Channel, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return c.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (c channelDo) Attrs(attrs ...field.AssignExpr) *channelDo {
|
|
return c.withDO(c.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (c channelDo) Assign(attrs ...field.AssignExpr) *channelDo {
|
|
return c.withDO(c.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (c channelDo) Joins(fields ...field.RelationField) *channelDo {
|
|
for _, _f := range fields {
|
|
c = *c.withDO(c.DO.Joins(_f))
|
|
}
|
|
return &c
|
|
}
|
|
|
|
func (c channelDo) Preload(fields ...field.RelationField) *channelDo {
|
|
for _, _f := range fields {
|
|
c = *c.withDO(c.DO.Preload(_f))
|
|
}
|
|
return &c
|
|
}
|
|
|
|
func (c channelDo) FirstOrInit() (*models.Channel, error) {
|
|
if result, err := c.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Channel), nil
|
|
}
|
|
}
|
|
|
|
func (c channelDo) FirstOrCreate() (*models.Channel, error) {
|
|
if result, err := c.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Channel), nil
|
|
}
|
|
}
|
|
|
|
func (c channelDo) FindByPage(offset int, limit int) (result []*models.Channel, count int64, err error) {
|
|
result, err = c.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = c.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (c channelDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = c.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = c.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (c channelDo) Scan(result interface{}) (err error) {
|
|
return c.DO.Scan(result)
|
|
}
|
|
|
|
func (c channelDo) Delete(models ...*models.Channel) (result gen.ResultInfo, err error) {
|
|
return c.DO.Delete(models)
|
|
}
|
|
|
|
func (c *channelDo) withDO(do gen.Dao) *channelDo {
|
|
c.DO = *do.(*gen.DO)
|
|
return c
|
|
}
|