384 lines
10 KiB
Go
384 lines
10 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.UserID = field.NewInt32(tableName, "user_id")
|
||
_channel.ProxyID = field.NewInt32(tableName, "proxy_id")
|
||
_channel.NodeID = field.NewInt32(tableName, "node_id")
|
||
_channel.ProxyPort = field.NewInt32(tableName, "proxy_port")
|
||
_channel.UserHost = field.NewString(tableName, "user_host")
|
||
_channel.NodeHost = field.NewString(tableName, "node_host")
|
||
_channel.AuthIP = field.NewBool(tableName, "auth_ip")
|
||
_channel.AuthPass = field.NewBool(tableName, "auth_pass")
|
||
_channel.Username = field.NewString(tableName, "username")
|
||
_channel.Password = field.NewString(tableName, "password")
|
||
_channel.Expiration = field.NewTime(tableName, "expiration")
|
||
_channel.CreatedAt = field.NewField(tableName, "created_at")
|
||
_channel.UpdatedAt = field.NewField(tableName, "updated_at")
|
||
_channel.DeletedAt = field.NewField(tableName, "deleted_at")
|
||
_channel.ProxyHost = field.NewString(tableName, "proxy_host")
|
||
_channel.Protocol = field.NewInt32(tableName, "protocol")
|
||
|
||
_channel.fillFieldMap()
|
||
|
||
return _channel
|
||
}
|
||
|
||
type channel struct {
|
||
channelDo
|
||
|
||
ALL field.Asterisk
|
||
ID field.Int32 // 通道ID
|
||
UserID field.Int32 // 用户ID
|
||
ProxyID field.Int32 // 代理ID
|
||
NodeID field.Int32 // 节点ID
|
||
ProxyPort field.Int32 // 转发端口
|
||
UserHost field.String // 用户地址
|
||
NodeHost field.String // 节点地址
|
||
AuthIP field.Bool // IP认证
|
||
AuthPass field.Bool // 密码认证
|
||
Username field.String // 用户名
|
||
Password field.String // 密码
|
||
Expiration field.Time // 过期时间
|
||
CreatedAt field.Field // 创建时间
|
||
UpdatedAt field.Field // 更新时间
|
||
DeletedAt field.Field // 删除时间
|
||
ProxyHost field.String
|
||
Protocol field.Int32 // 协议类型:1-http,2-https,3-socks5
|
||
|
||
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.UserID = field.NewInt32(table, "user_id")
|
||
c.ProxyID = field.NewInt32(table, "proxy_id")
|
||
c.NodeID = field.NewInt32(table, "node_id")
|
||
c.ProxyPort = field.NewInt32(table, "proxy_port")
|
||
c.UserHost = field.NewString(table, "user_host")
|
||
c.NodeHost = field.NewString(table, "node_host")
|
||
c.AuthIP = field.NewBool(table, "auth_ip")
|
||
c.AuthPass = field.NewBool(table, "auth_pass")
|
||
c.Username = field.NewString(table, "username")
|
||
c.Password = field.NewString(table, "password")
|
||
c.Expiration = field.NewTime(table, "expiration")
|
||
c.CreatedAt = field.NewField(table, "created_at")
|
||
c.UpdatedAt = field.NewField(table, "updated_at")
|
||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||
c.ProxyHost = field.NewString(table, "proxy_host")
|
||
c.Protocol = field.NewInt32(table, "protocol")
|
||
|
||
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, 17)
|
||
c.fieldMap["id"] = c.ID
|
||
c.fieldMap["user_id"] = c.UserID
|
||
c.fieldMap["proxy_id"] = c.ProxyID
|
||
c.fieldMap["node_id"] = c.NodeID
|
||
c.fieldMap["proxy_port"] = c.ProxyPort
|
||
c.fieldMap["user_host"] = c.UserHost
|
||
c.fieldMap["node_host"] = c.NodeHost
|
||
c.fieldMap["auth_ip"] = c.AuthIP
|
||
c.fieldMap["auth_pass"] = c.AuthPass
|
||
c.fieldMap["username"] = c.Username
|
||
c.fieldMap["password"] = c.Password
|
||
c.fieldMap["expiration"] = c.Expiration
|
||
c.fieldMap["created_at"] = c.CreatedAt
|
||
c.fieldMap["updated_at"] = c.UpdatedAt
|
||
c.fieldMap["deleted_at"] = c.DeletedAt
|
||
c.fieldMap["proxy_host"] = c.ProxyHost
|
||
c.fieldMap["protocol"] = c.Protocol
|
||
}
|
||
|
||
func (c channel) clone(db *gorm.DB) channel {
|
||
c.channelDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
return c
|
||
}
|
||
|
||
func (c channel) replaceDB(db *gorm.DB) channel {
|
||
c.channelDo.ReplaceDB(db)
|
||
return c
|
||
}
|
||
|
||
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
|
||
}
|