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 newTrade(db *gorm.DB, opts ...gen.DOOption) trade {
|
|
|
|
|
_trade := trade{}
|
|
|
|
|
|
|
|
|
|
_trade.tradeDo.UseDB(db, opts...)
|
|
|
|
|
_trade.tradeDo.UseModel(&models.Trade{})
|
|
|
|
|
|
|
|
|
|
tableName := _trade.tradeDo.TableName()
|
|
|
|
|
_trade.ALL = field.NewAsterisk(tableName)
|
|
|
|
|
_trade.ID = field.NewInt32(tableName, "id")
|
2025-11-24 18:44:06 +08:00
|
|
|
_trade.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
|
|
_trade.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
|
_trade.DeletedAt = field.NewField(tableName, "deleted_at")
|
2025-03-18 10:13:57 +08:00
|
|
|
_trade.UserID = field.NewInt32(tableName, "user_id")
|
|
|
|
|
_trade.InnerNo = field.NewString(tableName, "inner_no")
|
|
|
|
|
_trade.OuterNo = field.NewString(tableName, "outer_no")
|
2025-11-24 18:44:06 +08:00
|
|
|
_trade.Type = field.NewInt(tableName, "type")
|
2025-03-18 10:13:57 +08:00
|
|
|
_trade.Subject = field.NewString(tableName, "subject")
|
|
|
|
|
_trade.Remark = field.NewString(tableName, "remark")
|
2025-05-20 17:14:07 +08:00
|
|
|
_trade.Amount = field.NewField(tableName, "amount")
|
|
|
|
|
_trade.Payment = field.NewField(tableName, "payment")
|
2025-11-24 18:44:06 +08:00
|
|
|
_trade.Method = field.NewInt(tableName, "method")
|
|
|
|
|
_trade.Platform = field.NewInt(tableName, "platform")
|
|
|
|
|
_trade.Acquirer = field.NewInt(tableName, "acquirer")
|
|
|
|
|
_trade.Status = field.NewInt(tableName, "status")
|
2025-11-17 18:38:10 +08:00
|
|
|
_trade.Refunded = field.NewBool(tableName, "refunded")
|
2025-06-26 09:28:42 +08:00
|
|
|
_trade.PaymentURL = field.NewString(tableName, "payment_url")
|
2025-11-24 18:44:06 +08:00
|
|
|
_trade.CompletedAt = field.NewTime(tableName, "completed_at")
|
|
|
|
|
_trade.CanceledAt = field.NewTime(tableName, "canceled_at")
|
2026-03-20 14:37:41 +08:00
|
|
|
_trade.User = tradeBelongsToUser{
|
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
|
|
RelationField: field.NewRelation("User", "models.User"),
|
|
|
|
|
Admin: struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Roles struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Permissions struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Parent struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
Children struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}{
|
|
|
|
|
RelationField: field.NewRelation("User.Admin", "models.Admin"),
|
|
|
|
|
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"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-03-27 16:16:55 +08:00
|
|
|
Discount: struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}{
|
|
|
|
|
RelationField: field.NewRelation("User.Discount", "models.ProductDiscount"),
|
|
|
|
|
},
|
2026-03-20 14:37:41 +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"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2025-03-18 10:13:57 +08:00
|
|
|
|
|
|
|
|
_trade.fillFieldMap()
|
|
|
|
|
|
|
|
|
|
return _trade
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type trade struct {
|
|
|
|
|
tradeDo
|
|
|
|
|
|
2025-06-26 09:28:42 +08:00
|
|
|
ALL field.Asterisk
|
2025-11-24 18:44:06 +08:00
|
|
|
ID field.Int32
|
|
|
|
|
CreatedAt field.Time
|
|
|
|
|
UpdatedAt field.Time
|
|
|
|
|
DeletedAt field.Field
|
|
|
|
|
UserID field.Int32
|
|
|
|
|
InnerNo field.String
|
|
|
|
|
OuterNo field.String
|
|
|
|
|
Type field.Int
|
|
|
|
|
Subject field.String
|
|
|
|
|
Remark field.String
|
|
|
|
|
Amount field.Field
|
|
|
|
|
Payment field.Field
|
|
|
|
|
Method field.Int
|
|
|
|
|
Platform field.Int
|
|
|
|
|
Acquirer field.Int
|
|
|
|
|
Status field.Int
|
2025-11-17 18:38:10 +08:00
|
|
|
Refunded field.Bool
|
2025-11-24 18:44:06 +08:00
|
|
|
PaymentURL field.String
|
|
|
|
|
CompletedAt field.Time
|
|
|
|
|
CanceledAt field.Time
|
2026-03-20 14:37:41 +08:00
|
|
|
User tradeBelongsToUser
|
2025-03-18 10:13:57 +08:00
|
|
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t trade) Table(newTableName string) *trade {
|
|
|
|
|
t.tradeDo.UseTable(newTableName)
|
|
|
|
|
return t.updateTableName(newTableName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t trade) As(alias string) *trade {
|
|
|
|
|
t.tradeDo.DO = *(t.tradeDo.As(alias).(*gen.DO))
|
|
|
|
|
return t.updateTableName(alias)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t *trade) updateTableName(table string) *trade {
|
|
|
|
|
t.ALL = field.NewAsterisk(table)
|
|
|
|
|
t.ID = field.NewInt32(table, "id")
|
2025-11-24 18:44:06 +08:00
|
|
|
t.CreatedAt = field.NewTime(table, "created_at")
|
|
|
|
|
t.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
|
t.DeletedAt = field.NewField(table, "deleted_at")
|
2025-03-18 10:13:57 +08:00
|
|
|
t.UserID = field.NewInt32(table, "user_id")
|
|
|
|
|
t.InnerNo = field.NewString(table, "inner_no")
|
|
|
|
|
t.OuterNo = field.NewString(table, "outer_no")
|
2025-11-24 18:44:06 +08:00
|
|
|
t.Type = field.NewInt(table, "type")
|
2025-03-18 10:13:57 +08:00
|
|
|
t.Subject = field.NewString(table, "subject")
|
|
|
|
|
t.Remark = field.NewString(table, "remark")
|
2025-05-20 17:14:07 +08:00
|
|
|
t.Amount = field.NewField(table, "amount")
|
|
|
|
|
t.Payment = field.NewField(table, "payment")
|
2025-11-24 18:44:06 +08:00
|
|
|
t.Method = field.NewInt(table, "method")
|
|
|
|
|
t.Platform = field.NewInt(table, "platform")
|
|
|
|
|
t.Acquirer = field.NewInt(table, "acquirer")
|
|
|
|
|
t.Status = field.NewInt(table, "status")
|
2025-11-17 18:38:10 +08:00
|
|
|
t.Refunded = field.NewBool(table, "refunded")
|
2025-06-26 09:28:42 +08:00
|
|
|
t.PaymentURL = field.NewString(table, "payment_url")
|
2025-11-24 18:44:06 +08:00
|
|
|
t.CompletedAt = field.NewTime(table, "completed_at")
|
|
|
|
|
t.CanceledAt = field.NewTime(table, "canceled_at")
|
2025-03-18 10:13:57 +08:00
|
|
|
|
|
|
|
|
t.fillFieldMap()
|
|
|
|
|
|
|
|
|
|
return t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t *trade) 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 *trade) fillFieldMap() {
|
2026-03-20 14:37:41 +08:00
|
|
|
t.fieldMap = make(map[string]field.Expr, 21)
|
2025-03-18 10:13:57 +08:00
|
|
|
t.fieldMap["id"] = t.ID
|
2025-11-24 18:44:06 +08:00
|
|
|
t.fieldMap["created_at"] = t.CreatedAt
|
|
|
|
|
t.fieldMap["updated_at"] = t.UpdatedAt
|
|
|
|
|
t.fieldMap["deleted_at"] = t.DeletedAt
|
2025-03-18 10:13:57 +08:00
|
|
|
t.fieldMap["user_id"] = t.UserID
|
|
|
|
|
t.fieldMap["inner_no"] = t.InnerNo
|
|
|
|
|
t.fieldMap["outer_no"] = t.OuterNo
|
2025-05-08 10:46:21 +08:00
|
|
|
t.fieldMap["type"] = t.Type
|
2025-03-18 10:13:57 +08:00
|
|
|
t.fieldMap["subject"] = t.Subject
|
|
|
|
|
t.fieldMap["remark"] = t.Remark
|
|
|
|
|
t.fieldMap["amount"] = t.Amount
|
|
|
|
|
t.fieldMap["payment"] = t.Payment
|
|
|
|
|
t.fieldMap["method"] = t.Method
|
2025-06-17 10:53:05 +08:00
|
|
|
t.fieldMap["platform"] = t.Platform
|
2025-11-17 18:38:10 +08:00
|
|
|
t.fieldMap["acquirer"] = t.Acquirer
|
|
|
|
|
t.fieldMap["status"] = t.Status
|
|
|
|
|
t.fieldMap["refunded"] = t.Refunded
|
2025-06-26 09:28:42 +08:00
|
|
|
t.fieldMap["payment_url"] = t.PaymentURL
|
|
|
|
|
t.fieldMap["completed_at"] = t.CompletedAt
|
|
|
|
|
t.fieldMap["canceled_at"] = t.CanceledAt
|
2026-03-20 14:37:41 +08:00
|
|
|
|
2025-03-18 10:13:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t trade) clone(db *gorm.DB) trade {
|
|
|
|
|
t.tradeDo.ReplaceConnPool(db.Statement.ConnPool)
|
2026-03-20 14:37:41 +08:00
|
|
|
t.User.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
t.User.db.Statement.ConnPool = db.Statement.ConnPool
|
2025-03-18 10:13:57 +08:00
|
|
|
return t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t trade) replaceDB(db *gorm.DB) trade {
|
|
|
|
|
t.tradeDo.ReplaceDB(db)
|
2026-03-20 14:37:41 +08:00
|
|
|
t.User.db = db.Session(&gorm.Session{})
|
2025-03-18 10:13:57 +08:00
|
|
|
return t
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 14:37:41 +08:00
|
|
|
type tradeBelongsToUser struct {
|
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
|
|
field.RelationField
|
|
|
|
|
|
|
|
|
|
Admin struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Roles struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Permissions struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Parent struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
Children struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-27 16:16:55 +08:00
|
|
|
Discount struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
2026-03-20 14:37:41 +08:00
|
|
|
Roles struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Permissions struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUser) Where(conds ...field.Expr) *tradeBelongsToUser {
|
|
|
|
|
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 tradeBelongsToUser) WithContext(ctx context.Context) *tradeBelongsToUser {
|
|
|
|
|
a.db = a.db.WithContext(ctx)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUser) Session(session *gorm.Session) *tradeBelongsToUser {
|
|
|
|
|
a.db = a.db.Session(session)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUser) Model(m *models.Trade) *tradeBelongsToUserTx {
|
|
|
|
|
return &tradeBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUser) Unscoped() *tradeBelongsToUser {
|
|
|
|
|
a.db = a.db.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type tradeBelongsToUserTx struct{ tx *gorm.Association }
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUserTx) Find() (result *models.User, err error) {
|
|
|
|
|
return result, a.tx.Find(&result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUserTx) 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 tradeBelongsToUserTx) 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 tradeBelongsToUserTx) 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 tradeBelongsToUserTx) Clear() error {
|
|
|
|
|
return a.tx.Clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUserTx) Count() int64 {
|
|
|
|
|
return a.tx.Count()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a tradeBelongsToUserTx) Unscoped() *tradeBelongsToUserTx {
|
|
|
|
|
a.tx = a.tx.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-18 10:13:57 +08:00
|
|
|
type tradeDo struct{ gen.DO }
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Debug() *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Debug())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) WithContext(ctx context.Context) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.WithContext(ctx))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) ReadDB() *tradeDo {
|
|
|
|
|
return t.Clauses(dbresolver.Read)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) WriteDB() *tradeDo {
|
|
|
|
|
return t.Clauses(dbresolver.Write)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Session(config *gorm.Session) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Session(config))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Clauses(conds ...clause.Expression) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Clauses(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Returning(value interface{}, columns ...string) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Returning(value, columns...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Not(conds ...gen.Condition) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Not(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Or(conds ...gen.Condition) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Or(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Select(conds ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Select(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Where(conds ...gen.Condition) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Where(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Order(conds ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Order(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Distinct(cols ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Distinct(cols...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Omit(cols ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Omit(cols...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Join(table schema.Tabler, on ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Join(table, on...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) LeftJoin(table schema.Tabler, on ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.LeftJoin(table, on...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) RightJoin(table schema.Tabler, on ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.RightJoin(table, on...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Group(cols ...field.Expr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Group(cols...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Having(conds ...gen.Condition) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Having(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Limit(limit int) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Limit(limit))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Offset(offset int) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Offset(offset))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Scopes(funcs...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Unscoped() *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Unscoped())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Create(values ...*models.Trade) error {
|
|
|
|
|
if len(values) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return t.DO.Create(values)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) CreateInBatches(values []*models.Trade, 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 tradeDo) Save(values ...*models.Trade) error {
|
|
|
|
|
if len(values) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return t.DO.Save(values)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) First() (*models.Trade, error) {
|
|
|
|
|
if result, err := t.DO.First(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.Trade), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Take() (*models.Trade, error) {
|
|
|
|
|
if result, err := t.DO.Take(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.Trade), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Last() (*models.Trade, error) {
|
|
|
|
|
if result, err := t.DO.Last(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.Trade), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Find() ([]*models.Trade, error) {
|
|
|
|
|
result, err := t.DO.Find()
|
|
|
|
|
return result.([]*models.Trade), err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Trade, err error) {
|
|
|
|
|
buf := make([]*models.Trade, 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 tradeDo) FindInBatches(result *[]*models.Trade, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
|
|
return t.DO.FindInBatches(result, batchSize, fc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Attrs(attrs ...field.AssignExpr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Attrs(attrs...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Assign(attrs ...field.AssignExpr) *tradeDo {
|
|
|
|
|
return t.withDO(t.DO.Assign(attrs...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Joins(fields ...field.RelationField) *tradeDo {
|
|
|
|
|
for _, _f := range fields {
|
|
|
|
|
t = *t.withDO(t.DO.Joins(_f))
|
|
|
|
|
}
|
|
|
|
|
return &t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Preload(fields ...field.RelationField) *tradeDo {
|
|
|
|
|
for _, _f := range fields {
|
|
|
|
|
t = *t.withDO(t.DO.Preload(_f))
|
|
|
|
|
}
|
|
|
|
|
return &t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) FirstOrInit() (*models.Trade, error) {
|
|
|
|
|
if result, err := t.DO.FirstOrInit(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.Trade), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) FirstOrCreate() (*models.Trade, error) {
|
|
|
|
|
if result, err := t.DO.FirstOrCreate(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.Trade), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) FindByPage(offset int, limit int) (result []*models.Trade, 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 tradeDo) ScanByPage(result interface{}, 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 tradeDo) Scan(result interface{}) (err error) {
|
|
|
|
|
return t.DO.Scan(result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t tradeDo) Delete(models ...*models.Trade) (result gen.ResultInfo, err error) {
|
|
|
|
|
return t.DO.Delete(models)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t *tradeDo) withDO(do gen.Dao) *tradeDo {
|
|
|
|
|
t.DO = *do.(*gen.DO)
|
|
|
|
|
return t
|
|
|
|
|
}
|