1019 lines
25 KiB
Go
1019 lines
25 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 dal
|
|
|
|
import (
|
|
"app/internal/models"
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
)
|
|
|
|
func newOrder(db *gorm.DB, opts ...gen.DOOption) order {
|
|
_order := order{}
|
|
|
|
_order.orderDo.UseDB(db, opts...)
|
|
_order.orderDo.UseModel(&models.Order{})
|
|
|
|
tableName := _order.orderDo.TableName()
|
|
_order.ALL = field.NewAsterisk(tableName)
|
|
_order.Id = field.NewUint(tableName, "id")
|
|
_order.Status = field.NewString(tableName, "status")
|
|
_order.Description = field.NewString(tableName, "description")
|
|
_order.ProductTypeId = field.NewInt(tableName, "product_type_id")
|
|
_order.ProductAmount = field.NewUint(tableName, "product_amount")
|
|
_order.CustomerId = field.NewUint(tableName, "customer_id")
|
|
_order.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
_order.DeadlineDate = field.NewInt64(tableName, "deadline_date")
|
|
_order.Tasks = orderHasManyTasks{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Tasks", "models.Task"),
|
|
ProductType: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.ProductType", "models.ProductType"),
|
|
},
|
|
Order: struct {
|
|
field.RelationField
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
Customer struct {
|
|
field.RelationField
|
|
Orders struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
Tasks struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.Order", "models.Order"),
|
|
ProductType: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.Order.ProductType", "models.ProductType"),
|
|
},
|
|
Customer: struct {
|
|
field.RelationField
|
|
Orders struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.Order.Customer", "models.Customer"),
|
|
Orders: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.Order.Customer.Orders", "models.Order"),
|
|
},
|
|
},
|
|
Tasks: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.Order.Tasks", "models.Task"),
|
|
},
|
|
},
|
|
PrepTasks: struct {
|
|
field.RelationField
|
|
Task struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
WorkAreas struct {
|
|
field.RelationField
|
|
}
|
|
Workers struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
TeamType struct {
|
|
field.RelationField
|
|
}
|
|
TeamLeader struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
TeamMembers struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}
|
|
Tasks struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
PrepTasks struct {
|
|
field.RelationField
|
|
}
|
|
Shifts struct {
|
|
field.RelationField
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks", "models.PrepTask"),
|
|
Task: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.Task", "models.Task"),
|
|
},
|
|
WorkArea: struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
WorkAreas struct {
|
|
field.RelationField
|
|
}
|
|
Workers struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
TeamType struct {
|
|
field.RelationField
|
|
}
|
|
TeamLeader struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
TeamMembers struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}
|
|
Tasks struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
PrepTasks struct {
|
|
field.RelationField
|
|
}
|
|
Shifts struct {
|
|
field.RelationField
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea", "models.WorkArea"),
|
|
Workshop: struct {
|
|
field.RelationField
|
|
WorkAreas struct {
|
|
field.RelationField
|
|
}
|
|
Workers struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
TeamType struct {
|
|
field.RelationField
|
|
}
|
|
TeamLeader struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
TeamMembers struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}
|
|
Tasks struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop", "models.Workshop"),
|
|
WorkAreas: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.WorkAreas", "models.WorkArea"),
|
|
},
|
|
Workers: struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
TeamType struct {
|
|
field.RelationField
|
|
}
|
|
TeamLeader struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
TeamMembers struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers", "models.Worker"),
|
|
Workshop: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.Workshop", "models.Workshop"),
|
|
},
|
|
TeamTasks: struct {
|
|
field.RelationField
|
|
TeamType struct {
|
|
field.RelationField
|
|
}
|
|
TeamLeader struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
TeamMembers struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks", "models.TeamTask"),
|
|
TeamType: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamType", "models.TeamType"),
|
|
},
|
|
TeamLeader: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamLeader", "models.Worker"),
|
|
},
|
|
WorkArea: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.WorkArea", "models.WorkArea"),
|
|
},
|
|
TeamMembers: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamMembers", "models.Worker"),
|
|
},
|
|
},
|
|
},
|
|
Tasks: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Tasks", "models.Task"),
|
|
},
|
|
},
|
|
PrepTasks: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.PrepTasks", "models.PrepTask"),
|
|
},
|
|
Shifts: struct {
|
|
field.RelationField
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Shifts", "models.Shift"),
|
|
ProductType: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Shifts.ProductType", "models.ProductType"),
|
|
},
|
|
WorkArea: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Shifts.WorkArea", "models.WorkArea"),
|
|
},
|
|
},
|
|
TeamTasks: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.TeamTasks", "models.TeamTask"),
|
|
},
|
|
},
|
|
},
|
|
Workshops: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("Tasks.Workshops", "models.Workshop"),
|
|
},
|
|
}
|
|
|
|
_order.ProductType = orderBelongsToProductType{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("ProductType", "models.ProductType"),
|
|
}
|
|
|
|
_order.Customer = orderBelongsToCustomer{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Customer", "models.Customer"),
|
|
}
|
|
|
|
_order.fillFieldMap()
|
|
|
|
return _order
|
|
}
|
|
|
|
type order struct {
|
|
orderDo
|
|
|
|
ALL field.Asterisk
|
|
Id field.Uint
|
|
Status field.String
|
|
Description field.String
|
|
ProductTypeId field.Int
|
|
ProductAmount field.Uint
|
|
CustomerId field.Uint
|
|
CreatedAt field.Int64
|
|
DeadlineDate field.Int64
|
|
Tasks orderHasManyTasks
|
|
|
|
ProductType orderBelongsToProductType
|
|
|
|
Customer orderBelongsToCustomer
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (o order) Table(newTableName string) *order {
|
|
o.orderDo.UseTable(newTableName)
|
|
return o.updateTableName(newTableName)
|
|
}
|
|
|
|
func (o order) As(alias string) *order {
|
|
o.orderDo.DO = *(o.orderDo.As(alias).(*gen.DO))
|
|
return o.updateTableName(alias)
|
|
}
|
|
|
|
func (o *order) updateTableName(table string) *order {
|
|
o.ALL = field.NewAsterisk(table)
|
|
o.Id = field.NewUint(table, "id")
|
|
o.Status = field.NewString(table, "status")
|
|
o.Description = field.NewString(table, "description")
|
|
o.ProductTypeId = field.NewInt(table, "product_type_id")
|
|
o.ProductAmount = field.NewUint(table, "product_amount")
|
|
o.CustomerId = field.NewUint(table, "customer_id")
|
|
o.CreatedAt = field.NewInt64(table, "created_at")
|
|
o.DeadlineDate = field.NewInt64(table, "deadline_date")
|
|
|
|
o.fillFieldMap()
|
|
|
|
return o
|
|
}
|
|
|
|
func (o *order) 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 *order) fillFieldMap() {
|
|
o.fieldMap = make(map[string]field.Expr, 11)
|
|
o.fieldMap["id"] = o.Id
|
|
o.fieldMap["status"] = o.Status
|
|
o.fieldMap["description"] = o.Description
|
|
o.fieldMap["product_type_id"] = o.ProductTypeId
|
|
o.fieldMap["product_amount"] = o.ProductAmount
|
|
o.fieldMap["customer_id"] = o.CustomerId
|
|
o.fieldMap["created_at"] = o.CreatedAt
|
|
o.fieldMap["deadline_date"] = o.DeadlineDate
|
|
|
|
}
|
|
|
|
func (o order) clone(db *gorm.DB) order {
|
|
o.orderDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return o
|
|
}
|
|
|
|
func (o order) replaceDB(db *gorm.DB) order {
|
|
o.orderDo.ReplaceDB(db)
|
|
return o
|
|
}
|
|
|
|
type orderHasManyTasks struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
Order struct {
|
|
field.RelationField
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
Customer struct {
|
|
field.RelationField
|
|
Orders struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
Tasks struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
PrepTasks struct {
|
|
field.RelationField
|
|
Task struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
WorkAreas struct {
|
|
field.RelationField
|
|
}
|
|
Workers struct {
|
|
field.RelationField
|
|
Workshop struct {
|
|
field.RelationField
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
TeamType struct {
|
|
field.RelationField
|
|
}
|
|
TeamLeader struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
TeamMembers struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}
|
|
Tasks struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
PrepTasks struct {
|
|
field.RelationField
|
|
}
|
|
Shifts struct {
|
|
field.RelationField
|
|
ProductType struct {
|
|
field.RelationField
|
|
}
|
|
WorkArea struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
TeamTasks struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
}
|
|
Workshops struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
|
|
func (a orderHasManyTasks) Where(conds ...field.Expr) *orderHasManyTasks {
|
|
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 orderHasManyTasks) WithContext(ctx context.Context) *orderHasManyTasks {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a orderHasManyTasks) Session(session *gorm.Session) *orderHasManyTasks {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a orderHasManyTasks) Model(m *models.Order) *orderHasManyTasksTx {
|
|
return &orderHasManyTasksTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type orderHasManyTasksTx struct{ tx *gorm.Association }
|
|
|
|
func (a orderHasManyTasksTx) Find() (result []*models.Task, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a orderHasManyTasksTx) Append(values ...*models.Task) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a orderHasManyTasksTx) Replace(values ...*models.Task) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a orderHasManyTasksTx) Delete(values ...*models.Task) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a orderHasManyTasksTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a orderHasManyTasksTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type orderBelongsToProductType struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a orderBelongsToProductType) Where(conds ...field.Expr) *orderBelongsToProductType {
|
|
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 orderBelongsToProductType) WithContext(ctx context.Context) *orderBelongsToProductType {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a orderBelongsToProductType) Session(session *gorm.Session) *orderBelongsToProductType {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a orderBelongsToProductType) Model(m *models.Order) *orderBelongsToProductTypeTx {
|
|
return &orderBelongsToProductTypeTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type orderBelongsToProductTypeTx struct{ tx *gorm.Association }
|
|
|
|
func (a orderBelongsToProductTypeTx) Find() (result *models.ProductType, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a orderBelongsToProductTypeTx) Append(values ...*models.ProductType) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a orderBelongsToProductTypeTx) Replace(values ...*models.ProductType) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a orderBelongsToProductTypeTx) Delete(values ...*models.ProductType) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a orderBelongsToProductTypeTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a orderBelongsToProductTypeTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type orderBelongsToCustomer struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a orderBelongsToCustomer) Where(conds ...field.Expr) *orderBelongsToCustomer {
|
|
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 orderBelongsToCustomer) WithContext(ctx context.Context) *orderBelongsToCustomer {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a orderBelongsToCustomer) Session(session *gorm.Session) *orderBelongsToCustomer {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a orderBelongsToCustomer) Model(m *models.Order) *orderBelongsToCustomerTx {
|
|
return &orderBelongsToCustomerTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type orderBelongsToCustomerTx struct{ tx *gorm.Association }
|
|
|
|
func (a orderBelongsToCustomerTx) Find() (result *models.Customer, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a orderBelongsToCustomerTx) Append(values ...*models.Customer) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a orderBelongsToCustomerTx) Replace(values ...*models.Customer) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a orderBelongsToCustomerTx) Delete(values ...*models.Customer) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a orderBelongsToCustomerTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a orderBelongsToCustomerTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type orderDo struct{ gen.DO }
|
|
|
|
type IOrderDo interface {
|
|
gen.SubQuery
|
|
Debug() IOrderDo
|
|
WithContext(ctx context.Context) IOrderDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IOrderDo
|
|
WriteDB() IOrderDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IOrderDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IOrderDo
|
|
Not(conds ...gen.Condition) IOrderDo
|
|
Or(conds ...gen.Condition) IOrderDo
|
|
Select(conds ...field.Expr) IOrderDo
|
|
Where(conds ...gen.Condition) IOrderDo
|
|
Order(conds ...field.Expr) IOrderDo
|
|
Distinct(cols ...field.Expr) IOrderDo
|
|
Omit(cols ...field.Expr) IOrderDo
|
|
Join(table schema.Tabler, on ...field.Expr) IOrderDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IOrderDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IOrderDo
|
|
Group(cols ...field.Expr) IOrderDo
|
|
Having(conds ...gen.Condition) IOrderDo
|
|
Limit(limit int) IOrderDo
|
|
Offset(offset int) IOrderDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IOrderDo
|
|
Unscoped() IOrderDo
|
|
Create(values ...*models.Order) error
|
|
CreateInBatches(values []*models.Order, batchSize int) error
|
|
Save(values ...*models.Order) error
|
|
First() (*models.Order, error)
|
|
Take() (*models.Order, error)
|
|
Last() (*models.Order, error)
|
|
Find() ([]*models.Order, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Order, err error)
|
|
FindInBatches(result *[]*models.Order, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*models.Order) (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) IOrderDo
|
|
Assign(attrs ...field.AssignExpr) IOrderDo
|
|
Joins(fields ...field.RelationField) IOrderDo
|
|
Preload(fields ...field.RelationField) IOrderDo
|
|
FirstOrInit() (*models.Order, error)
|
|
FirstOrCreate() (*models.Order, error)
|
|
FindByPage(offset int, limit int) (result []*models.Order, 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) IOrderDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (o orderDo) Debug() IOrderDo {
|
|
return o.withDO(o.DO.Debug())
|
|
}
|
|
|
|
func (o orderDo) WithContext(ctx context.Context) IOrderDo {
|
|
return o.withDO(o.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (o orderDo) ReadDB() IOrderDo {
|
|
return o.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (o orderDo) WriteDB() IOrderDo {
|
|
return o.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (o orderDo) Session(config *gorm.Session) IOrderDo {
|
|
return o.withDO(o.DO.Session(config))
|
|
}
|
|
|
|
func (o orderDo) Clauses(conds ...clause.Expression) IOrderDo {
|
|
return o.withDO(o.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (o orderDo) Returning(value interface{}, columns ...string) IOrderDo {
|
|
return o.withDO(o.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (o orderDo) Not(conds ...gen.Condition) IOrderDo {
|
|
return o.withDO(o.DO.Not(conds...))
|
|
}
|
|
|
|
func (o orderDo) Or(conds ...gen.Condition) IOrderDo {
|
|
return o.withDO(o.DO.Or(conds...))
|
|
}
|
|
|
|
func (o orderDo) Select(conds ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.Select(conds...))
|
|
}
|
|
|
|
func (o orderDo) Where(conds ...gen.Condition) IOrderDo {
|
|
return o.withDO(o.DO.Where(conds...))
|
|
}
|
|
|
|
func (o orderDo) Order(conds ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.Order(conds...))
|
|
}
|
|
|
|
func (o orderDo) Distinct(cols ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (o orderDo) Omit(cols ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.Omit(cols...))
|
|
}
|
|
|
|
func (o orderDo) Join(table schema.Tabler, on ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.Join(table, on...))
|
|
}
|
|
|
|
func (o orderDo) LeftJoin(table schema.Tabler, on ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (o orderDo) RightJoin(table schema.Tabler, on ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (o orderDo) Group(cols ...field.Expr) IOrderDo {
|
|
return o.withDO(o.DO.Group(cols...))
|
|
}
|
|
|
|
func (o orderDo) Having(conds ...gen.Condition) IOrderDo {
|
|
return o.withDO(o.DO.Having(conds...))
|
|
}
|
|
|
|
func (o orderDo) Limit(limit int) IOrderDo {
|
|
return o.withDO(o.DO.Limit(limit))
|
|
}
|
|
|
|
func (o orderDo) Offset(offset int) IOrderDo {
|
|
return o.withDO(o.DO.Offset(offset))
|
|
}
|
|
|
|
func (o orderDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IOrderDo {
|
|
return o.withDO(o.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (o orderDo) Unscoped() IOrderDo {
|
|
return o.withDO(o.DO.Unscoped())
|
|
}
|
|
|
|
func (o orderDo) Create(values ...*models.Order) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return o.DO.Create(values)
|
|
}
|
|
|
|
func (o orderDo) CreateInBatches(values []*models.Order, 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 orderDo) Save(values ...*models.Order) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return o.DO.Save(values)
|
|
}
|
|
|
|
func (o orderDo) First() (*models.Order, error) {
|
|
if result, err := o.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Order), nil
|
|
}
|
|
}
|
|
|
|
func (o orderDo) Take() (*models.Order, error) {
|
|
if result, err := o.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Order), nil
|
|
}
|
|
}
|
|
|
|
func (o orderDo) Last() (*models.Order, error) {
|
|
if result, err := o.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Order), nil
|
|
}
|
|
}
|
|
|
|
func (o orderDo) Find() ([]*models.Order, error) {
|
|
result, err := o.DO.Find()
|
|
return result.([]*models.Order), err
|
|
}
|
|
|
|
func (o orderDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Order, err error) {
|
|
buf := make([]*models.Order, 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 orderDo) FindInBatches(result *[]*models.Order, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return o.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (o orderDo) Attrs(attrs ...field.AssignExpr) IOrderDo {
|
|
return o.withDO(o.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (o orderDo) Assign(attrs ...field.AssignExpr) IOrderDo {
|
|
return o.withDO(o.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (o orderDo) Joins(fields ...field.RelationField) IOrderDo {
|
|
for _, _f := range fields {
|
|
o = *o.withDO(o.DO.Joins(_f))
|
|
}
|
|
return &o
|
|
}
|
|
|
|
func (o orderDo) Preload(fields ...field.RelationField) IOrderDo {
|
|
for _, _f := range fields {
|
|
o = *o.withDO(o.DO.Preload(_f))
|
|
}
|
|
return &o
|
|
}
|
|
|
|
func (o orderDo) FirstOrInit() (*models.Order, error) {
|
|
if result, err := o.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Order), nil
|
|
}
|
|
}
|
|
|
|
func (o orderDo) FirstOrCreate() (*models.Order, error) {
|
|
if result, err := o.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Order), nil
|
|
}
|
|
}
|
|
|
|
func (o orderDo) FindByPage(offset int, limit int) (result []*models.Order, 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 orderDo) 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 orderDo) Scan(result interface{}) (err error) {
|
|
return o.DO.Scan(result)
|
|
}
|
|
|
|
func (o orderDo) Delete(models ...*models.Order) (result gen.ResultInfo, err error) {
|
|
return o.DO.Delete(models)
|
|
}
|
|
|
|
func (o *orderDo) withDO(do gen.Dao) *orderDo {
|
|
o.DO = *do.(*gen.DO)
|
|
return o
|
|
}
|