|
|
// 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 dao
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
"gorm.io/gorm/clause"
|
|
|
"gorm.io/gorm/schema"
|
|
|
|
|
|
"gorm.io/gen"
|
|
|
"gorm.io/gen/field"
|
|
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
|
|
"joybuywork/internal/repository/model"
|
|
|
)
|
|
|
|
|
|
func newNotifyURL(db *gorm.DB, opts ...gen.DOOption) notifyURL {
|
|
|
_notifyURL := notifyURL{}
|
|
|
|
|
|
_notifyURL.notifyURLDo.UseDB(db, opts...)
|
|
|
_notifyURL.notifyURLDo.UseModel(&model.NotifyURL{})
|
|
|
|
|
|
tableName := _notifyURL.notifyURLDo.TableName()
|
|
|
_notifyURL.ALL = field.NewAsterisk(tableName)
|
|
|
_notifyURL.ID = field.NewInt64(tableName, "id")
|
|
|
_notifyURL.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_notifyURL.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_notifyURL.IsDel = field.NewInt64(tableName, "is_del")
|
|
|
_notifyURL.ProjectID = field.NewInt64(tableName, "project_id")
|
|
|
_notifyURL.Title = field.NewString(tableName, "title")
|
|
|
_notifyURL.URL = field.NewString(tableName, "url")
|
|
|
_notifyURL.OldData = field.NewInt8(tableName, "old_data")
|
|
|
_notifyURL.Source = field.NewInt8(tableName, "source")
|
|
|
_notifyURL.Headers = field.NewString(tableName, "headers")
|
|
|
|
|
|
_notifyURL.fillFieldMap()
|
|
|
|
|
|
return _notifyURL
|
|
|
}
|
|
|
|
|
|
type notifyURL struct {
|
|
|
notifyURLDo notifyURLDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
IsDel field.Int64
|
|
|
ProjectID field.Int64 // 项目id(project表)
|
|
|
Title field.String // 地址名称
|
|
|
URL field.String // 回调地址
|
|
|
OldData field.Int8 // 是否旧数据(0-否,1-是)
|
|
|
Source field.Int8 // 数据来源(0-后台创建,1-奖品数据迁移,2-api创建)
|
|
|
Headers field.String // 请求头数据
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (n notifyURL) Table(newTableName string) *notifyURL {
|
|
|
n.notifyURLDo.UseTable(newTableName)
|
|
|
return n.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (n notifyURL) As(alias string) *notifyURL {
|
|
|
n.notifyURLDo.DO = *(n.notifyURLDo.As(alias).(*gen.DO))
|
|
|
return n.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (n *notifyURL) updateTableName(table string) *notifyURL {
|
|
|
n.ALL = field.NewAsterisk(table)
|
|
|
n.ID = field.NewInt64(table, "id")
|
|
|
n.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
n.UpdatedAt = field.NewInt64(table, "updated_at")
|
|
|
n.IsDel = field.NewInt64(table, "is_del")
|
|
|
n.ProjectID = field.NewInt64(table, "project_id")
|
|
|
n.Title = field.NewString(table, "title")
|
|
|
n.URL = field.NewString(table, "url")
|
|
|
n.OldData = field.NewInt8(table, "old_data")
|
|
|
n.Source = field.NewInt8(table, "source")
|
|
|
n.Headers = field.NewString(table, "headers")
|
|
|
|
|
|
n.fillFieldMap()
|
|
|
|
|
|
return n
|
|
|
}
|
|
|
|
|
|
func (n *notifyURL) WithContext(ctx context.Context) *notifyURLDo {
|
|
|
return n.notifyURLDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (n notifyURL) TableName() string { return n.notifyURLDo.TableName() }
|
|
|
|
|
|
func (n notifyURL) Alias() string { return n.notifyURLDo.Alias() }
|
|
|
|
|
|
func (n *notifyURL) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
_f, ok := n.fieldMap[fieldName]
|
|
|
if !ok || _f == nil {
|
|
|
return nil, false
|
|
|
}
|
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
|
return _oe, ok
|
|
|
}
|
|
|
|
|
|
func (n *notifyURL) fillFieldMap() {
|
|
|
n.fieldMap = make(map[string]field.Expr, 10)
|
|
|
n.fieldMap["id"] = n.ID
|
|
|
n.fieldMap["created_at"] = n.CreatedAt
|
|
|
n.fieldMap["updated_at"] = n.UpdatedAt
|
|
|
n.fieldMap["is_del"] = n.IsDel
|
|
|
n.fieldMap["project_id"] = n.ProjectID
|
|
|
n.fieldMap["title"] = n.Title
|
|
|
n.fieldMap["url"] = n.URL
|
|
|
n.fieldMap["old_data"] = n.OldData
|
|
|
n.fieldMap["source"] = n.Source
|
|
|
n.fieldMap["headers"] = n.Headers
|
|
|
}
|
|
|
|
|
|
func (n notifyURL) clone(db *gorm.DB) notifyURL {
|
|
|
n.notifyURLDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return n
|
|
|
}
|
|
|
|
|
|
func (n notifyURL) replaceDB(db *gorm.DB) notifyURL {
|
|
|
n.notifyURLDo.ReplaceDB(db)
|
|
|
return n
|
|
|
}
|
|
|
|
|
|
type notifyURLDo struct{ gen.DO }
|
|
|
|
|
|
func (n notifyURLDo) Debug() *notifyURLDo {
|
|
|
return n.withDO(n.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) WithContext(ctx context.Context) *notifyURLDo {
|
|
|
return n.withDO(n.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) ReadDB() *notifyURLDo {
|
|
|
return n.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) WriteDB() *notifyURLDo {
|
|
|
return n.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Session(config *gorm.Session) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Clauses(conds ...clause.Expression) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Returning(value interface{}, columns ...string) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Not(conds ...gen.Condition) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Or(conds ...gen.Condition) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Select(conds ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Where(conds ...gen.Condition) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *notifyURLDo {
|
|
|
return n.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Order(conds ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Distinct(cols ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Omit(cols ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Join(table schema.Tabler, on ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) LeftJoin(table schema.Tabler, on ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) RightJoin(table schema.Tabler, on ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Group(cols ...field.Expr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Having(conds ...gen.Condition) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Limit(limit int) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Offset(offset int) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Unscoped() *notifyURLDo {
|
|
|
return n.withDO(n.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Create(values ...*model.NotifyURL) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return n.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) CreateInBatches(values []*model.NotifyURL, batchSize int) error {
|
|
|
return n.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 (n notifyURLDo) Save(values ...*model.NotifyURL) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return n.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) First() (*model.NotifyURL, error) {
|
|
|
if result, err := n.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.NotifyURL), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Take() (*model.NotifyURL, error) {
|
|
|
if result, err := n.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.NotifyURL), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Last() (*model.NotifyURL, error) {
|
|
|
if result, err := n.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.NotifyURL), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Find() ([]*model.NotifyURL, error) {
|
|
|
result, err := n.DO.Find()
|
|
|
return result.([]*model.NotifyURL), err
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.NotifyURL, err error) {
|
|
|
buf := make([]*model.NotifyURL, 0, batchSize)
|
|
|
err = n.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 (n notifyURLDo) FindInBatches(result *[]*model.NotifyURL, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return n.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Attrs(attrs ...field.AssignExpr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Assign(attrs ...field.AssignExpr) *notifyURLDo {
|
|
|
return n.withDO(n.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Joins(fields ...field.RelationField) *notifyURLDo {
|
|
|
for _, _f := range fields {
|
|
|
n = *n.withDO(n.DO.Joins(_f))
|
|
|
}
|
|
|
return &n
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Preload(fields ...field.RelationField) *notifyURLDo {
|
|
|
for _, _f := range fields {
|
|
|
n = *n.withDO(n.DO.Preload(_f))
|
|
|
}
|
|
|
return &n
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) FirstOrInit() (*model.NotifyURL, error) {
|
|
|
if result, err := n.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.NotifyURL), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) FirstOrCreate() (*model.NotifyURL, error) {
|
|
|
if result, err := n.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.NotifyURL), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) FindByPage(offset int, limit int) (result []*model.NotifyURL, count int64, err error) {
|
|
|
result, err = n.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 = n.Offset(-1).Limit(-1).Count()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
count, err = n.Count()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = n.Offset(offset).Limit(limit).Scan(result)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Scan(result interface{}) (err error) {
|
|
|
return n.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (n notifyURLDo) Delete(models ...*model.NotifyURL) (result gen.ResultInfo, err error) {
|
|
|
return n.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (n *notifyURLDo) withDO(do gen.Dao) *notifyURLDo {
|
|
|
n.DO = *do.(*gen.DO)
|
|
|
return n
|
|
|
}
|