mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-27 01:33:37 +00:00
429 lines
13 KiB
Go
429 lines
13 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 query
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"gorm.io/gorm"
|
||
|
"gorm.io/gorm/clause"
|
||
|
"gorm.io/gorm/schema"
|
||
|
|
||
|
"gorm.io/gen"
|
||
|
"gorm.io/gen/field"
|
||
|
|
||
|
"gorm.io/plugin/dbresolver"
|
||
|
|
||
|
"code.tjo.space/mentos1386/zdravko/internal/models"
|
||
|
)
|
||
|
|
||
|
func newHealthcheckTCP(db *gorm.DB, opts ...gen.DOOption) healthcheckTCP {
|
||
|
_healthcheckTCP := healthcheckTCP{}
|
||
|
|
||
|
_healthcheckTCP.healthcheckTCPDo.UseDB(db, opts...)
|
||
|
_healthcheckTCP.healthcheckTCPDo.UseModel(&models.HealthcheckTCP{})
|
||
|
|
||
|
tableName := _healthcheckTCP.healthcheckTCPDo.TableName()
|
||
|
_healthcheckTCP.ALL = field.NewAsterisk(tableName)
|
||
|
_healthcheckTCP.ID = field.NewUint(tableName, "id")
|
||
|
_healthcheckTCP.CreatedAt = field.NewTime(tableName, "created_at")
|
||
|
_healthcheckTCP.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||
|
_healthcheckTCP.DeletedAt = field.NewField(tableName, "deleted_at")
|
||
|
_healthcheckTCP.Name = field.NewString(tableName, "name")
|
||
|
_healthcheckTCP.Status = field.NewString(tableName, "status")
|
||
|
_healthcheckTCP.UptimePercentage = field.NewFloat64(tableName, "uptime_percentage")
|
||
|
_healthcheckTCP.Schedule = field.NewString(tableName, "schedule")
|
||
|
_healthcheckTCP.Hostname = field.NewString(tableName, "hostname")
|
||
|
_healthcheckTCP.Port = field.NewInt(tableName, "port")
|
||
|
|
||
|
_healthcheckTCP.fillFieldMap()
|
||
|
|
||
|
return _healthcheckTCP
|
||
|
}
|
||
|
|
||
|
type healthcheckTCP struct {
|
||
|
healthcheckTCPDo healthcheckTCPDo
|
||
|
|
||
|
ALL field.Asterisk
|
||
|
ID field.Uint
|
||
|
CreatedAt field.Time
|
||
|
UpdatedAt field.Time
|
||
|
DeletedAt field.Field
|
||
|
Name field.String
|
||
|
Status field.String
|
||
|
UptimePercentage field.Float64
|
||
|
Schedule field.String
|
||
|
Hostname field.String
|
||
|
Port field.Int
|
||
|
|
||
|
fieldMap map[string]field.Expr
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCP) Table(newTableName string) *healthcheckTCP {
|
||
|
h.healthcheckTCPDo.UseTable(newTableName)
|
||
|
return h.updateTableName(newTableName)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCP) As(alias string) *healthcheckTCP {
|
||
|
h.healthcheckTCPDo.DO = *(h.healthcheckTCPDo.As(alias).(*gen.DO))
|
||
|
return h.updateTableName(alias)
|
||
|
}
|
||
|
|
||
|
func (h *healthcheckTCP) updateTableName(table string) *healthcheckTCP {
|
||
|
h.ALL = field.NewAsterisk(table)
|
||
|
h.ID = field.NewUint(table, "id")
|
||
|
h.CreatedAt = field.NewTime(table, "created_at")
|
||
|
h.UpdatedAt = field.NewTime(table, "updated_at")
|
||
|
h.DeletedAt = field.NewField(table, "deleted_at")
|
||
|
h.Name = field.NewString(table, "name")
|
||
|
h.Status = field.NewString(table, "status")
|
||
|
h.UptimePercentage = field.NewFloat64(table, "uptime_percentage")
|
||
|
h.Schedule = field.NewString(table, "schedule")
|
||
|
h.Hostname = field.NewString(table, "hostname")
|
||
|
h.Port = field.NewInt(table, "port")
|
||
|
|
||
|
h.fillFieldMap()
|
||
|
|
||
|
return h
|
||
|
}
|
||
|
|
||
|
func (h *healthcheckTCP) WithContext(ctx context.Context) IHealthcheckTCPDo {
|
||
|
return h.healthcheckTCPDo.WithContext(ctx)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCP) TableName() string { return h.healthcheckTCPDo.TableName() }
|
||
|
|
||
|
func (h healthcheckTCP) Alias() string { return h.healthcheckTCPDo.Alias() }
|
||
|
|
||
|
func (h healthcheckTCP) Columns(cols ...field.Expr) gen.Columns {
|
||
|
return h.healthcheckTCPDo.Columns(cols...)
|
||
|
}
|
||
|
|
||
|
func (h *healthcheckTCP) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||
|
_f, ok := h.fieldMap[fieldName]
|
||
|
if !ok || _f == nil {
|
||
|
return nil, false
|
||
|
}
|
||
|
_oe, ok := _f.(field.OrderExpr)
|
||
|
return _oe, ok
|
||
|
}
|
||
|
|
||
|
func (h *healthcheckTCP) fillFieldMap() {
|
||
|
h.fieldMap = make(map[string]field.Expr, 10)
|
||
|
h.fieldMap["id"] = h.ID
|
||
|
h.fieldMap["created_at"] = h.CreatedAt
|
||
|
h.fieldMap["updated_at"] = h.UpdatedAt
|
||
|
h.fieldMap["deleted_at"] = h.DeletedAt
|
||
|
h.fieldMap["name"] = h.Name
|
||
|
h.fieldMap["status"] = h.Status
|
||
|
h.fieldMap["uptime_percentage"] = h.UptimePercentage
|
||
|
h.fieldMap["schedule"] = h.Schedule
|
||
|
h.fieldMap["hostname"] = h.Hostname
|
||
|
h.fieldMap["port"] = h.Port
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCP) clone(db *gorm.DB) healthcheckTCP {
|
||
|
h.healthcheckTCPDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
|
return h
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCP) replaceDB(db *gorm.DB) healthcheckTCP {
|
||
|
h.healthcheckTCPDo.ReplaceDB(db)
|
||
|
return h
|
||
|
}
|
||
|
|
||
|
type healthcheckTCPDo struct{ gen.DO }
|
||
|
|
||
|
type IHealthcheckTCPDo interface {
|
||
|
gen.SubQuery
|
||
|
Debug() IHealthcheckTCPDo
|
||
|
WithContext(ctx context.Context) IHealthcheckTCPDo
|
||
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||
|
ReplaceDB(db *gorm.DB)
|
||
|
ReadDB() IHealthcheckTCPDo
|
||
|
WriteDB() IHealthcheckTCPDo
|
||
|
As(alias string) gen.Dao
|
||
|
Session(config *gorm.Session) IHealthcheckTCPDo
|
||
|
Columns(cols ...field.Expr) gen.Columns
|
||
|
Clauses(conds ...clause.Expression) IHealthcheckTCPDo
|
||
|
Not(conds ...gen.Condition) IHealthcheckTCPDo
|
||
|
Or(conds ...gen.Condition) IHealthcheckTCPDo
|
||
|
Select(conds ...field.Expr) IHealthcheckTCPDo
|
||
|
Where(conds ...gen.Condition) IHealthcheckTCPDo
|
||
|
Order(conds ...field.Expr) IHealthcheckTCPDo
|
||
|
Distinct(cols ...field.Expr) IHealthcheckTCPDo
|
||
|
Omit(cols ...field.Expr) IHealthcheckTCPDo
|
||
|
Join(table schema.Tabler, on ...field.Expr) IHealthcheckTCPDo
|
||
|
LeftJoin(table schema.Tabler, on ...field.Expr) IHealthcheckTCPDo
|
||
|
RightJoin(table schema.Tabler, on ...field.Expr) IHealthcheckTCPDo
|
||
|
Group(cols ...field.Expr) IHealthcheckTCPDo
|
||
|
Having(conds ...gen.Condition) IHealthcheckTCPDo
|
||
|
Limit(limit int) IHealthcheckTCPDo
|
||
|
Offset(offset int) IHealthcheckTCPDo
|
||
|
Count() (count int64, err error)
|
||
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IHealthcheckTCPDo
|
||
|
Unscoped() IHealthcheckTCPDo
|
||
|
Create(values ...*models.HealthcheckTCP) error
|
||
|
CreateInBatches(values []*models.HealthcheckTCP, batchSize int) error
|
||
|
Save(values ...*models.HealthcheckTCP) error
|
||
|
First() (*models.HealthcheckTCP, error)
|
||
|
Take() (*models.HealthcheckTCP, error)
|
||
|
Last() (*models.HealthcheckTCP, error)
|
||
|
Find() ([]*models.HealthcheckTCP, error)
|
||
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.HealthcheckTCP, err error)
|
||
|
FindInBatches(result *[]*models.HealthcheckTCP, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||
|
Pluck(column field.Expr, dest interface{}) error
|
||
|
Delete(...*models.HealthcheckTCP) (info gen.ResultInfo, err error)
|
||
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||
|
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateFrom(q gen.SubQuery) gen.Dao
|
||
|
Attrs(attrs ...field.AssignExpr) IHealthcheckTCPDo
|
||
|
Assign(attrs ...field.AssignExpr) IHealthcheckTCPDo
|
||
|
Joins(fields ...field.RelationField) IHealthcheckTCPDo
|
||
|
Preload(fields ...field.RelationField) IHealthcheckTCPDo
|
||
|
FirstOrInit() (*models.HealthcheckTCP, error)
|
||
|
FirstOrCreate() (*models.HealthcheckTCP, error)
|
||
|
FindByPage(offset int, limit int) (result []*models.HealthcheckTCP, count int64, err error)
|
||
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||
|
Scan(result interface{}) (err error)
|
||
|
Returning(value interface{}, columns ...string) IHealthcheckTCPDo
|
||
|
UnderlyingDB() *gorm.DB
|
||
|
schema.Tabler
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Debug() IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Debug())
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) WithContext(ctx context.Context) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.WithContext(ctx))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) ReadDB() IHealthcheckTCPDo {
|
||
|
return h.Clauses(dbresolver.Read)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) WriteDB() IHealthcheckTCPDo {
|
||
|
return h.Clauses(dbresolver.Write)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Session(config *gorm.Session) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Session(config))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Clauses(conds ...clause.Expression) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Clauses(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Returning(value interface{}, columns ...string) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Returning(value, columns...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Not(conds ...gen.Condition) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Not(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Or(conds ...gen.Condition) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Or(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Select(conds ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Select(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Where(conds ...gen.Condition) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Where(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Order(conds ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Order(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Distinct(cols ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Distinct(cols...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Omit(cols ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Omit(cols...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Join(table schema.Tabler, on ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Join(table, on...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) LeftJoin(table schema.Tabler, on ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.LeftJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) RightJoin(table schema.Tabler, on ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.RightJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Group(cols ...field.Expr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Group(cols...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Having(conds ...gen.Condition) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Having(conds...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Limit(limit int) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Limit(limit))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Offset(offset int) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Offset(offset))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Scopes(funcs...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Unscoped() IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Unscoped())
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Create(values ...*models.HealthcheckTCP) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return h.DO.Create(values)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) CreateInBatches(values []*models.HealthcheckTCP, batchSize int) error {
|
||
|
return h.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 (h healthcheckTCPDo) Save(values ...*models.HealthcheckTCP) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return h.DO.Save(values)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) First() (*models.HealthcheckTCP, error) {
|
||
|
if result, err := h.DO.First(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*models.HealthcheckTCP), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Take() (*models.HealthcheckTCP, error) {
|
||
|
if result, err := h.DO.Take(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*models.HealthcheckTCP), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Last() (*models.HealthcheckTCP, error) {
|
||
|
if result, err := h.DO.Last(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*models.HealthcheckTCP), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Find() ([]*models.HealthcheckTCP, error) {
|
||
|
result, err := h.DO.Find()
|
||
|
return result.([]*models.HealthcheckTCP), err
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.HealthcheckTCP, err error) {
|
||
|
buf := make([]*models.HealthcheckTCP, 0, batchSize)
|
||
|
err = h.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 (h healthcheckTCPDo) FindInBatches(result *[]*models.HealthcheckTCP, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||
|
return h.DO.FindInBatches(result, batchSize, fc)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Attrs(attrs ...field.AssignExpr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Attrs(attrs...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Assign(attrs ...field.AssignExpr) IHealthcheckTCPDo {
|
||
|
return h.withDO(h.DO.Assign(attrs...))
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Joins(fields ...field.RelationField) IHealthcheckTCPDo {
|
||
|
for _, _f := range fields {
|
||
|
h = *h.withDO(h.DO.Joins(_f))
|
||
|
}
|
||
|
return &h
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Preload(fields ...field.RelationField) IHealthcheckTCPDo {
|
||
|
for _, _f := range fields {
|
||
|
h = *h.withDO(h.DO.Preload(_f))
|
||
|
}
|
||
|
return &h
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) FirstOrInit() (*models.HealthcheckTCP, error) {
|
||
|
if result, err := h.DO.FirstOrInit(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*models.HealthcheckTCP), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) FirstOrCreate() (*models.HealthcheckTCP, error) {
|
||
|
if result, err := h.DO.FirstOrCreate(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*models.HealthcheckTCP), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) FindByPage(offset int, limit int) (result []*models.HealthcheckTCP, count int64, err error) {
|
||
|
result, err = h.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 = h.Offset(-1).Limit(-1).Count()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||
|
count, err = h.Count()
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
err = h.Offset(offset).Limit(limit).Scan(result)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Scan(result interface{}) (err error) {
|
||
|
return h.DO.Scan(result)
|
||
|
}
|
||
|
|
||
|
func (h healthcheckTCPDo) Delete(models ...*models.HealthcheckTCP) (result gen.ResultInfo, err error) {
|
||
|
return h.DO.Delete(models)
|
||
|
}
|
||
|
|
||
|
func (h *healthcheckTCPDo) withDO(do gen.Dao) *healthcheckTCPDo {
|
||
|
h.DO = *do.(*gen.DO)
|
||
|
return h
|
||
|
}
|