Files
servicebase/pkg/repo/trade_commodity.gen.go
2025-11-19 14:24:13 +08:00

446 lines
14 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"gitea.ddegame.cn/open/servicebase/pkg/model"
)
func newTradeCommodity(db *gorm.DB, opts ...gen.DOOption) tradeCommodity {
_tradeCommodity := tradeCommodity{}
_tradeCommodity.tradeCommodityDo.UseDB(db, opts...)
_tradeCommodity.tradeCommodityDo.UseModel(&model.TradeCommodity{})
tableName := _tradeCommodity.tradeCommodityDo.TableName()
_tradeCommodity.ALL = field.NewAsterisk(tableName)
_tradeCommodity.ID = field.NewString(tableName, "id")
_tradeCommodity.CommodityType = field.NewString(tableName, "commodity_type")
_tradeCommodity.UserID = field.NewString(tableName, "user_id")
_tradeCommodity.CommodityID = field.NewString(tableName, "commodity_id")
_tradeCommodity.Desc = field.NewString(tableName, "desc")
_tradeCommodity.Price = field.NewInt32(tableName, "price")
_tradeCommodity.Icon = field.NewString(tableName, "icon")
_tradeCommodity.Logo = field.NewString(tableName, "logo")
_tradeCommodity.State = field.NewInt32(tableName, "state")
_tradeCommodity.DeleteAt = field.NewField(tableName, "delete_at")
_tradeCommodity.CreateAt = field.NewTime(tableName, "create_at")
_tradeCommodity.CreateBy = field.NewString(tableName, "create_by")
_tradeCommodity.UpdateAt = field.NewTime(tableName, "update_at")
_tradeCommodity.UpdateBy = field.NewString(tableName, "update_by")
_tradeCommodity.fillFieldMap()
return _tradeCommodity
}
// tradeCommodity 交易的商品
type tradeCommodity struct {
tradeCommodityDo tradeCommodityDo
ALL field.Asterisk
ID field.String // 业务ID
CommodityType field.String // GAME_ROLE=游戏角色
UserID field.String // 用户ID
CommodityID field.String // 如游戏角色IDuser_game_role的ID
Desc field.String // 描述
Price field.Int32 // 价格,单位为分
Icon field.String // 图标
Logo field.String // logo
State field.Int32 // 状态1=启用 2=禁用
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (t tradeCommodity) Table(newTableName string) *tradeCommodity {
t.tradeCommodityDo.UseTable(newTableName)
return t.updateTableName(newTableName)
}
func (t tradeCommodity) As(alias string) *tradeCommodity {
t.tradeCommodityDo.DO = *(t.tradeCommodityDo.As(alias).(*gen.DO))
return t.updateTableName(alias)
}
func (t *tradeCommodity) updateTableName(table string) *tradeCommodity {
t.ALL = field.NewAsterisk(table)
t.ID = field.NewString(table, "id")
t.CommodityType = field.NewString(table, "commodity_type")
t.UserID = field.NewString(table, "user_id")
t.CommodityID = field.NewString(table, "commodity_id")
t.Desc = field.NewString(table, "desc")
t.Price = field.NewInt32(table, "price")
t.Icon = field.NewString(table, "icon")
t.Logo = field.NewString(table, "logo")
t.State = field.NewInt32(table, "state")
t.DeleteAt = field.NewField(table, "delete_at")
t.CreateAt = field.NewTime(table, "create_at")
t.CreateBy = field.NewString(table, "create_by")
t.UpdateAt = field.NewTime(table, "update_at")
t.UpdateBy = field.NewString(table, "update_by")
t.fillFieldMap()
return t
}
func (t *tradeCommodity) WithContext(ctx context.Context) ITradeCommodityDo {
return t.tradeCommodityDo.WithContext(ctx)
}
func (t tradeCommodity) TableName() string { return t.tradeCommodityDo.TableName() }
func (t tradeCommodity) Alias() string { return t.tradeCommodityDo.Alias() }
func (t tradeCommodity) Columns(cols ...field.Expr) gen.Columns {
return t.tradeCommodityDo.Columns(cols...)
}
func (t *tradeCommodity) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := t.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (t *tradeCommodity) fillFieldMap() {
t.fieldMap = make(map[string]field.Expr, 14)
t.fieldMap["id"] = t.ID
t.fieldMap["commodity_type"] = t.CommodityType
t.fieldMap["user_id"] = t.UserID
t.fieldMap["commodity_id"] = t.CommodityID
t.fieldMap["desc"] = t.Desc
t.fieldMap["price"] = t.Price
t.fieldMap["icon"] = t.Icon
t.fieldMap["logo"] = t.Logo
t.fieldMap["state"] = t.State
t.fieldMap["delete_at"] = t.DeleteAt
t.fieldMap["create_at"] = t.CreateAt
t.fieldMap["create_by"] = t.CreateBy
t.fieldMap["update_at"] = t.UpdateAt
t.fieldMap["update_by"] = t.UpdateBy
}
func (t tradeCommodity) clone(db *gorm.DB) tradeCommodity {
t.tradeCommodityDo.ReplaceConnPool(db.Statement.ConnPool)
return t
}
func (t tradeCommodity) replaceDB(db *gorm.DB) tradeCommodity {
t.tradeCommodityDo.ReplaceDB(db)
return t
}
type tradeCommodityDo struct{ gen.DO }
type ITradeCommodityDo interface {
gen.SubQuery
Debug() ITradeCommodityDo
WithContext(ctx context.Context) ITradeCommodityDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() ITradeCommodityDo
WriteDB() ITradeCommodityDo
As(alias string) gen.Dao
Session(config *gorm.Session) ITradeCommodityDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) ITradeCommodityDo
Not(conds ...gen.Condition) ITradeCommodityDo
Or(conds ...gen.Condition) ITradeCommodityDo
Select(conds ...field.Expr) ITradeCommodityDo
Where(conds ...gen.Condition) ITradeCommodityDo
Order(conds ...field.Expr) ITradeCommodityDo
Distinct(cols ...field.Expr) ITradeCommodityDo
Omit(cols ...field.Expr) ITradeCommodityDo
Join(table schema.Tabler, on ...field.Expr) ITradeCommodityDo
LeftJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo
RightJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo
Group(cols ...field.Expr) ITradeCommodityDo
Having(conds ...gen.Condition) ITradeCommodityDo
Limit(limit int) ITradeCommodityDo
Offset(offset int) ITradeCommodityDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) ITradeCommodityDo
Unscoped() ITradeCommodityDo
Create(values ...*model.TradeCommodity) error
CreateInBatches(values []*model.TradeCommodity, batchSize int) error
Save(values ...*model.TradeCommodity) error
First() (*model.TradeCommodity, error)
Take() (*model.TradeCommodity, error)
Last() (*model.TradeCommodity, error)
Find() ([]*model.TradeCommodity, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TradeCommodity, err error)
FindInBatches(result *[]*model.TradeCommodity, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest any) error
Delete(...*model.TradeCommodity) (info gen.ResultInfo, err error)
Update(column field.Expr, value any) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value any) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value any) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value any) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) ITradeCommodityDo
Assign(attrs ...field.AssignExpr) ITradeCommodityDo
Joins(fields ...field.RelationField) ITradeCommodityDo
Preload(fields ...field.RelationField) ITradeCommodityDo
FirstOrInit() (*model.TradeCommodity, error)
FirstOrCreate() (*model.TradeCommodity, error)
FindByPage(offset int, limit int) (result []*model.TradeCommodity, count int64, err error)
ScanByPage(result any, offset int, limit int) (count int64, err error)
Scan(result any) (err error)
Returning(value any, columns ...string) ITradeCommodityDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (t tradeCommodityDo) Debug() ITradeCommodityDo {
return t.withDO(t.DO.Debug())
}
func (t tradeCommodityDo) WithContext(ctx context.Context) ITradeCommodityDo {
return t.withDO(t.DO.WithContext(ctx))
}
func (t tradeCommodityDo) ReadDB() ITradeCommodityDo {
return t.Clauses(dbresolver.Read)
}
func (t tradeCommodityDo) WriteDB() ITradeCommodityDo {
return t.Clauses(dbresolver.Write)
}
func (t tradeCommodityDo) Session(config *gorm.Session) ITradeCommodityDo {
return t.withDO(t.DO.Session(config))
}
func (t tradeCommodityDo) Clauses(conds ...clause.Expression) ITradeCommodityDo {
return t.withDO(t.DO.Clauses(conds...))
}
func (t tradeCommodityDo) Returning(value any, columns ...string) ITradeCommodityDo {
return t.withDO(t.DO.Returning(value, columns...))
}
func (t tradeCommodityDo) Not(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Not(conds...))
}
func (t tradeCommodityDo) Or(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Or(conds...))
}
func (t tradeCommodityDo) Select(conds ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Select(conds...))
}
func (t tradeCommodityDo) Where(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Where(conds...))
}
func (t tradeCommodityDo) Order(conds ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Order(conds...))
}
func (t tradeCommodityDo) Distinct(cols ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Distinct(cols...))
}
func (t tradeCommodityDo) Omit(cols ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Omit(cols...))
}
func (t tradeCommodityDo) Join(table schema.Tabler, on ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Join(table, on...))
}
func (t tradeCommodityDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.LeftJoin(table, on...))
}
func (t tradeCommodityDo) RightJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.RightJoin(table, on...))
}
func (t tradeCommodityDo) Group(cols ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Group(cols...))
}
func (t tradeCommodityDo) Having(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Having(conds...))
}
func (t tradeCommodityDo) Limit(limit int) ITradeCommodityDo {
return t.withDO(t.DO.Limit(limit))
}
func (t tradeCommodityDo) Offset(offset int) ITradeCommodityDo {
return t.withDO(t.DO.Offset(offset))
}
func (t tradeCommodityDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITradeCommodityDo {
return t.withDO(t.DO.Scopes(funcs...))
}
func (t tradeCommodityDo) Unscoped() ITradeCommodityDo {
return t.withDO(t.DO.Unscoped())
}
func (t tradeCommodityDo) Create(values ...*model.TradeCommodity) error {
if len(values) == 0 {
return nil
}
return t.DO.Create(values)
}
func (t tradeCommodityDo) CreateInBatches(values []*model.TradeCommodity, batchSize int) error {
return t.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 (t tradeCommodityDo) Save(values ...*model.TradeCommodity) error {
if len(values) == 0 {
return nil
}
return t.DO.Save(values)
}
func (t tradeCommodityDo) First() (*model.TradeCommodity, error) {
if result, err := t.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) Take() (*model.TradeCommodity, error) {
if result, err := t.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) Last() (*model.TradeCommodity, error) {
if result, err := t.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) Find() ([]*model.TradeCommodity, error) {
result, err := t.DO.Find()
return result.([]*model.TradeCommodity), err
}
func (t tradeCommodityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TradeCommodity, err error) {
buf := make([]*model.TradeCommodity, 0, batchSize)
err = t.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 (t tradeCommodityDo) FindInBatches(result *[]*model.TradeCommodity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return t.DO.FindInBatches(result, batchSize, fc)
}
func (t tradeCommodityDo) Attrs(attrs ...field.AssignExpr) ITradeCommodityDo {
return t.withDO(t.DO.Attrs(attrs...))
}
func (t tradeCommodityDo) Assign(attrs ...field.AssignExpr) ITradeCommodityDo {
return t.withDO(t.DO.Assign(attrs...))
}
func (t tradeCommodityDo) Joins(fields ...field.RelationField) ITradeCommodityDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Joins(_f))
}
return &t
}
func (t tradeCommodityDo) Preload(fields ...field.RelationField) ITradeCommodityDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Preload(_f))
}
return &t
}
func (t tradeCommodityDo) FirstOrInit() (*model.TradeCommodity, error) {
if result, err := t.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) FirstOrCreate() (*model.TradeCommodity, error) {
if result, err := t.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) FindByPage(offset int, limit int) (result []*model.TradeCommodity, count int64, err error) {
result, err = t.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 = t.Offset(-1).Limit(-1).Count()
return
}
func (t tradeCommodityDo) ScanByPage(result any, offset int, limit int) (count int64, err error) {
count, err = t.Count()
if err != nil {
return
}
err = t.Offset(offset).Limit(limit).Scan(result)
return
}
func (t tradeCommodityDo) Scan(result any) (err error) {
return t.DO.Scan(result)
}
func (t tradeCommodityDo) Delete(models ...*model.TradeCommodity) (result gen.ResultInfo, err error) {
return t.DO.Delete(models)
}
func (t *tradeCommodityDo) withDO(do gen.Dao) *tradeCommodityDo {
t.DO = *do.(*gen.DO)
return t
}