代码拉取完成,页面将自动刷新
// @generated Do not edit this file, which is automatically generated by the generator.
package dbschema
import (
"fmt"
"github.com/webx-top/db"
"github.com/webx-top/db/lib/factory"
"time"
)
// DbSyncLog 数据表同步日志
type DbSyncLog struct {
param *factory.Param
trans *factory.Transaction
objects []*DbSyncLog
namer func(string) string
connID int
Id uint64 `db:"id,omitempty,pk" bson:"id,omitempty" comment:"" json:"id" xml:"id"`
SyncId uint `db:"sync_id" bson:"sync_id" comment:"同步方案ID" json:"sync_id" xml:"sync_id"`
Created uint `db:"created" bson:"created" comment:"创建时间" json:"created" xml:"created"`
Result string `db:"result" bson:"result" comment:"结果报表" json:"result" xml:"result"`
ChangeTables string `db:"change_tables" bson:"change_tables" comment:"被更改的表" json:"change_tables" xml:"change_tables"`
ChangeTableNum uint `db:"change_table_num" bson:"change_table_num" comment:"被更改的表的数量" json:"change_table_num" xml:"change_table_num"`
Elapsed uint64 `db:"elapsed" bson:"elapsed" comment:"总共耗时" json:"elapsed" xml:"elapsed"`
Failed uint `db:"failed" bson:"failed" comment:"失败次数" json:"failed" xml:"failed"`
}
func (this *DbSyncLog) Trans() *factory.Transaction {
return this.trans
}
func (this *DbSyncLog) Use(trans *factory.Transaction) factory.Model {
this.trans = trans
return this
}
func (this *DbSyncLog) SetConnID(connID int) factory.Model {
this.connID = connID
return this
}
func (this *DbSyncLog) New(structName string, connID ...int) factory.Model {
if len(connID) > 0 {
return factory.NewModel(structName,connID[0]).Use(this.trans)
}
return factory.NewModel(structName,this.connID).Use(this.trans)
}
func (this *DbSyncLog) Objects() []*DbSyncLog {
if this.objects == nil {
return nil
}
return this.objects[:]
}
func (this *DbSyncLog) NewObjects() *[]*DbSyncLog {
this.objects = []*DbSyncLog{}
return &this.objects
}
func (this *DbSyncLog) NewParam() *factory.Param {
return factory.NewParam(factory.DefaultFactory).SetIndex(this.connID).SetTrans(this.trans).SetCollection(this.Name_()).SetModel(this)
}
func (this *DbSyncLog) SetNamer(namer func (string) string) factory.Model {
this.namer = namer
return this
}
func (this *DbSyncLog) Short_() string {
return "db_sync_log"
}
func (this *DbSyncLog) Struct_() string {
return "DbSyncLog"
}
func (this *DbSyncLog) Name_() string {
if this.namer != nil {
return WithPrefix(this.namer(this.Short_()))
}
return WithPrefix(factory.TableNamerGet(this.Short_())(this))
}
func (this *DbSyncLog) SetParam(param *factory.Param) factory.Model {
this.param = param
return this
}
func (this *DbSyncLog) Param() *factory.Param {
if this.param == nil {
return this.NewParam()
}
return this.param
}
func (this *DbSyncLog) Get(mw func(db.Result) db.Result, args ...interface{}) error {
return this.Param().SetArgs(args...).SetRecv(this).SetMiddleware(mw).One()
}
func (this *DbSyncLog) List(recv interface{}, mw func(db.Result) db.Result, page, size int, args ...interface{}) (func() int64, error) {
if recv == nil {
recv = this.NewObjects()
}
return this.Param().SetArgs(args...).SetPage(page).SetSize(size).SetRecv(recv).SetMiddleware(mw).List()
}
func (this *DbSyncLog) GroupBy(keyField string, inputRows ...[]*DbSyncLog) map[string][]*DbSyncLog {
var rows []*DbSyncLog
if len(inputRows) > 0 {
rows = inputRows[0]
} else {
rows = this.Objects()
}
r := map[string][]*DbSyncLog{}
for _, row := range rows {
dmap := row.AsMap()
vkey := fmt.Sprint(dmap[keyField])
if _, y := r[vkey]; !y {
r[vkey] = []*DbSyncLog{}
}
r[vkey] = append(r[vkey], row)
}
return r
}
func (this *DbSyncLog) KeyBy(keyField string, inputRows ...[]*DbSyncLog) map[string]*DbSyncLog {
var rows []*DbSyncLog
if len(inputRows) > 0 {
rows = inputRows[0]
} else {
rows = this.Objects()
}
r := map[string]*DbSyncLog{}
for _, row := range rows {
dmap := row.AsMap()
vkey := fmt.Sprint(dmap[keyField])
r[vkey] = row
}
return r
}
func (this *DbSyncLog) AsKV(keyField string, valueField string, inputRows ...[]*DbSyncLog) map[string]interface{} {
var rows []*DbSyncLog
if len(inputRows) > 0 {
rows = inputRows[0]
} else {
rows = this.Objects()
}
r := map[string]interface{}{}
for _, row := range rows {
dmap := row.AsMap()
vkey := fmt.Sprint(dmap[keyField])
r[vkey] = dmap[valueField]
}
return r
}
func (this *DbSyncLog) ListByOffset(recv interface{}, mw func(db.Result) db.Result, offset, size int, args ...interface{}) (func() int64, error) {
if recv == nil {
recv = this.NewObjects()
}
return this.Param().SetArgs(args...).SetOffset(offset).SetSize(size).SetRecv(recv).SetMiddleware(mw).List()
}
func (this *DbSyncLog) Add() (pk interface{}, err error) {
this.Created = uint(time.Now().Unix())
this.Id = 0
pk, err = this.Param().SetSend(this).Insert()
if err == nil && pk != nil {
if v, y := pk.(uint64); y {
this.Id = v
} else if v, y := pk.(int64); y {
this.Id = uint64(v)
}
}
return
}
func (this *DbSyncLog) Edit(mw func(db.Result) db.Result, args ...interface{}) error {
return this.Setter(mw, args...).SetSend(this).Update()
}
func (this *DbSyncLog) Setter(mw func(db.Result) db.Result, args ...interface{}) *factory.Param {
return this.Param().SetArgs(args...).SetMiddleware(mw)
}
func (this *DbSyncLog) SetField(mw func(db.Result) db.Result, field string, value interface{}, args ...interface{}) error {
return this.SetFields(mw, map[string]interface{}{
field: value,
}, args...)
}
func (this *DbSyncLog) SetFields(mw func(db.Result) db.Result, kvset map[string]interface{}, args ...interface{}) error {
return this.Setter(mw, args...).SetSend(kvset).Update()
}
func (this *DbSyncLog) Upsert(mw func(db.Result) db.Result, args ...interface{}) (pk interface{}, err error) {
pk, err = this.Param().SetArgs(args...).SetSend(this).SetMiddleware(mw).Upsert(func(){
},func(){
this.Created = uint(time.Now().Unix())
this.Id = 0
})
if err == nil && pk != nil {
if v, y := pk.(uint64); y {
this.Id = v
} else if v, y := pk.(int64); y {
this.Id = uint64(v)
}
}
return
}
func (this *DbSyncLog) Delete(mw func(db.Result) db.Result, args ...interface{}) error {
return this.Param().SetArgs(args...).SetMiddleware(mw).Delete()
}
func (this *DbSyncLog) Count(mw func(db.Result) db.Result, args ...interface{}) (int64, error) {
return this.Param().SetArgs(args...).SetMiddleware(mw).Count()
}
func (this *DbSyncLog) Reset() *DbSyncLog {
this.Id = 0
this.SyncId = 0
this.Created = 0
this.Result = ``
this.ChangeTables = ``
this.ChangeTableNum = 0
this.Elapsed = 0
this.Failed = 0
return this
}
func (this *DbSyncLog) AsMap() map[string]interface{} {
r := map[string]interface{}{}
r["Id"] = this.Id
r["SyncId"] = this.SyncId
r["Created"] = this.Created
r["Result"] = this.Result
r["ChangeTables"] = this.ChangeTables
r["ChangeTableNum"] = this.ChangeTableNum
r["Elapsed"] = this.Elapsed
r["Failed"] = this.Failed
return r
}
func (this *DbSyncLog) AsRow() map[string]interface{} {
r := map[string]interface{}{}
r["id"] = this.Id
r["sync_id"] = this.SyncId
r["created"] = this.Created
r["result"] = this.Result
r["change_tables"] = this.ChangeTables
r["change_table_num"] = this.ChangeTableNum
r["elapsed"] = this.Elapsed
r["failed"] = this.Failed
return r
}
func (this *DbSyncLog) BatchValidate(kvset map[string]interface{}) error {
if kvset == nil {
kvset = this.AsRow()
}
return factory.BatchValidate(this.Short_(), kvset)
}
func (this *DbSyncLog) Validate(field string, value interface{}) error {
return factory.Validate(this.Short_(), field, value)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。