572 lines
16 KiB
Go
572 lines
16 KiB
Go
|
// 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"
|
||
|
|
||
|
"leafdev.top/Leaf/api-platform/internal/entity"
|
||
|
)
|
||
|
|
||
|
func newOrderItem(db *gorm.DB, opts ...gen.DOOption) orderItem {
|
||
|
_orderItem := orderItem{}
|
||
|
|
||
|
_orderItem.orderItemDo.UseDB(db, opts...)
|
||
|
_orderItem.orderItemDo.UseModel(&entity.OrderItem{})
|
||
|
|
||
|
tableName := _orderItem.orderItemDo.TableName()
|
||
|
_orderItem.ALL = field.NewAsterisk(tableName)
|
||
|
_orderItem.Id = field.NewUint(tableName, "id")
|
||
|
_orderItem.CreatedAt = field.NewTime(tableName, "created_at")
|
||
|
_orderItem.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||
|
_orderItem.OrderId = field.NewUint(tableName, "order_id")
|
||
|
_orderItem.PackageId = field.NewUint(tableName, "package_id")
|
||
|
_orderItem.Order = orderItemBelongsToOrder{
|
||
|
db: db.Session(&gorm.Session{}),
|
||
|
|
||
|
RelationField: field.NewRelation("Order", "entity.Order"),
|
||
|
PromoCode: struct {
|
||
|
field.RelationField
|
||
|
}{
|
||
|
RelationField: field.NewRelation("Order.PromoCode", "entity.PromoCode"),
|
||
|
},
|
||
|
}
|
||
|
|
||
|
_orderItem.Package = orderItemBelongsToPackage{
|
||
|
db: db.Session(&gorm.Session{}),
|
||
|
|
||
|
RelationField: field.NewRelation("Package", "entity.Packages"),
|
||
|
Api: struct {
|
||
|
field.RelationField
|
||
|
}{
|
||
|
RelationField: field.NewRelation("Package.Api", "entity.Api"),
|
||
|
},
|
||
|
}
|
||
|
|
||
|
_orderItem.fillFieldMap()
|
||
|
|
||
|
return _orderItem
|
||
|
}
|
||
|
|
||
|
type orderItem struct {
|
||
|
orderItemDo
|
||
|
|
||
|
ALL field.Asterisk
|
||
|
Id field.Uint
|
||
|
CreatedAt field.Time
|
||
|
UpdatedAt field.Time
|
||
|
OrderId field.Uint
|
||
|
PackageId field.Uint
|
||
|
Order orderItemBelongsToOrder
|
||
|
|
||
|
Package orderItemBelongsToPackage
|
||
|
|
||
|
fieldMap map[string]field.Expr
|
||
|
}
|
||
|
|
||
|
func (o orderItem) Table(newTableName string) *orderItem {
|
||
|
o.orderItemDo.UseTable(newTableName)
|
||
|
return o.updateTableName(newTableName)
|
||
|
}
|
||
|
|
||
|
func (o orderItem) As(alias string) *orderItem {
|
||
|
o.orderItemDo.DO = *(o.orderItemDo.As(alias).(*gen.DO))
|
||
|
return o.updateTableName(alias)
|
||
|
}
|
||
|
|
||
|
func (o *orderItem) updateTableName(table string) *orderItem {
|
||
|
o.ALL = field.NewAsterisk(table)
|
||
|
o.Id = field.NewUint(table, "id")
|
||
|
o.CreatedAt = field.NewTime(table, "created_at")
|
||
|
o.UpdatedAt = field.NewTime(table, "updated_at")
|
||
|
o.OrderId = field.NewUint(table, "order_id")
|
||
|
o.PackageId = field.NewUint(table, "package_id")
|
||
|
|
||
|
o.fillFieldMap()
|
||
|
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
func (o *orderItem) 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 *orderItem) fillFieldMap() {
|
||
|
o.fieldMap = make(map[string]field.Expr, 7)
|
||
|
o.fieldMap["id"] = o.Id
|
||
|
o.fieldMap["created_at"] = o.CreatedAt
|
||
|
o.fieldMap["updated_at"] = o.UpdatedAt
|
||
|
o.fieldMap["order_id"] = o.OrderId
|
||
|
o.fieldMap["package_id"] = o.PackageId
|
||
|
|
||
|
}
|
||
|
|
||
|
func (o orderItem) clone(db *gorm.DB) orderItem {
|
||
|
o.orderItemDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
func (o orderItem) replaceDB(db *gorm.DB) orderItem {
|
||
|
o.orderItemDo.ReplaceDB(db)
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
type orderItemBelongsToOrder struct {
|
||
|
db *gorm.DB
|
||
|
|
||
|
field.RelationField
|
||
|
|
||
|
PromoCode struct {
|
||
|
field.RelationField
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrder) Where(conds ...field.Expr) *orderItemBelongsToOrder {
|
||
|
if len(conds) == 0 {
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
exprs := make([]clause.Expression, 0, len(conds))
|
||
|
for _, cond := range conds {
|
||
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||
|
}
|
||
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrder) WithContext(ctx context.Context) *orderItemBelongsToOrder {
|
||
|
a.db = a.db.WithContext(ctx)
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrder) Session(session *gorm.Session) *orderItemBelongsToOrder {
|
||
|
a.db = a.db.Session(session)
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrder) Model(m *entity.OrderItem) *orderItemBelongsToOrderTx {
|
||
|
return &orderItemBelongsToOrderTx{a.db.Model(m).Association(a.Name())}
|
||
|
}
|
||
|
|
||
|
type orderItemBelongsToOrderTx struct{ tx *gorm.Association }
|
||
|
|
||
|
func (a orderItemBelongsToOrderTx) Find() (result *entity.Order, err error) {
|
||
|
return result, a.tx.Find(&result)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrderTx) Append(values ...*entity.Order) (err error) {
|
||
|
targetValues := make([]interface{}, len(values))
|
||
|
for i, v := range values {
|
||
|
targetValues[i] = v
|
||
|
}
|
||
|
return a.tx.Append(targetValues...)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrderTx) Replace(values ...*entity.Order) (err error) {
|
||
|
targetValues := make([]interface{}, len(values))
|
||
|
for i, v := range values {
|
||
|
targetValues[i] = v
|
||
|
}
|
||
|
return a.tx.Replace(targetValues...)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrderTx) Delete(values ...*entity.Order) (err error) {
|
||
|
targetValues := make([]interface{}, len(values))
|
||
|
for i, v := range values {
|
||
|
targetValues[i] = v
|
||
|
}
|
||
|
return a.tx.Delete(targetValues...)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrderTx) Clear() error {
|
||
|
return a.tx.Clear()
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToOrderTx) Count() int64 {
|
||
|
return a.tx.Count()
|
||
|
}
|
||
|
|
||
|
type orderItemBelongsToPackage struct {
|
||
|
db *gorm.DB
|
||
|
|
||
|
field.RelationField
|
||
|
|
||
|
Api struct {
|
||
|
field.RelationField
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackage) Where(conds ...field.Expr) *orderItemBelongsToPackage {
|
||
|
if len(conds) == 0 {
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
exprs := make([]clause.Expression, 0, len(conds))
|
||
|
for _, cond := range conds {
|
||
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||
|
}
|
||
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackage) WithContext(ctx context.Context) *orderItemBelongsToPackage {
|
||
|
a.db = a.db.WithContext(ctx)
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackage) Session(session *gorm.Session) *orderItemBelongsToPackage {
|
||
|
a.db = a.db.Session(session)
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackage) Model(m *entity.OrderItem) *orderItemBelongsToPackageTx {
|
||
|
return &orderItemBelongsToPackageTx{a.db.Model(m).Association(a.Name())}
|
||
|
}
|
||
|
|
||
|
type orderItemBelongsToPackageTx struct{ tx *gorm.Association }
|
||
|
|
||
|
func (a orderItemBelongsToPackageTx) Find() (result *entity.Packages, err error) {
|
||
|
return result, a.tx.Find(&result)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackageTx) Append(values ...*entity.Packages) (err error) {
|
||
|
targetValues := make([]interface{}, len(values))
|
||
|
for i, v := range values {
|
||
|
targetValues[i] = v
|
||
|
}
|
||
|
return a.tx.Append(targetValues...)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackageTx) Replace(values ...*entity.Packages) (err error) {
|
||
|
targetValues := make([]interface{}, len(values))
|
||
|
for i, v := range values {
|
||
|
targetValues[i] = v
|
||
|
}
|
||
|
return a.tx.Replace(targetValues...)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackageTx) Delete(values ...*entity.Packages) (err error) {
|
||
|
targetValues := make([]interface{}, len(values))
|
||
|
for i, v := range values {
|
||
|
targetValues[i] = v
|
||
|
}
|
||
|
return a.tx.Delete(targetValues...)
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackageTx) Clear() error {
|
||
|
return a.tx.Clear()
|
||
|
}
|
||
|
|
||
|
func (a orderItemBelongsToPackageTx) Count() int64 {
|
||
|
return a.tx.Count()
|
||
|
}
|
||
|
|
||
|
type orderItemDo struct{ gen.DO }
|
||
|
|
||
|
type IOrderItemDo interface {
|
||
|
gen.SubQuery
|
||
|
Debug() IOrderItemDo
|
||
|
WithContext(ctx context.Context) IOrderItemDo
|
||
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||
|
ReplaceDB(db *gorm.DB)
|
||
|
ReadDB() IOrderItemDo
|
||
|
WriteDB() IOrderItemDo
|
||
|
As(alias string) gen.Dao
|
||
|
Session(config *gorm.Session) IOrderItemDo
|
||
|
Columns(cols ...field.Expr) gen.Columns
|
||
|
Clauses(conds ...clause.Expression) IOrderItemDo
|
||
|
Not(conds ...gen.Condition) IOrderItemDo
|
||
|
Or(conds ...gen.Condition) IOrderItemDo
|
||
|
Select(conds ...field.Expr) IOrderItemDo
|
||
|
Where(conds ...gen.Condition) IOrderItemDo
|
||
|
Order(conds ...field.Expr) IOrderItemDo
|
||
|
Distinct(cols ...field.Expr) IOrderItemDo
|
||
|
Omit(cols ...field.Expr) IOrderItemDo
|
||
|
Join(table schema.Tabler, on ...field.Expr) IOrderItemDo
|
||
|
LeftJoin(table schema.Tabler, on ...field.Expr) IOrderItemDo
|
||
|
RightJoin(table schema.Tabler, on ...field.Expr) IOrderItemDo
|
||
|
Group(cols ...field.Expr) IOrderItemDo
|
||
|
Having(conds ...gen.Condition) IOrderItemDo
|
||
|
Limit(limit int) IOrderItemDo
|
||
|
Offset(offset int) IOrderItemDo
|
||
|
Count() (count int64, err error)
|
||
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IOrderItemDo
|
||
|
Unscoped() IOrderItemDo
|
||
|
Create(values ...*entity.OrderItem) error
|
||
|
CreateInBatches(values []*entity.OrderItem, batchSize int) error
|
||
|
Save(values ...*entity.OrderItem) error
|
||
|
First() (*entity.OrderItem, error)
|
||
|
Take() (*entity.OrderItem, error)
|
||
|
Last() (*entity.OrderItem, error)
|
||
|
Find() ([]*entity.OrderItem, error)
|
||
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.OrderItem, err error)
|
||
|
FindInBatches(result *[]*entity.OrderItem, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||
|
Pluck(column field.Expr, dest interface{}) error
|
||
|
Delete(...*entity.OrderItem) (info gen.ResultInfo, err error)
|
||
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||
|
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||
|
UpdateFrom(q gen.SubQuery) gen.Dao
|
||
|
Attrs(attrs ...field.AssignExpr) IOrderItemDo
|
||
|
Assign(attrs ...field.AssignExpr) IOrderItemDo
|
||
|
Joins(fields ...field.RelationField) IOrderItemDo
|
||
|
Preload(fields ...field.RelationField) IOrderItemDo
|
||
|
FirstOrInit() (*entity.OrderItem, error)
|
||
|
FirstOrCreate() (*entity.OrderItem, error)
|
||
|
FindByPage(offset int, limit int) (result []*entity.OrderItem, count int64, err error)
|
||
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||
|
Scan(result interface{}) (err error)
|
||
|
Returning(value interface{}, columns ...string) IOrderItemDo
|
||
|
UnderlyingDB() *gorm.DB
|
||
|
schema.Tabler
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Debug() IOrderItemDo {
|
||
|
return o.withDO(o.DO.Debug())
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) WithContext(ctx context.Context) IOrderItemDo {
|
||
|
return o.withDO(o.DO.WithContext(ctx))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) ReadDB() IOrderItemDo {
|
||
|
return o.Clauses(dbresolver.Read)
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) WriteDB() IOrderItemDo {
|
||
|
return o.Clauses(dbresolver.Write)
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Session(config *gorm.Session) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Session(config))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Clauses(conds ...clause.Expression) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Clauses(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Returning(value interface{}, columns ...string) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Returning(value, columns...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Not(conds ...gen.Condition) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Not(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Or(conds ...gen.Condition) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Or(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Select(conds ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Select(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Where(conds ...gen.Condition) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Where(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Order(conds ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Order(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Distinct(cols ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Distinct(cols...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Omit(cols ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Omit(cols...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Join(table schema.Tabler, on ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Join(table, on...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) LeftJoin(table schema.Tabler, on ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.LeftJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) RightJoin(table schema.Tabler, on ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.RightJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Group(cols ...field.Expr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Group(cols...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Having(conds ...gen.Condition) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Having(conds...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Limit(limit int) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Limit(limit))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Offset(offset int) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Offset(offset))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Scopes(funcs...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Unscoped() IOrderItemDo {
|
||
|
return o.withDO(o.DO.Unscoped())
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Create(values ...*entity.OrderItem) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return o.DO.Create(values)
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) CreateInBatches(values []*entity.OrderItem, 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 orderItemDo) Save(values ...*entity.OrderItem) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return o.DO.Save(values)
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) First() (*entity.OrderItem, error) {
|
||
|
if result, err := o.DO.First(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*entity.OrderItem), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Take() (*entity.OrderItem, error) {
|
||
|
if result, err := o.DO.Take(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*entity.OrderItem), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Last() (*entity.OrderItem, error) {
|
||
|
if result, err := o.DO.Last(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*entity.OrderItem), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Find() ([]*entity.OrderItem, error) {
|
||
|
result, err := o.DO.Find()
|
||
|
return result.([]*entity.OrderItem), err
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.OrderItem, err error) {
|
||
|
buf := make([]*entity.OrderItem, 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 orderItemDo) FindInBatches(result *[]*entity.OrderItem, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||
|
return o.DO.FindInBatches(result, batchSize, fc)
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Attrs(attrs ...field.AssignExpr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Attrs(attrs...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Assign(attrs ...field.AssignExpr) IOrderItemDo {
|
||
|
return o.withDO(o.DO.Assign(attrs...))
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Joins(fields ...field.RelationField) IOrderItemDo {
|
||
|
for _, _f := range fields {
|
||
|
o = *o.withDO(o.DO.Joins(_f))
|
||
|
}
|
||
|
return &o
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Preload(fields ...field.RelationField) IOrderItemDo {
|
||
|
for _, _f := range fields {
|
||
|
o = *o.withDO(o.DO.Preload(_f))
|
||
|
}
|
||
|
return &o
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) FirstOrInit() (*entity.OrderItem, error) {
|
||
|
if result, err := o.DO.FirstOrInit(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*entity.OrderItem), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) FirstOrCreate() (*entity.OrderItem, error) {
|
||
|
if result, err := o.DO.FirstOrCreate(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*entity.OrderItem), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) FindByPage(offset int, limit int) (result []*entity.OrderItem, 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 orderItemDo) 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 orderItemDo) Scan(result interface{}) (err error) {
|
||
|
return o.DO.Scan(result)
|
||
|
}
|
||
|
|
||
|
func (o orderItemDo) Delete(models ...*entity.OrderItem) (result gen.ResultInfo, err error) {
|
||
|
return o.DO.Delete(models)
|
||
|
}
|
||
|
|
||
|
func (o *orderItemDo) withDO(do gen.Dao) *orderItemDo {
|
||
|
o.DO = *do.(*gen.DO)
|
||
|
return o
|
||
|
}
|