mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-29 18:51:22 +00:00
428 lines
14 KiB
Go
428 lines
14 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 newHealthcheckHTTP(db *gorm.DB, opts ...gen.DOOption) healthcheckHTTP {
|
|
_healthcheckHTTP := healthcheckHTTP{}
|
|
|
|
_healthcheckHTTP.healthcheckHTTPDo.UseDB(db, opts...)
|
|
_healthcheckHTTP.healthcheckHTTPDo.UseModel(&models.HealthcheckHTTP{})
|
|
|
|
tableName := _healthcheckHTTP.healthcheckHTTPDo.TableName()
|
|
_healthcheckHTTP.ALL = field.NewAsterisk(tableName)
|
|
_healthcheckHTTP.ID = field.NewUint(tableName, "id")
|
|
_healthcheckHTTP.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_healthcheckHTTP.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_healthcheckHTTP.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
_healthcheckHTTP.Name = field.NewString(tableName, "name")
|
|
_healthcheckHTTP.Status = field.NewString(tableName, "status")
|
|
_healthcheckHTTP.UptimePercentage = field.NewFloat64(tableName, "uptime_percentage")
|
|
_healthcheckHTTP.Schedule = field.NewString(tableName, "schedule")
|
|
_healthcheckHTTP.URL = field.NewString(tableName, "url")
|
|
_healthcheckHTTP.Method = field.NewString(tableName, "method")
|
|
|
|
_healthcheckHTTP.fillFieldMap()
|
|
|
|
return _healthcheckHTTP
|
|
}
|
|
|
|
type healthcheckHTTP struct {
|
|
healthcheckHTTPDo healthcheckHTTPDo
|
|
|
|
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
|
|
URL field.String
|
|
Method field.String
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (h healthcheckHTTP) Table(newTableName string) *healthcheckHTTP {
|
|
h.healthcheckHTTPDo.UseTable(newTableName)
|
|
return h.updateTableName(newTableName)
|
|
}
|
|
|
|
func (h healthcheckHTTP) As(alias string) *healthcheckHTTP {
|
|
h.healthcheckHTTPDo.DO = *(h.healthcheckHTTPDo.As(alias).(*gen.DO))
|
|
return h.updateTableName(alias)
|
|
}
|
|
|
|
func (h *healthcheckHTTP) updateTableName(table string) *healthcheckHTTP {
|
|
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.URL = field.NewString(table, "url")
|
|
h.Method = field.NewString(table, "method")
|
|
|
|
h.fillFieldMap()
|
|
|
|
return h
|
|
}
|
|
|
|
func (h *healthcheckHTTP) WithContext(ctx context.Context) IHealthcheckHTTPDo {
|
|
return h.healthcheckHTTPDo.WithContext(ctx)
|
|
}
|
|
|
|
func (h healthcheckHTTP) TableName() string { return h.healthcheckHTTPDo.TableName() }
|
|
|
|
func (h healthcheckHTTP) Alias() string { return h.healthcheckHTTPDo.Alias() }
|
|
|
|
func (h healthcheckHTTP) Columns(cols ...field.Expr) gen.Columns {
|
|
return h.healthcheckHTTPDo.Columns(cols...)
|
|
}
|
|
|
|
func (h *healthcheckHTTP) 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 *healthcheckHTTP) 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["url"] = h.URL
|
|
h.fieldMap["method"] = h.Method
|
|
}
|
|
|
|
func (h healthcheckHTTP) clone(db *gorm.DB) healthcheckHTTP {
|
|
h.healthcheckHTTPDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return h
|
|
}
|
|
|
|
func (h healthcheckHTTP) replaceDB(db *gorm.DB) healthcheckHTTP {
|
|
h.healthcheckHTTPDo.ReplaceDB(db)
|
|
return h
|
|
}
|
|
|
|
type healthcheckHTTPDo struct{ gen.DO }
|
|
|
|
type IHealthcheckHTTPDo interface {
|
|
gen.SubQuery
|
|
Debug() IHealthcheckHTTPDo
|
|
WithContext(ctx context.Context) IHealthcheckHTTPDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IHealthcheckHTTPDo
|
|
WriteDB() IHealthcheckHTTPDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IHealthcheckHTTPDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IHealthcheckHTTPDo
|
|
Not(conds ...gen.Condition) IHealthcheckHTTPDo
|
|
Or(conds ...gen.Condition) IHealthcheckHTTPDo
|
|
Select(conds ...field.Expr) IHealthcheckHTTPDo
|
|
Where(conds ...gen.Condition) IHealthcheckHTTPDo
|
|
Order(conds ...field.Expr) IHealthcheckHTTPDo
|
|
Distinct(cols ...field.Expr) IHealthcheckHTTPDo
|
|
Omit(cols ...field.Expr) IHealthcheckHTTPDo
|
|
Join(table schema.Tabler, on ...field.Expr) IHealthcheckHTTPDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IHealthcheckHTTPDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IHealthcheckHTTPDo
|
|
Group(cols ...field.Expr) IHealthcheckHTTPDo
|
|
Having(conds ...gen.Condition) IHealthcheckHTTPDo
|
|
Limit(limit int) IHealthcheckHTTPDo
|
|
Offset(offset int) IHealthcheckHTTPDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IHealthcheckHTTPDo
|
|
Unscoped() IHealthcheckHTTPDo
|
|
Create(values ...*models.HealthcheckHTTP) error
|
|
CreateInBatches(values []*models.HealthcheckHTTP, batchSize int) error
|
|
Save(values ...*models.HealthcheckHTTP) error
|
|
First() (*models.HealthcheckHTTP, error)
|
|
Take() (*models.HealthcheckHTTP, error)
|
|
Last() (*models.HealthcheckHTTP, error)
|
|
Find() ([]*models.HealthcheckHTTP, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.HealthcheckHTTP, err error)
|
|
FindInBatches(result *[]*models.HealthcheckHTTP, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*models.HealthcheckHTTP) (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) IHealthcheckHTTPDo
|
|
Assign(attrs ...field.AssignExpr) IHealthcheckHTTPDo
|
|
Joins(fields ...field.RelationField) IHealthcheckHTTPDo
|
|
Preload(fields ...field.RelationField) IHealthcheckHTTPDo
|
|
FirstOrInit() (*models.HealthcheckHTTP, error)
|
|
FirstOrCreate() (*models.HealthcheckHTTP, error)
|
|
FindByPage(offset int, limit int) (result []*models.HealthcheckHTTP, 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) IHealthcheckHTTPDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Debug() IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Debug())
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) WithContext(ctx context.Context) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) ReadDB() IHealthcheckHTTPDo {
|
|
return h.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) WriteDB() IHealthcheckHTTPDo {
|
|
return h.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Session(config *gorm.Session) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Session(config))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Clauses(conds ...clause.Expression) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Returning(value interface{}, columns ...string) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Not(conds ...gen.Condition) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Not(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Or(conds ...gen.Condition) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Or(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Select(conds ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Select(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Where(conds ...gen.Condition) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Where(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Order(conds ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Order(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Distinct(cols ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Omit(cols ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Omit(cols...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Join(table schema.Tabler, on ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Join(table, on...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) LeftJoin(table schema.Tabler, on ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) RightJoin(table schema.Tabler, on ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Group(cols ...field.Expr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Group(cols...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Having(conds ...gen.Condition) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Having(conds...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Limit(limit int) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Limit(limit))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Offset(offset int) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Offset(offset))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Unscoped() IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Unscoped())
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Create(values ...*models.HealthcheckHTTP) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return h.DO.Create(values)
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) CreateInBatches(values []*models.HealthcheckHTTP, 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 healthcheckHTTPDo) Save(values ...*models.HealthcheckHTTP) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return h.DO.Save(values)
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) First() (*models.HealthcheckHTTP, error) {
|
|
if result, err := h.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.HealthcheckHTTP), nil
|
|
}
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Take() (*models.HealthcheckHTTP, error) {
|
|
if result, err := h.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.HealthcheckHTTP), nil
|
|
}
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Last() (*models.HealthcheckHTTP, error) {
|
|
if result, err := h.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.HealthcheckHTTP), nil
|
|
}
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Find() ([]*models.HealthcheckHTTP, error) {
|
|
result, err := h.DO.Find()
|
|
return result.([]*models.HealthcheckHTTP), err
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.HealthcheckHTTP, err error) {
|
|
buf := make([]*models.HealthcheckHTTP, 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 healthcheckHTTPDo) FindInBatches(result *[]*models.HealthcheckHTTP, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return h.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Attrs(attrs ...field.AssignExpr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Assign(attrs ...field.AssignExpr) IHealthcheckHTTPDo {
|
|
return h.withDO(h.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Joins(fields ...field.RelationField) IHealthcheckHTTPDo {
|
|
for _, _f := range fields {
|
|
h = *h.withDO(h.DO.Joins(_f))
|
|
}
|
|
return &h
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Preload(fields ...field.RelationField) IHealthcheckHTTPDo {
|
|
for _, _f := range fields {
|
|
h = *h.withDO(h.DO.Preload(_f))
|
|
}
|
|
return &h
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) FirstOrInit() (*models.HealthcheckHTTP, error) {
|
|
if result, err := h.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.HealthcheckHTTP), nil
|
|
}
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) FirstOrCreate() (*models.HealthcheckHTTP, error) {
|
|
if result, err := h.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.HealthcheckHTTP), nil
|
|
}
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) FindByPage(offset int, limit int) (result []*models.HealthcheckHTTP, 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 healthcheckHTTPDo) 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 healthcheckHTTPDo) Scan(result interface{}) (err error) {
|
|
return h.DO.Scan(result)
|
|
}
|
|
|
|
func (h healthcheckHTTPDo) Delete(models ...*models.HealthcheckHTTP) (result gen.ResultInfo, err error) {
|
|
return h.DO.Delete(models)
|
|
}
|
|
|
|
func (h *healthcheckHTTPDo) withDO(do gen.Dao) *healthcheckHTTPDo {
|
|
h.DO = *do.(*gen.DO)
|
|
return h
|
|
}
|