Files
platform/web/queries/bill.gen.go

926 lines
22 KiB
Go
Raw Normal View History

2025-03-18 10:13:57 +08:00
// 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 queries
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"platform/web/models"
)
func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
_bill := bill{}
_bill.billDo.UseDB(db, opts...)
_bill.billDo.UseModel(&models.Bill{})
tableName := _bill.billDo.TableName()
_bill.ALL = field.NewAsterisk(tableName)
_bill.ID = field.NewInt32(tableName, "id")
_bill.CreatedAt = field.NewTime(tableName, "created_at")
_bill.UpdatedAt = field.NewTime(tableName, "updated_at")
_bill.DeletedAt = field.NewField(tableName, "deleted_at")
2025-03-18 10:13:57 +08:00
_bill.UserID = field.NewInt32(tableName, "user_id")
_bill.TradeID = field.NewInt32(tableName, "trade_id")
_bill.ResourceID = field.NewInt32(tableName, "resource_id")
_bill.RefundID = field.NewInt32(tableName, "refund_id")
_bill.CouponID = field.NewInt32(tableName, "coupon_id")
_bill.BillNo = field.NewString(tableName, "bill_no")
_bill.Info = field.NewString(tableName, "info")
_bill.Type = field.NewInt(tableName, "type")
_bill.Amount = field.NewField(tableName, "amount")
_bill.Actual = field.NewField(tableName, "actual")
_bill.User = billBelongsToUser{
db: db.Session(&gorm.Session{}),
RelationField: field.NewRelation("User", "models.User"),
Admin: struct {
field.RelationField
2026-03-18 18:09:32 +08:00
Roles struct {
field.RelationField
Permissions struct {
field.RelationField
Parent struct {
field.RelationField
}
Children struct {
field.RelationField
}
}
}
}{
RelationField: field.NewRelation("User.Admin", "models.Admin"),
2026-03-18 18:09:32 +08:00
Roles: struct {
field.RelationField
Permissions struct {
field.RelationField
Parent struct {
field.RelationField
}
Children struct {
field.RelationField
}
}
}{
RelationField: field.NewRelation("User.Admin.Roles", "models.AdminRole"),
Permissions: struct {
field.RelationField
Parent struct {
field.RelationField
}
Children struct {
field.RelationField
}
}{
RelationField: field.NewRelation("User.Admin.Roles.Permissions", "models.Permission"),
Parent: struct {
field.RelationField
}{
RelationField: field.NewRelation("User.Admin.Roles.Permissions.Parent", "models.Permission"),
},
Children: struct {
field.RelationField
}{
RelationField: field.NewRelation("User.Admin.Roles.Permissions.Children", "models.Permission"),
},
},
},
},
Discount: struct {
field.RelationField
}{
RelationField: field.NewRelation("User.Discount", "models.ProductDiscount"),
},
2026-03-18 18:09:32 +08:00
Roles: struct {
field.RelationField
Permissions struct {
field.RelationField
}
}{
RelationField: field.NewRelation("User.Roles", "models.UserRole"),
Permissions: struct {
field.RelationField
}{
RelationField: field.NewRelation("User.Roles.Permissions", "models.Permission"),
},
},
}
_bill.Trade = billBelongsToTrade{
db: db.Session(&gorm.Session{}),
RelationField: field.NewRelation("Trade", "models.Trade"),
2026-03-20 14:37:41 +08:00
User: struct {
field.RelationField
}{
RelationField: field.NewRelation("Trade.User", "models.User"),
},
}
_bill.Resource = billBelongsToResource{
db: db.Session(&gorm.Session{}),
RelationField: field.NewRelation("Resource", "models.Resource"),
User: struct {
field.RelationField
}{
RelationField: field.NewRelation("Resource.User", "models.User"),
},
Short: struct {
field.RelationField
2026-03-24 16:25:21 +08:00
Sku struct {
field.RelationField
Product struct {
field.RelationField
}
Discount struct {
field.RelationField
}
}
}{
RelationField: field.NewRelation("Resource.Short", "models.ResourceShort"),
2026-03-24 16:25:21 +08:00
Sku: struct {
field.RelationField
Product struct {
field.RelationField
}
Discount struct {
field.RelationField
}
}{
RelationField: field.NewRelation("Resource.Short.Sku", "models.ProductSku"),
Product: struct {
field.RelationField
}{
RelationField: field.NewRelation("Resource.Short.Sku.Product", "models.Product"),
},
Discount: struct {
field.RelationField
}{
RelationField: field.NewRelation("Resource.Short.Sku.Discount", "models.ProductDiscount"),
},
},
},
Long: struct {
field.RelationField
2026-03-24 16:25:21 +08:00
Sku struct {
field.RelationField
}
}{
RelationField: field.NewRelation("Resource.Long", "models.ResourceLong"),
2026-03-24 16:25:21 +08:00
Sku: struct {
field.RelationField
}{
RelationField: field.NewRelation("Resource.Long.Sku", "models.ProductSku"),
},
},
Product: struct {
field.RelationField
}{
RelationField: field.NewRelation("Resource.Product", "models.Product"),
},
}
2025-03-18 10:13:57 +08:00
_bill.Refund = billBelongsToRefund{
db: db.Session(&gorm.Session{}),
RelationField: field.NewRelation("Refund", "models.Refund"),
}
2025-03-18 10:13:57 +08:00
_bill.fillFieldMap()
return _bill
}
type bill struct {
billDo
ALL field.Asterisk
ID field.Int32
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
UserID field.Int32
TradeID field.Int32
ResourceID field.Int32
RefundID field.Int32
CouponID field.Int32
BillNo field.String
Info field.String
Type field.Int
Amount field.Field
Actual field.Field
User billBelongsToUser
Trade billBelongsToTrade
Resource billBelongsToResource
2025-03-18 10:13:57 +08:00
Refund billBelongsToRefund
2025-03-18 10:13:57 +08:00
fieldMap map[string]field.Expr
}
func (b bill) Table(newTableName string) *bill {
b.billDo.UseTable(newTableName)
return b.updateTableName(newTableName)
}
func (b bill) As(alias string) *bill {
b.billDo.DO = *(b.billDo.As(alias).(*gen.DO))
return b.updateTableName(alias)
}
func (b *bill) updateTableName(table string) *bill {
b.ALL = field.NewAsterisk(table)
b.ID = field.NewInt32(table, "id")
b.CreatedAt = field.NewTime(table, "created_at")
b.UpdatedAt = field.NewTime(table, "updated_at")
b.DeletedAt = field.NewField(table, "deleted_at")
2025-03-18 10:13:57 +08:00
b.UserID = field.NewInt32(table, "user_id")
b.TradeID = field.NewInt32(table, "trade_id")
b.ResourceID = field.NewInt32(table, "resource_id")
b.RefundID = field.NewInt32(table, "refund_id")
b.CouponID = field.NewInt32(table, "coupon_id")
b.BillNo = field.NewString(table, "bill_no")
b.Info = field.NewString(table, "info")
b.Type = field.NewInt(table, "type")
b.Amount = field.NewField(table, "amount")
b.Actual = field.NewField(table, "actual")
2025-03-18 10:13:57 +08:00
b.fillFieldMap()
return b
}
func (b *bill) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := b.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (b *bill) fillFieldMap() {
b.fieldMap = make(map[string]field.Expr, 18)
2025-03-18 10:13:57 +08:00
b.fieldMap["id"] = b.ID
b.fieldMap["created_at"] = b.CreatedAt
b.fieldMap["updated_at"] = b.UpdatedAt
b.fieldMap["deleted_at"] = b.DeletedAt
2025-03-18 10:13:57 +08:00
b.fieldMap["user_id"] = b.UserID
b.fieldMap["trade_id"] = b.TradeID
b.fieldMap["resource_id"] = b.ResourceID
b.fieldMap["refund_id"] = b.RefundID
b.fieldMap["coupon_id"] = b.CouponID
b.fieldMap["bill_no"] = b.BillNo
b.fieldMap["info"] = b.Info
b.fieldMap["type"] = b.Type
b.fieldMap["amount"] = b.Amount
b.fieldMap["actual"] = b.Actual
2025-03-18 10:13:57 +08:00
}
func (b bill) clone(db *gorm.DB) bill {
b.billDo.ReplaceConnPool(db.Statement.ConnPool)
b.User.db = db.Session(&gorm.Session{Initialized: true})
b.User.db.Statement.ConnPool = db.Statement.ConnPool
b.Trade.db = db.Session(&gorm.Session{Initialized: true})
b.Trade.db.Statement.ConnPool = db.Statement.ConnPool
b.Resource.db = db.Session(&gorm.Session{Initialized: true})
b.Resource.db.Statement.ConnPool = db.Statement.ConnPool
b.Refund.db = db.Session(&gorm.Session{Initialized: true})
b.Refund.db.Statement.ConnPool = db.Statement.ConnPool
2025-03-18 10:13:57 +08:00
return b
}
func (b bill) replaceDB(db *gorm.DB) bill {
b.billDo.ReplaceDB(db)
b.User.db = db.Session(&gorm.Session{})
b.Trade.db = db.Session(&gorm.Session{})
b.Resource.db = db.Session(&gorm.Session{})
b.Refund.db = db.Session(&gorm.Session{})
2025-03-18 10:13:57 +08:00
return b
}
type billBelongsToUser struct {
db *gorm.DB
field.RelationField
Admin struct {
field.RelationField
2026-03-18 18:09:32 +08:00
Roles struct {
field.RelationField
Permissions struct {
field.RelationField
Parent struct {
field.RelationField
}
Children struct {
field.RelationField
}
}
}
}
Discount struct {
field.RelationField
}
2026-03-18 18:09:32 +08:00
Roles struct {
field.RelationField
Permissions struct {
field.RelationField
}
}
}
func (a billBelongsToUser) Where(conds ...field.Expr) *billBelongsToUser {
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 billBelongsToUser) WithContext(ctx context.Context) *billBelongsToUser {
a.db = a.db.WithContext(ctx)
return &a
}
func (a billBelongsToUser) Session(session *gorm.Session) *billBelongsToUser {
a.db = a.db.Session(session)
return &a
}
func (a billBelongsToUser) Model(m *models.Bill) *billBelongsToUserTx {
return &billBelongsToUserTx{a.db.Model(m).Association(a.Name())}
}
func (a billBelongsToUser) Unscoped() *billBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type billBelongsToUserTx struct{ tx *gorm.Association }
func (a billBelongsToUserTx) Find() (result *models.User, err error) {
return result, a.tx.Find(&result)
}
func (a billBelongsToUserTx) Append(values ...*models.User) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Append(targetValues...)
}
func (a billBelongsToUserTx) Replace(values ...*models.User) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Replace(targetValues...)
}
func (a billBelongsToUserTx) Delete(values ...*models.User) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Delete(targetValues...)
}
func (a billBelongsToUserTx) Clear() error {
return a.tx.Clear()
}
func (a billBelongsToUserTx) Count() int64 {
return a.tx.Count()
}
func (a billBelongsToUserTx) Unscoped() *billBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type billBelongsToTrade struct {
db *gorm.DB
field.RelationField
2026-03-20 14:37:41 +08:00
User struct {
field.RelationField
}
}
func (a billBelongsToTrade) Where(conds ...field.Expr) *billBelongsToTrade {
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 billBelongsToTrade) WithContext(ctx context.Context) *billBelongsToTrade {
a.db = a.db.WithContext(ctx)
return &a
}
func (a billBelongsToTrade) Session(session *gorm.Session) *billBelongsToTrade {
a.db = a.db.Session(session)
return &a
}
func (a billBelongsToTrade) Model(m *models.Bill) *billBelongsToTradeTx {
return &billBelongsToTradeTx{a.db.Model(m).Association(a.Name())}
}
func (a billBelongsToTrade) Unscoped() *billBelongsToTrade {
a.db = a.db.Unscoped()
return &a
}
type billBelongsToTradeTx struct{ tx *gorm.Association }
func (a billBelongsToTradeTx) Find() (result *models.Trade, err error) {
return result, a.tx.Find(&result)
}
func (a billBelongsToTradeTx) Append(values ...*models.Trade) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Append(targetValues...)
}
func (a billBelongsToTradeTx) Replace(values ...*models.Trade) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Replace(targetValues...)
}
func (a billBelongsToTradeTx) Delete(values ...*models.Trade) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Delete(targetValues...)
}
func (a billBelongsToTradeTx) Clear() error {
return a.tx.Clear()
}
func (a billBelongsToTradeTx) Count() int64 {
return a.tx.Count()
}
func (a billBelongsToTradeTx) Unscoped() *billBelongsToTradeTx {
a.tx = a.tx.Unscoped()
return &a
}
type billBelongsToResource struct {
db *gorm.DB
field.RelationField
User struct {
field.RelationField
}
Short struct {
field.RelationField
2026-03-24 16:25:21 +08:00
Sku struct {
field.RelationField
Product struct {
field.RelationField
}
Discount struct {
field.RelationField
}
}
}
Long struct {
field.RelationField
2026-03-24 16:25:21 +08:00
Sku struct {
field.RelationField
}
}
Product struct {
field.RelationField
}
}
func (a billBelongsToResource) Where(conds ...field.Expr) *billBelongsToResource {
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 billBelongsToResource) WithContext(ctx context.Context) *billBelongsToResource {
a.db = a.db.WithContext(ctx)
return &a
}
func (a billBelongsToResource) Session(session *gorm.Session) *billBelongsToResource {
a.db = a.db.Session(session)
return &a
}
func (a billBelongsToResource) Model(m *models.Bill) *billBelongsToResourceTx {
return &billBelongsToResourceTx{a.db.Model(m).Association(a.Name())}
}
func (a billBelongsToResource) Unscoped() *billBelongsToResource {
a.db = a.db.Unscoped()
return &a
}
type billBelongsToResourceTx struct{ tx *gorm.Association }
func (a billBelongsToResourceTx) Find() (result *models.Resource, err error) {
return result, a.tx.Find(&result)
}
func (a billBelongsToResourceTx) Append(values ...*models.Resource) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Append(targetValues...)
}
func (a billBelongsToResourceTx) Replace(values ...*models.Resource) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Replace(targetValues...)
}
func (a billBelongsToResourceTx) Delete(values ...*models.Resource) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Delete(targetValues...)
}
func (a billBelongsToResourceTx) Clear() error {
return a.tx.Clear()
}
func (a billBelongsToResourceTx) Count() int64 {
return a.tx.Count()
}
func (a billBelongsToResourceTx) Unscoped() *billBelongsToResourceTx {
a.tx = a.tx.Unscoped()
return &a
}
type billBelongsToRefund struct {
db *gorm.DB
field.RelationField
}
func (a billBelongsToRefund) Where(conds ...field.Expr) *billBelongsToRefund {
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 billBelongsToRefund) WithContext(ctx context.Context) *billBelongsToRefund {
a.db = a.db.WithContext(ctx)
return &a
}
func (a billBelongsToRefund) Session(session *gorm.Session) *billBelongsToRefund {
a.db = a.db.Session(session)
return &a
}
func (a billBelongsToRefund) Model(m *models.Bill) *billBelongsToRefundTx {
return &billBelongsToRefundTx{a.db.Model(m).Association(a.Name())}
}
func (a billBelongsToRefund) Unscoped() *billBelongsToRefund {
a.db = a.db.Unscoped()
return &a
}
type billBelongsToRefundTx struct{ tx *gorm.Association }
func (a billBelongsToRefundTx) Find() (result *models.Refund, err error) {
return result, a.tx.Find(&result)
}
func (a billBelongsToRefundTx) Append(values ...*models.Refund) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Append(targetValues...)
}
func (a billBelongsToRefundTx) Replace(values ...*models.Refund) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Replace(targetValues...)
}
func (a billBelongsToRefundTx) Delete(values ...*models.Refund) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Delete(targetValues...)
}
func (a billBelongsToRefundTx) Clear() error {
return a.tx.Clear()
}
func (a billBelongsToRefundTx) Count() int64 {
return a.tx.Count()
}
func (a billBelongsToRefundTx) Unscoped() *billBelongsToRefundTx {
a.tx = a.tx.Unscoped()
return &a
}
2025-03-18 10:13:57 +08:00
type billDo struct{ gen.DO }
func (b billDo) Debug() *billDo {
return b.withDO(b.DO.Debug())
}
func (b billDo) WithContext(ctx context.Context) *billDo {
return b.withDO(b.DO.WithContext(ctx))
}
func (b billDo) ReadDB() *billDo {
return b.Clauses(dbresolver.Read)
}
func (b billDo) WriteDB() *billDo {
return b.Clauses(dbresolver.Write)
}
func (b billDo) Session(config *gorm.Session) *billDo {
return b.withDO(b.DO.Session(config))
}
func (b billDo) Clauses(conds ...clause.Expression) *billDo {
return b.withDO(b.DO.Clauses(conds...))
}
func (b billDo) Returning(value interface{}, columns ...string) *billDo {
return b.withDO(b.DO.Returning(value, columns...))
}
func (b billDo) Not(conds ...gen.Condition) *billDo {
return b.withDO(b.DO.Not(conds...))
}
func (b billDo) Or(conds ...gen.Condition) *billDo {
return b.withDO(b.DO.Or(conds...))
}
func (b billDo) Select(conds ...field.Expr) *billDo {
return b.withDO(b.DO.Select(conds...))
}
func (b billDo) Where(conds ...gen.Condition) *billDo {
return b.withDO(b.DO.Where(conds...))
}
func (b billDo) Order(conds ...field.Expr) *billDo {
return b.withDO(b.DO.Order(conds...))
}
func (b billDo) Distinct(cols ...field.Expr) *billDo {
return b.withDO(b.DO.Distinct(cols...))
}
func (b billDo) Omit(cols ...field.Expr) *billDo {
return b.withDO(b.DO.Omit(cols...))
}
func (b billDo) Join(table schema.Tabler, on ...field.Expr) *billDo {
return b.withDO(b.DO.Join(table, on...))
}
func (b billDo) LeftJoin(table schema.Tabler, on ...field.Expr) *billDo {
return b.withDO(b.DO.LeftJoin(table, on...))
}
func (b billDo) RightJoin(table schema.Tabler, on ...field.Expr) *billDo {
return b.withDO(b.DO.RightJoin(table, on...))
}
func (b billDo) Group(cols ...field.Expr) *billDo {
return b.withDO(b.DO.Group(cols...))
}
func (b billDo) Having(conds ...gen.Condition) *billDo {
return b.withDO(b.DO.Having(conds...))
}
func (b billDo) Limit(limit int) *billDo {
return b.withDO(b.DO.Limit(limit))
}
func (b billDo) Offset(offset int) *billDo {
return b.withDO(b.DO.Offset(offset))
}
func (b billDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *billDo {
return b.withDO(b.DO.Scopes(funcs...))
}
func (b billDo) Unscoped() *billDo {
return b.withDO(b.DO.Unscoped())
}
func (b billDo) Create(values ...*models.Bill) error {
if len(values) == 0 {
return nil
}
return b.DO.Create(values)
}
func (b billDo) CreateInBatches(values []*models.Bill, batchSize int) error {
return b.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 (b billDo) Save(values ...*models.Bill) error {
if len(values) == 0 {
return nil
}
return b.DO.Save(values)
}
func (b billDo) First() (*models.Bill, error) {
if result, err := b.DO.First(); err != nil {
return nil, err
} else {
return result.(*models.Bill), nil
}
}
func (b billDo) Take() (*models.Bill, error) {
if result, err := b.DO.Take(); err != nil {
return nil, err
} else {
return result.(*models.Bill), nil
}
}
func (b billDo) Last() (*models.Bill, error) {
if result, err := b.DO.Last(); err != nil {
return nil, err
} else {
return result.(*models.Bill), nil
}
}
func (b billDo) Find() ([]*models.Bill, error) {
result, err := b.DO.Find()
return result.([]*models.Bill), err
}
func (b billDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Bill, err error) {
buf := make([]*models.Bill, 0, batchSize)
err = b.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 (b billDo) FindInBatches(result *[]*models.Bill, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return b.DO.FindInBatches(result, batchSize, fc)
}
func (b billDo) Attrs(attrs ...field.AssignExpr) *billDo {
return b.withDO(b.DO.Attrs(attrs...))
}
func (b billDo) Assign(attrs ...field.AssignExpr) *billDo {
return b.withDO(b.DO.Assign(attrs...))
}
func (b billDo) Joins(fields ...field.RelationField) *billDo {
for _, _f := range fields {
b = *b.withDO(b.DO.Joins(_f))
}
return &b
}
func (b billDo) Preload(fields ...field.RelationField) *billDo {
for _, _f := range fields {
b = *b.withDO(b.DO.Preload(_f))
}
return &b
}
func (b billDo) FirstOrInit() (*models.Bill, error) {
if result, err := b.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*models.Bill), nil
}
}
func (b billDo) FirstOrCreate() (*models.Bill, error) {
if result, err := b.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*models.Bill), nil
}
}
func (b billDo) FindByPage(offset int, limit int) (result []*models.Bill, count int64, err error) {
result, err = b.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 = b.Offset(-1).Limit(-1).Count()
return
}
func (b billDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = b.Count()
if err != nil {
return
}
err = b.Offset(offset).Limit(limit).Scan(result)
return
}
func (b billDo) Scan(result interface{}) (err error) {
return b.DO.Scan(result)
}
func (b billDo) Delete(models ...*models.Bill) (result gen.ResultInfo, err error) {
return b.DO.Delete(models)
}
func (b *billDo) withDO(do gen.Dao) *billDo {
b.DO = *do.(*gen.DO)
return b
}