357 lines
9.7 KiB
Go
Executable File
Raw Permalink 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 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"
"bindbox-game/internal/repository/mysql/model"
)
func newOrderItems(db *gorm.DB, opts ...gen.DOOption) orderItems {
_orderItems := orderItems{}
_orderItems.orderItemsDo.UseDB(db, opts...)
_orderItems.orderItemsDo.UseModel(&model.OrderItems{})
tableName := _orderItems.orderItemsDo.TableName()
_orderItems.ALL = field.NewAsterisk(tableName)
_orderItems.ID = field.NewInt64(tableName, "id")
_orderItems.CreatedAt = field.NewTime(tableName, "created_at")
_orderItems.OrderID = field.NewInt64(tableName, "order_id")
_orderItems.ProductID = field.NewInt64(tableName, "product_id")
_orderItems.Title = field.NewString(tableName, "title")
_orderItems.Quantity = field.NewInt64(tableName, "quantity")
_orderItems.Price = field.NewInt64(tableName, "price")
_orderItems.TotalAmount = field.NewInt64(tableName, "total_amount")
_orderItems.ProductImages = field.NewString(tableName, "product_images")
_orderItems.Status = field.NewInt32(tableName, "status")
_orderItems.fillFieldMap()
return _orderItems
}
// orderItems 订单明细
type orderItems struct {
orderItemsDo
ALL field.Asterisk
ID field.Int64 // 主键ID
CreatedAt field.Time // 创建时间
OrderID field.Int64 // 订单IDorders.id
ProductID field.Int64 // 商品IDproducts.id
Title field.String // 商品标题快照
Quantity field.Int64 // 购买数量
Price field.Int64 // 成交单价(分)
TotalAmount field.Int64 // 行应付总额(分)
ProductImages field.String // 商品图片快照JSON
Status field.Int32 // 行状态1正常 2取消
fieldMap map[string]field.Expr
}
func (o orderItems) Table(newTableName string) *orderItems {
o.orderItemsDo.UseTable(newTableName)
return o.updateTableName(newTableName)
}
func (o orderItems) As(alias string) *orderItems {
o.orderItemsDo.DO = *(o.orderItemsDo.As(alias).(*gen.DO))
return o.updateTableName(alias)
}
func (o *orderItems) updateTableName(table string) *orderItems {
o.ALL = field.NewAsterisk(table)
o.ID = field.NewInt64(table, "id")
o.CreatedAt = field.NewTime(table, "created_at")
o.OrderID = field.NewInt64(table, "order_id")
o.ProductID = field.NewInt64(table, "product_id")
o.Title = field.NewString(table, "title")
o.Quantity = field.NewInt64(table, "quantity")
o.Price = field.NewInt64(table, "price")
o.TotalAmount = field.NewInt64(table, "total_amount")
o.ProductImages = field.NewString(table, "product_images")
o.Status = field.NewInt32(table, "status")
o.fillFieldMap()
return o
}
func (o *orderItems) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := o.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (o *orderItems) fillFieldMap() {
o.fieldMap = make(map[string]field.Expr, 10)
o.fieldMap["id"] = o.ID
o.fieldMap["created_at"] = o.CreatedAt
o.fieldMap["order_id"] = o.OrderID
o.fieldMap["product_id"] = o.ProductID
o.fieldMap["title"] = o.Title
o.fieldMap["quantity"] = o.Quantity
o.fieldMap["price"] = o.Price
o.fieldMap["total_amount"] = o.TotalAmount
o.fieldMap["product_images"] = o.ProductImages
o.fieldMap["status"] = o.Status
}
func (o orderItems) clone(db *gorm.DB) orderItems {
o.orderItemsDo.ReplaceConnPool(db.Statement.ConnPool)
return o
}
func (o orderItems) replaceDB(db *gorm.DB) orderItems {
o.orderItemsDo.ReplaceDB(db)
return o
}
type orderItemsDo struct{ gen.DO }
func (o orderItemsDo) Debug() *orderItemsDo {
return o.withDO(o.DO.Debug())
}
func (o orderItemsDo) WithContext(ctx context.Context) *orderItemsDo {
return o.withDO(o.DO.WithContext(ctx))
}
func (o orderItemsDo) ReadDB() *orderItemsDo {
return o.Clauses(dbresolver.Read)
}
func (o orderItemsDo) WriteDB() *orderItemsDo {
return o.Clauses(dbresolver.Write)
}
func (o orderItemsDo) Session(config *gorm.Session) *orderItemsDo {
return o.withDO(o.DO.Session(config))
}
func (o orderItemsDo) Clauses(conds ...clause.Expression) *orderItemsDo {
return o.withDO(o.DO.Clauses(conds...))
}
func (o orderItemsDo) Returning(value interface{}, columns ...string) *orderItemsDo {
return o.withDO(o.DO.Returning(value, columns...))
}
func (o orderItemsDo) Not(conds ...gen.Condition) *orderItemsDo {
return o.withDO(o.DO.Not(conds...))
}
func (o orderItemsDo) Or(conds ...gen.Condition) *orderItemsDo {
return o.withDO(o.DO.Or(conds...))
}
func (o orderItemsDo) Select(conds ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.Select(conds...))
}
func (o orderItemsDo) Where(conds ...gen.Condition) *orderItemsDo {
return o.withDO(o.DO.Where(conds...))
}
func (o orderItemsDo) Order(conds ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.Order(conds...))
}
func (o orderItemsDo) Distinct(cols ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.Distinct(cols...))
}
func (o orderItemsDo) Omit(cols ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.Omit(cols...))
}
func (o orderItemsDo) Join(table schema.Tabler, on ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.Join(table, on...))
}
func (o orderItemsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.LeftJoin(table, on...))
}
func (o orderItemsDo) RightJoin(table schema.Tabler, on ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.RightJoin(table, on...))
}
func (o orderItemsDo) Group(cols ...field.Expr) *orderItemsDo {
return o.withDO(o.DO.Group(cols...))
}
func (o orderItemsDo) Having(conds ...gen.Condition) *orderItemsDo {
return o.withDO(o.DO.Having(conds...))
}
func (o orderItemsDo) Limit(limit int) *orderItemsDo {
return o.withDO(o.DO.Limit(limit))
}
func (o orderItemsDo) Offset(offset int) *orderItemsDo {
return o.withDO(o.DO.Offset(offset))
}
func (o orderItemsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *orderItemsDo {
return o.withDO(o.DO.Scopes(funcs...))
}
func (o orderItemsDo) Unscoped() *orderItemsDo {
return o.withDO(o.DO.Unscoped())
}
func (o orderItemsDo) Create(values ...*model.OrderItems) error {
if len(values) == 0 {
return nil
}
return o.DO.Create(values)
}
func (o orderItemsDo) CreateInBatches(values []*model.OrderItems, batchSize int) error {
return o.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 (o orderItemsDo) Save(values ...*model.OrderItems) error {
if len(values) == 0 {
return nil
}
return o.DO.Save(values)
}
func (o orderItemsDo) First() (*model.OrderItems, error) {
if result, err := o.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.OrderItems), nil
}
}
func (o orderItemsDo) Take() (*model.OrderItems, error) {
if result, err := o.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.OrderItems), nil
}
}
func (o orderItemsDo) Last() (*model.OrderItems, error) {
if result, err := o.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.OrderItems), nil
}
}
func (o orderItemsDo) Find() ([]*model.OrderItems, error) {
result, err := o.DO.Find()
return result.([]*model.OrderItems), err
}
func (o orderItemsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.OrderItems, err error) {
buf := make([]*model.OrderItems, 0, batchSize)
err = o.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 (o orderItemsDo) FindInBatches(result *[]*model.OrderItems, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return o.DO.FindInBatches(result, batchSize, fc)
}
func (o orderItemsDo) Attrs(attrs ...field.AssignExpr) *orderItemsDo {
return o.withDO(o.DO.Attrs(attrs...))
}
func (o orderItemsDo) Assign(attrs ...field.AssignExpr) *orderItemsDo {
return o.withDO(o.DO.Assign(attrs...))
}
func (o orderItemsDo) Joins(fields ...field.RelationField) *orderItemsDo {
for _, _f := range fields {
o = *o.withDO(o.DO.Joins(_f))
}
return &o
}
func (o orderItemsDo) Preload(fields ...field.RelationField) *orderItemsDo {
for _, _f := range fields {
o = *o.withDO(o.DO.Preload(_f))
}
return &o
}
func (o orderItemsDo) FirstOrInit() (*model.OrderItems, error) {
if result, err := o.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.OrderItems), nil
}
}
func (o orderItemsDo) FirstOrCreate() (*model.OrderItems, error) {
if result, err := o.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.OrderItems), nil
}
}
func (o orderItemsDo) FindByPage(offset int, limit int) (result []*model.OrderItems, count int64, err error) {
result, err = o.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 = o.Offset(-1).Limit(-1).Count()
return
}
func (o orderItemsDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = o.Count()
if err != nil {
return
}
err = o.Offset(offset).Limit(limit).Scan(result)
return
}
func (o orderItemsDo) Scan(result interface{}) (err error) {
return o.DO.Scan(result)
}
func (o orderItemsDo) Delete(models ...*model.OrderItems) (result gen.ResultInfo, err error) {
return o.DO.Delete(models)
}
func (o *orderItemsDo) withDO(do gen.Dao) *orderItemsDo {
o.DO = *do.(*gen.DO)
return o
}