123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- // 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"
- "gadmin/internal/gorm/model"
- )
- func newExpeditionLog(db *gorm.DB, opts ...gen.DOOption) expeditionLog {
- _expeditionLog := expeditionLog{}
- _expeditionLog.expeditionLogDo.UseDB(db, opts...)
- _expeditionLog.expeditionLogDo.UseModel(&model.ExpeditionLog{})
- tableName := _expeditionLog.expeditionLogDo.TableName()
- _expeditionLog.ALL = field.NewAsterisk(tableName)
- _expeditionLog.ID = field.NewInt64(tableName, "id")
- _expeditionLog.UserID = field.NewInt64(tableName, "user_id")
- _expeditionLog.ServerID = field.NewInt32(tableName, "server_id")
- _expeditionLog.EventID = field.NewInt32(tableName, "event_id")
- _expeditionLog.Floor = field.NewInt32(tableName, "floor")
- _expeditionLog.Goods = field.NewString(tableName, "goods")
- _expeditionLog.CostType = field.NewInt32(tableName, "cost_type")
- _expeditionLog.Date = field.NewString(tableName, "date")
- _expeditionLog.EventAt = field.NewInt32(tableName, "event_at")
- _expeditionLog.EventAtNs = field.NewInt64(tableName, "event_at_ns")
- _expeditionLog.fillFieldMap()
- return _expeditionLog
- }
- type expeditionLog struct {
- expeditionLogDo
- ALL field.Asterisk
- ID field.Int64
- UserID field.Int64 // 用户id
- ServerID field.Int32 // 服务器ID
- EventID field.Int32 // 事件ID
- Floor field.Int32 // 关卡ID
- Goods field.String // {id,count}—{物品id,物品数量}
- CostType field.Int32 // 1看广告 2 钻石 3人民币
- Date field.String // 触发日期 2005-01-02
- EventAt field.Int32 // 触发时间戳
- EventAtNs field.Int64 // 发生时间ns
- fieldMap map[string]field.Expr
- }
- func (e expeditionLog) Table(newTableName string) *expeditionLog {
- e.expeditionLogDo.UseTable(newTableName)
- return e.updateTableName(newTableName)
- }
- func (e expeditionLog) As(alias string) *expeditionLog {
- e.expeditionLogDo.DO = *(e.expeditionLogDo.As(alias).(*gen.DO))
- return e.updateTableName(alias)
- }
- func (e *expeditionLog) updateTableName(table string) *expeditionLog {
- e.ALL = field.NewAsterisk(table)
- e.ID = field.NewInt64(table, "id")
- e.UserID = field.NewInt64(table, "user_id")
- e.ServerID = field.NewInt32(table, "server_id")
- e.EventID = field.NewInt32(table, "event_id")
- e.Floor = field.NewInt32(table, "floor")
- e.Goods = field.NewString(table, "goods")
- e.CostType = field.NewInt32(table, "cost_type")
- e.Date = field.NewString(table, "date")
- e.EventAt = field.NewInt32(table, "event_at")
- e.EventAtNs = field.NewInt64(table, "event_at_ns")
- e.fillFieldMap()
- return e
- }
- func (e *expeditionLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := e.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (e *expeditionLog) fillFieldMap() {
- e.fieldMap = make(map[string]field.Expr, 10)
- e.fieldMap["id"] = e.ID
- e.fieldMap["user_id"] = e.UserID
- e.fieldMap["server_id"] = e.ServerID
- e.fieldMap["event_id"] = e.EventID
- e.fieldMap["floor"] = e.Floor
- e.fieldMap["goods"] = e.Goods
- e.fieldMap["cost_type"] = e.CostType
- e.fieldMap["date"] = e.Date
- e.fieldMap["event_at"] = e.EventAt
- e.fieldMap["event_at_ns"] = e.EventAtNs
- }
- func (e expeditionLog) clone(db *gorm.DB) expeditionLog {
- e.expeditionLogDo.ReplaceConnPool(db.Statement.ConnPool)
- return e
- }
- func (e expeditionLog) replaceDB(db *gorm.DB) expeditionLog {
- e.expeditionLogDo.ReplaceDB(db)
- return e
- }
- type expeditionLogDo struct{ gen.DO }
- func (e expeditionLogDo) Debug() *expeditionLogDo {
- return e.withDO(e.DO.Debug())
- }
- func (e expeditionLogDo) WithContext(ctx context.Context) *expeditionLogDo {
- return e.withDO(e.DO.WithContext(ctx))
- }
- func (e expeditionLogDo) ReadDB() *expeditionLogDo {
- return e.Clauses(dbresolver.Read)
- }
- func (e expeditionLogDo) WriteDB() *expeditionLogDo {
- return e.Clauses(dbresolver.Write)
- }
- func (e expeditionLogDo) Session(config *gorm.Session) *expeditionLogDo {
- return e.withDO(e.DO.Session(config))
- }
- func (e expeditionLogDo) Clauses(conds ...clause.Expression) *expeditionLogDo {
- return e.withDO(e.DO.Clauses(conds...))
- }
- func (e expeditionLogDo) Returning(value interface{}, columns ...string) *expeditionLogDo {
- return e.withDO(e.DO.Returning(value, columns...))
- }
- func (e expeditionLogDo) Not(conds ...gen.Condition) *expeditionLogDo {
- return e.withDO(e.DO.Not(conds...))
- }
- func (e expeditionLogDo) Or(conds ...gen.Condition) *expeditionLogDo {
- return e.withDO(e.DO.Or(conds...))
- }
- func (e expeditionLogDo) Select(conds ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.Select(conds...))
- }
- func (e expeditionLogDo) Where(conds ...gen.Condition) *expeditionLogDo {
- return e.withDO(e.DO.Where(conds...))
- }
- func (e expeditionLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *expeditionLogDo {
- return e.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (e expeditionLogDo) Order(conds ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.Order(conds...))
- }
- func (e expeditionLogDo) Distinct(cols ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.Distinct(cols...))
- }
- func (e expeditionLogDo) Omit(cols ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.Omit(cols...))
- }
- func (e expeditionLogDo) Join(table schema.Tabler, on ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.Join(table, on...))
- }
- func (e expeditionLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.LeftJoin(table, on...))
- }
- func (e expeditionLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.RightJoin(table, on...))
- }
- func (e expeditionLogDo) Group(cols ...field.Expr) *expeditionLogDo {
- return e.withDO(e.DO.Group(cols...))
- }
- func (e expeditionLogDo) Having(conds ...gen.Condition) *expeditionLogDo {
- return e.withDO(e.DO.Having(conds...))
- }
- func (e expeditionLogDo) Limit(limit int) *expeditionLogDo {
- return e.withDO(e.DO.Limit(limit))
- }
- func (e expeditionLogDo) Offset(offset int) *expeditionLogDo {
- return e.withDO(e.DO.Offset(offset))
- }
- func (e expeditionLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *expeditionLogDo {
- return e.withDO(e.DO.Scopes(funcs...))
- }
- func (e expeditionLogDo) Unscoped() *expeditionLogDo {
- return e.withDO(e.DO.Unscoped())
- }
- func (e expeditionLogDo) Create(values ...*model.ExpeditionLog) error {
- if len(values) == 0 {
- return nil
- }
- return e.DO.Create(values)
- }
- func (e expeditionLogDo) CreateInBatches(values []*model.ExpeditionLog, batchSize int) error {
- return e.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 (e expeditionLogDo) Save(values ...*model.ExpeditionLog) error {
- if len(values) == 0 {
- return nil
- }
- return e.DO.Save(values)
- }
- func (e expeditionLogDo) First() (*model.ExpeditionLog, error) {
- if result, err := e.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.ExpeditionLog), nil
- }
- }
- func (e expeditionLogDo) Take() (*model.ExpeditionLog, error) {
- if result, err := e.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.ExpeditionLog), nil
- }
- }
- func (e expeditionLogDo) Last() (*model.ExpeditionLog, error) {
- if result, err := e.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.ExpeditionLog), nil
- }
- }
- func (e expeditionLogDo) Find() ([]*model.ExpeditionLog, error) {
- result, err := e.DO.Find()
- return result.([]*model.ExpeditionLog), err
- }
- func (e expeditionLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExpeditionLog, err error) {
- buf := make([]*model.ExpeditionLog, 0, batchSize)
- err = e.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 (e expeditionLogDo) FindInBatches(result *[]*model.ExpeditionLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return e.DO.FindInBatches(result, batchSize, fc)
- }
- func (e expeditionLogDo) Attrs(attrs ...field.AssignExpr) *expeditionLogDo {
- return e.withDO(e.DO.Attrs(attrs...))
- }
- func (e expeditionLogDo) Assign(attrs ...field.AssignExpr) *expeditionLogDo {
- return e.withDO(e.DO.Assign(attrs...))
- }
- func (e expeditionLogDo) Joins(fields ...field.RelationField) *expeditionLogDo {
- for _, _f := range fields {
- e = *e.withDO(e.DO.Joins(_f))
- }
- return &e
- }
- func (e expeditionLogDo) Preload(fields ...field.RelationField) *expeditionLogDo {
- for _, _f := range fields {
- e = *e.withDO(e.DO.Preload(_f))
- }
- return &e
- }
- func (e expeditionLogDo) FirstOrInit() (*model.ExpeditionLog, error) {
- if result, err := e.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.ExpeditionLog), nil
- }
- }
- func (e expeditionLogDo) FirstOrCreate() (*model.ExpeditionLog, error) {
- if result, err := e.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.ExpeditionLog), nil
- }
- }
- func (e expeditionLogDo) FindByPage(offset int, limit int) (result []*model.ExpeditionLog, count int64, err error) {
- result, err = e.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 = e.Offset(-1).Limit(-1).Count()
- return
- }
- func (e expeditionLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = e.Count()
- if err != nil {
- return
- }
- err = e.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (e expeditionLogDo) Scan(result interface{}) (err error) {
- return e.DO.Scan(result)
- }
- func (e expeditionLogDo) Delete(models ...*model.ExpeditionLog) (result gen.ResultInfo, err error) {
- return e.DO.Delete(models)
- }
- func (e *expeditionLogDo) withDO(do gen.Dao) *expeditionLogDo {
- e.DO = *do.(*gen.DO)
- return e
- }
|