// 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 newWorkArea(db *gorm.DB, opts ...gen.DOOption) workArea {
	_workArea := workArea{}

	_workArea.workAreaDo.UseDB(db, opts...)
	_workArea.workAreaDo.UseModel(&models.WorkArea{})

	tableName := _workArea.workAreaDo.TableName()
	_workArea.ALL = field.NewAsterisk(tableName)
	_workArea.Id = field.NewUint(tableName, "id")
	_workArea.Name = field.NewString(tableName, "name")
	_workArea.Description = field.NewString(tableName, "description")
	_workArea.Performance = field.NewUint(tableName, "performance")
	_workArea.WorkshopId = field.NewUint(tableName, "workshop_id")
	_workArea.PrepTasks = workAreaHasManyPrepTasks{
		db: db.Session(&gorm.Session{}),

		RelationField: field.NewRelation("PrepTasks", "models.PrepTask"),
		Task: struct {
			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
			}
			Workshops struct {
				field.RelationField
				WorkAreas struct {
					field.RelationField
					Workshop struct {
						field.RelationField
					}
					PrepTasks struct {
						field.RelationField
					}
					Shifts struct {
						field.RelationField
						ProductType struct {
							field.RelationField
						}
						WorkArea struct {
							field.RelationField
						}
					}
					TeamTasks struct {
						field.RelationField
						TeamType struct {
							field.RelationField
						}
						TeamLeader struct {
							field.RelationField
							Workshop struct {
								field.RelationField
							}
							TeamTasks struct {
								field.RelationField
							}
						}
						WorkArea struct {
							field.RelationField
						}
						TeamMembers struct {
							field.RelationField
						}
					}
				}
				Workers struct {
					field.RelationField
				}
				Tasks struct {
					field.RelationField
				}
			}
		}{
			RelationField: field.NewRelation("PrepTasks.Task", "models.Task"),
			ProductType: struct {
				field.RelationField
			}{
				RelationField: field.NewRelation("PrepTasks.Task.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("PrepTasks.Task.Order", "models.Order"),
				ProductType: struct {
					field.RelationField
				}{
					RelationField: field.NewRelation("PrepTasks.Task.Order.ProductType", "models.ProductType"),
				},
				Customer: struct {
					field.RelationField
					Orders struct {
						field.RelationField
					}
				}{
					RelationField: field.NewRelation("PrepTasks.Task.Order.Customer", "models.Customer"),
					Orders: struct {
						field.RelationField
					}{
						RelationField: field.NewRelation("PrepTasks.Task.Order.Customer.Orders", "models.Order"),
					},
				},
				Tasks: struct {
					field.RelationField
				}{
					RelationField: field.NewRelation("PrepTasks.Task.Order.Tasks", "models.Task"),
				},
			},
			PrepTasks: struct {
				field.RelationField
			}{
				RelationField: field.NewRelation("PrepTasks.Task.PrepTasks", "models.PrepTask"),
			},
			Workshops: struct {
				field.RelationField
				WorkAreas struct {
					field.RelationField
					Workshop struct {
						field.RelationField
					}
					PrepTasks struct {
						field.RelationField
					}
					Shifts struct {
						field.RelationField
						ProductType struct {
							field.RelationField
						}
						WorkArea struct {
							field.RelationField
						}
					}
					TeamTasks struct {
						field.RelationField
						TeamType struct {
							field.RelationField
						}
						TeamLeader struct {
							field.RelationField
							Workshop struct {
								field.RelationField
							}
							TeamTasks struct {
								field.RelationField
							}
						}
						WorkArea struct {
							field.RelationField
						}
						TeamMembers struct {
							field.RelationField
						}
					}
				}
				Workers struct {
					field.RelationField
				}
				Tasks struct {
					field.RelationField
				}
			}{
				RelationField: field.NewRelation("PrepTasks.Task.Workshops", "models.Workshop"),
				WorkAreas: struct {
					field.RelationField
					Workshop struct {
						field.RelationField
					}
					PrepTasks struct {
						field.RelationField
					}
					Shifts struct {
						field.RelationField
						ProductType struct {
							field.RelationField
						}
						WorkArea struct {
							field.RelationField
						}
					}
					TeamTasks struct {
						field.RelationField
						TeamType struct {
							field.RelationField
						}
						TeamLeader struct {
							field.RelationField
							Workshop struct {
								field.RelationField
							}
							TeamTasks struct {
								field.RelationField
							}
						}
						WorkArea struct {
							field.RelationField
						}
						TeamMembers struct {
							field.RelationField
						}
					}
				}{
					RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas", "models.WorkArea"),
					Workshop: struct {
						field.RelationField
					}{
						RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.Workshop", "models.Workshop"),
					},
					PrepTasks: struct {
						field.RelationField
					}{
						RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.PrepTasks", "models.PrepTask"),
					},
					Shifts: struct {
						field.RelationField
						ProductType struct {
							field.RelationField
						}
						WorkArea struct {
							field.RelationField
						}
					}{
						RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.Shifts", "models.Shift"),
						ProductType: struct {
							field.RelationField
						}{
							RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.Shifts.ProductType", "models.ProductType"),
						},
						WorkArea: struct {
							field.RelationField
						}{
							RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.Shifts.WorkArea", "models.WorkArea"),
						},
					},
					TeamTasks: struct {
						field.RelationField
						TeamType struct {
							field.RelationField
						}
						TeamLeader struct {
							field.RelationField
							Workshop struct {
								field.RelationField
							}
							TeamTasks struct {
								field.RelationField
							}
						}
						WorkArea struct {
							field.RelationField
						}
						TeamMembers struct {
							field.RelationField
						}
					}{
						RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks", "models.TeamTask"),
						TeamType: struct {
							field.RelationField
						}{
							RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks.TeamType", "models.TeamType"),
						},
						TeamLeader: struct {
							field.RelationField
							Workshop struct {
								field.RelationField
							}
							TeamTasks struct {
								field.RelationField
							}
						}{
							RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks.TeamLeader", "models.Worker"),
							Workshop: struct {
								field.RelationField
							}{
								RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks.TeamLeader.Workshop", "models.Workshop"),
							},
							TeamTasks: struct {
								field.RelationField
							}{
								RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks.TeamLeader.TeamTasks", "models.TeamTask"),
							},
						},
						WorkArea: struct {
							field.RelationField
						}{
							RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks.WorkArea", "models.WorkArea"),
						},
						TeamMembers: struct {
							field.RelationField
						}{
							RelationField: field.NewRelation("PrepTasks.Task.Workshops.WorkAreas.TeamTasks.TeamMembers", "models.Worker"),
						},
					},
				},
				Workers: struct {
					field.RelationField
				}{
					RelationField: field.NewRelation("PrepTasks.Task.Workshops.Workers", "models.Worker"),
				},
				Tasks: struct {
					field.RelationField
				}{
					RelationField: field.NewRelation("PrepTasks.Task.Workshops.Tasks", "models.Task"),
				},
			},
		},
		WorkArea: struct {
			field.RelationField
		}{
			RelationField: field.NewRelation("PrepTasks.WorkArea", "models.WorkArea"),
		},
	}

	_workArea.Shifts = workAreaHasManyShifts{
		db: db.Session(&gorm.Session{}),

		RelationField: field.NewRelation("Shifts", "models.Shift"),
	}

	_workArea.TeamTasks = workAreaHasManyTeamTasks{
		db: db.Session(&gorm.Session{}),

		RelationField: field.NewRelation("TeamTasks", "models.TeamTask"),
	}

	_workArea.Workshop = workAreaBelongsToWorkshop{
		db: db.Session(&gorm.Session{}),

		RelationField: field.NewRelation("Workshop", "models.Workshop"),
	}

	_workArea.fillFieldMap()

	return _workArea
}

type workArea struct {
	workAreaDo

	ALL         field.Asterisk
	Id          field.Uint
	Name        field.String
	Description field.String
	Performance field.Uint
	WorkshopId  field.Uint
	PrepTasks   workAreaHasManyPrepTasks

	Shifts workAreaHasManyShifts

	TeamTasks workAreaHasManyTeamTasks

	Workshop workAreaBelongsToWorkshop

	fieldMap map[string]field.Expr
}

func (w workArea) Table(newTableName string) *workArea {
	w.workAreaDo.UseTable(newTableName)
	return w.updateTableName(newTableName)
}

func (w workArea) As(alias string) *workArea {
	w.workAreaDo.DO = *(w.workAreaDo.As(alias).(*gen.DO))
	return w.updateTableName(alias)
}

func (w *workArea) updateTableName(table string) *workArea {
	w.ALL = field.NewAsterisk(table)
	w.Id = field.NewUint(table, "id")
	w.Name = field.NewString(table, "name")
	w.Description = field.NewString(table, "description")
	w.Performance = field.NewUint(table, "performance")
	w.WorkshopId = field.NewUint(table, "workshop_id")

	w.fillFieldMap()

	return w
}

func (w *workArea) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
	_f, ok := w.fieldMap[fieldName]
	if !ok || _f == nil {
		return nil, false
	}
	_oe, ok := _f.(field.OrderExpr)
	return _oe, ok
}

func (w *workArea) fillFieldMap() {
	w.fieldMap = make(map[string]field.Expr, 9)
	w.fieldMap["id"] = w.Id
	w.fieldMap["name"] = w.Name
	w.fieldMap["description"] = w.Description
	w.fieldMap["performance"] = w.Performance
	w.fieldMap["workshop_id"] = w.WorkshopId

}

func (w workArea) clone(db *gorm.DB) workArea {
	w.workAreaDo.ReplaceConnPool(db.Statement.ConnPool)
	return w
}

func (w workArea) replaceDB(db *gorm.DB) workArea {
	w.workAreaDo.ReplaceDB(db)
	return w
}

type workAreaHasManyPrepTasks struct {
	db *gorm.DB

	field.RelationField

	Task struct {
		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
		}
		Workshops struct {
			field.RelationField
			WorkAreas struct {
				field.RelationField
				Workshop struct {
					field.RelationField
				}
				PrepTasks struct {
					field.RelationField
				}
				Shifts struct {
					field.RelationField
					ProductType struct {
						field.RelationField
					}
					WorkArea struct {
						field.RelationField
					}
				}
				TeamTasks struct {
					field.RelationField
					TeamType struct {
						field.RelationField
					}
					TeamLeader struct {
						field.RelationField
						Workshop struct {
							field.RelationField
						}
						TeamTasks struct {
							field.RelationField
						}
					}
					WorkArea struct {
						field.RelationField
					}
					TeamMembers struct {
						field.RelationField
					}
				}
			}
			Workers struct {
				field.RelationField
			}
			Tasks struct {
				field.RelationField
			}
		}
	}
	WorkArea struct {
		field.RelationField
	}
}

func (a workAreaHasManyPrepTasks) Where(conds ...field.Expr) *workAreaHasManyPrepTasks {
	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 workAreaHasManyPrepTasks) WithContext(ctx context.Context) *workAreaHasManyPrepTasks {
	a.db = a.db.WithContext(ctx)
	return &a
}

func (a workAreaHasManyPrepTasks) Session(session *gorm.Session) *workAreaHasManyPrepTasks {
	a.db = a.db.Session(session)
	return &a
}

func (a workAreaHasManyPrepTasks) Model(m *models.WorkArea) *workAreaHasManyPrepTasksTx {
	return &workAreaHasManyPrepTasksTx{a.db.Model(m).Association(a.Name())}
}

type workAreaHasManyPrepTasksTx struct{ tx *gorm.Association }

func (a workAreaHasManyPrepTasksTx) Find() (result []*models.PrepTask, err error) {
	return result, a.tx.Find(&result)
}

func (a workAreaHasManyPrepTasksTx) Append(values ...*models.PrepTask) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Append(targetValues...)
}

func (a workAreaHasManyPrepTasksTx) Replace(values ...*models.PrepTask) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Replace(targetValues...)
}

func (a workAreaHasManyPrepTasksTx) Delete(values ...*models.PrepTask) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Delete(targetValues...)
}

func (a workAreaHasManyPrepTasksTx) Clear() error {
	return a.tx.Clear()
}

func (a workAreaHasManyPrepTasksTx) Count() int64 {
	return a.tx.Count()
}

type workAreaHasManyShifts struct {
	db *gorm.DB

	field.RelationField
}

func (a workAreaHasManyShifts) Where(conds ...field.Expr) *workAreaHasManyShifts {
	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 workAreaHasManyShifts) WithContext(ctx context.Context) *workAreaHasManyShifts {
	a.db = a.db.WithContext(ctx)
	return &a
}

func (a workAreaHasManyShifts) Session(session *gorm.Session) *workAreaHasManyShifts {
	a.db = a.db.Session(session)
	return &a
}

func (a workAreaHasManyShifts) Model(m *models.WorkArea) *workAreaHasManyShiftsTx {
	return &workAreaHasManyShiftsTx{a.db.Model(m).Association(a.Name())}
}

type workAreaHasManyShiftsTx struct{ tx *gorm.Association }

func (a workAreaHasManyShiftsTx) Find() (result []*models.Shift, err error) {
	return result, a.tx.Find(&result)
}

func (a workAreaHasManyShiftsTx) Append(values ...*models.Shift) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Append(targetValues...)
}

func (a workAreaHasManyShiftsTx) Replace(values ...*models.Shift) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Replace(targetValues...)
}

func (a workAreaHasManyShiftsTx) Delete(values ...*models.Shift) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Delete(targetValues...)
}

func (a workAreaHasManyShiftsTx) Clear() error {
	return a.tx.Clear()
}

func (a workAreaHasManyShiftsTx) Count() int64 {
	return a.tx.Count()
}

type workAreaHasManyTeamTasks struct {
	db *gorm.DB

	field.RelationField
}

func (a workAreaHasManyTeamTasks) Where(conds ...field.Expr) *workAreaHasManyTeamTasks {
	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 workAreaHasManyTeamTasks) WithContext(ctx context.Context) *workAreaHasManyTeamTasks {
	a.db = a.db.WithContext(ctx)
	return &a
}

func (a workAreaHasManyTeamTasks) Session(session *gorm.Session) *workAreaHasManyTeamTasks {
	a.db = a.db.Session(session)
	return &a
}

func (a workAreaHasManyTeamTasks) Model(m *models.WorkArea) *workAreaHasManyTeamTasksTx {
	return &workAreaHasManyTeamTasksTx{a.db.Model(m).Association(a.Name())}
}

type workAreaHasManyTeamTasksTx struct{ tx *gorm.Association }

func (a workAreaHasManyTeamTasksTx) Find() (result []*models.TeamTask, err error) {
	return result, a.tx.Find(&result)
}

func (a workAreaHasManyTeamTasksTx) Append(values ...*models.TeamTask) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Append(targetValues...)
}

func (a workAreaHasManyTeamTasksTx) Replace(values ...*models.TeamTask) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Replace(targetValues...)
}

func (a workAreaHasManyTeamTasksTx) Delete(values ...*models.TeamTask) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Delete(targetValues...)
}

func (a workAreaHasManyTeamTasksTx) Clear() error {
	return a.tx.Clear()
}

func (a workAreaHasManyTeamTasksTx) Count() int64 {
	return a.tx.Count()
}

type workAreaBelongsToWorkshop struct {
	db *gorm.DB

	field.RelationField
}

func (a workAreaBelongsToWorkshop) Where(conds ...field.Expr) *workAreaBelongsToWorkshop {
	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 workAreaBelongsToWorkshop) WithContext(ctx context.Context) *workAreaBelongsToWorkshop {
	a.db = a.db.WithContext(ctx)
	return &a
}

func (a workAreaBelongsToWorkshop) Session(session *gorm.Session) *workAreaBelongsToWorkshop {
	a.db = a.db.Session(session)
	return &a
}

func (a workAreaBelongsToWorkshop) Model(m *models.WorkArea) *workAreaBelongsToWorkshopTx {
	return &workAreaBelongsToWorkshopTx{a.db.Model(m).Association(a.Name())}
}

type workAreaBelongsToWorkshopTx struct{ tx *gorm.Association }

func (a workAreaBelongsToWorkshopTx) Find() (result *models.Workshop, err error) {
	return result, a.tx.Find(&result)
}

func (a workAreaBelongsToWorkshopTx) Append(values ...*models.Workshop) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Append(targetValues...)
}

func (a workAreaBelongsToWorkshopTx) Replace(values ...*models.Workshop) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Replace(targetValues...)
}

func (a workAreaBelongsToWorkshopTx) Delete(values ...*models.Workshop) (err error) {
	targetValues := make([]interface{}, len(values))
	for i, v := range values {
		targetValues[i] = v
	}
	return a.tx.Delete(targetValues...)
}

func (a workAreaBelongsToWorkshopTx) Clear() error {
	return a.tx.Clear()
}

func (a workAreaBelongsToWorkshopTx) Count() int64 {
	return a.tx.Count()
}

type workAreaDo struct{ gen.DO }

type IWorkAreaDo interface {
	gen.SubQuery
	Debug() IWorkAreaDo
	WithContext(ctx context.Context) IWorkAreaDo
	WithResult(fc func(tx gen.Dao)) gen.ResultInfo
	ReplaceDB(db *gorm.DB)
	ReadDB() IWorkAreaDo
	WriteDB() IWorkAreaDo
	As(alias string) gen.Dao
	Session(config *gorm.Session) IWorkAreaDo
	Columns(cols ...field.Expr) gen.Columns
	Clauses(conds ...clause.Expression) IWorkAreaDo
	Not(conds ...gen.Condition) IWorkAreaDo
	Or(conds ...gen.Condition) IWorkAreaDo
	Select(conds ...field.Expr) IWorkAreaDo
	Where(conds ...gen.Condition) IWorkAreaDo
	Order(conds ...field.Expr) IWorkAreaDo
	Distinct(cols ...field.Expr) IWorkAreaDo
	Omit(cols ...field.Expr) IWorkAreaDo
	Join(table schema.Tabler, on ...field.Expr) IWorkAreaDo
	LeftJoin(table schema.Tabler, on ...field.Expr) IWorkAreaDo
	RightJoin(table schema.Tabler, on ...field.Expr) IWorkAreaDo
	Group(cols ...field.Expr) IWorkAreaDo
	Having(conds ...gen.Condition) IWorkAreaDo
	Limit(limit int) IWorkAreaDo
	Offset(offset int) IWorkAreaDo
	Count() (count int64, err error)
	Scopes(funcs ...func(gen.Dao) gen.Dao) IWorkAreaDo
	Unscoped() IWorkAreaDo
	Create(values ...*models.WorkArea) error
	CreateInBatches(values []*models.WorkArea, batchSize int) error
	Save(values ...*models.WorkArea) error
	First() (*models.WorkArea, error)
	Take() (*models.WorkArea, error)
	Last() (*models.WorkArea, error)
	Find() ([]*models.WorkArea, error)
	FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.WorkArea, err error)
	FindInBatches(result *[]*models.WorkArea, batchSize int, fc func(tx gen.Dao, batch int) error) error
	Pluck(column field.Expr, dest interface{}) error
	Delete(...*models.WorkArea) (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) IWorkAreaDo
	Assign(attrs ...field.AssignExpr) IWorkAreaDo
	Joins(fields ...field.RelationField) IWorkAreaDo
	Preload(fields ...field.RelationField) IWorkAreaDo
	FirstOrInit() (*models.WorkArea, error)
	FirstOrCreate() (*models.WorkArea, error)
	FindByPage(offset int, limit int) (result []*models.WorkArea, 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) IWorkAreaDo
	UnderlyingDB() *gorm.DB
	schema.Tabler
}

func (w workAreaDo) Debug() IWorkAreaDo {
	return w.withDO(w.DO.Debug())
}

func (w workAreaDo) WithContext(ctx context.Context) IWorkAreaDo {
	return w.withDO(w.DO.WithContext(ctx))
}

func (w workAreaDo) ReadDB() IWorkAreaDo {
	return w.Clauses(dbresolver.Read)
}

func (w workAreaDo) WriteDB() IWorkAreaDo {
	return w.Clauses(dbresolver.Write)
}

func (w workAreaDo) Session(config *gorm.Session) IWorkAreaDo {
	return w.withDO(w.DO.Session(config))
}

func (w workAreaDo) Clauses(conds ...clause.Expression) IWorkAreaDo {
	return w.withDO(w.DO.Clauses(conds...))
}

func (w workAreaDo) Returning(value interface{}, columns ...string) IWorkAreaDo {
	return w.withDO(w.DO.Returning(value, columns...))
}

func (w workAreaDo) Not(conds ...gen.Condition) IWorkAreaDo {
	return w.withDO(w.DO.Not(conds...))
}

func (w workAreaDo) Or(conds ...gen.Condition) IWorkAreaDo {
	return w.withDO(w.DO.Or(conds...))
}

func (w workAreaDo) Select(conds ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.Select(conds...))
}

func (w workAreaDo) Where(conds ...gen.Condition) IWorkAreaDo {
	return w.withDO(w.DO.Where(conds...))
}

func (w workAreaDo) Order(conds ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.Order(conds...))
}

func (w workAreaDo) Distinct(cols ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.Distinct(cols...))
}

func (w workAreaDo) Omit(cols ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.Omit(cols...))
}

func (w workAreaDo) Join(table schema.Tabler, on ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.Join(table, on...))
}

func (w workAreaDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.LeftJoin(table, on...))
}

func (w workAreaDo) RightJoin(table schema.Tabler, on ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.RightJoin(table, on...))
}

func (w workAreaDo) Group(cols ...field.Expr) IWorkAreaDo {
	return w.withDO(w.DO.Group(cols...))
}

func (w workAreaDo) Having(conds ...gen.Condition) IWorkAreaDo {
	return w.withDO(w.DO.Having(conds...))
}

func (w workAreaDo) Limit(limit int) IWorkAreaDo {
	return w.withDO(w.DO.Limit(limit))
}

func (w workAreaDo) Offset(offset int) IWorkAreaDo {
	return w.withDO(w.DO.Offset(offset))
}

func (w workAreaDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWorkAreaDo {
	return w.withDO(w.DO.Scopes(funcs...))
}

func (w workAreaDo) Unscoped() IWorkAreaDo {
	return w.withDO(w.DO.Unscoped())
}

func (w workAreaDo) Create(values ...*models.WorkArea) error {
	if len(values) == 0 {
		return nil
	}
	return w.DO.Create(values)
}

func (w workAreaDo) CreateInBatches(values []*models.WorkArea, batchSize int) error {
	return w.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 (w workAreaDo) Save(values ...*models.WorkArea) error {
	if len(values) == 0 {
		return nil
	}
	return w.DO.Save(values)
}

func (w workAreaDo) First() (*models.WorkArea, error) {
	if result, err := w.DO.First(); err != nil {
		return nil, err
	} else {
		return result.(*models.WorkArea), nil
	}
}

func (w workAreaDo) Take() (*models.WorkArea, error) {
	if result, err := w.DO.Take(); err != nil {
		return nil, err
	} else {
		return result.(*models.WorkArea), nil
	}
}

func (w workAreaDo) Last() (*models.WorkArea, error) {
	if result, err := w.DO.Last(); err != nil {
		return nil, err
	} else {
		return result.(*models.WorkArea), nil
	}
}

func (w workAreaDo) Find() ([]*models.WorkArea, error) {
	result, err := w.DO.Find()
	return result.([]*models.WorkArea), err
}

func (w workAreaDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.WorkArea, err error) {
	buf := make([]*models.WorkArea, 0, batchSize)
	err = w.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 (w workAreaDo) FindInBatches(result *[]*models.WorkArea, batchSize int, fc func(tx gen.Dao, batch int) error) error {
	return w.DO.FindInBatches(result, batchSize, fc)
}

func (w workAreaDo) Attrs(attrs ...field.AssignExpr) IWorkAreaDo {
	return w.withDO(w.DO.Attrs(attrs...))
}

func (w workAreaDo) Assign(attrs ...field.AssignExpr) IWorkAreaDo {
	return w.withDO(w.DO.Assign(attrs...))
}

func (w workAreaDo) Joins(fields ...field.RelationField) IWorkAreaDo {
	for _, _f := range fields {
		w = *w.withDO(w.DO.Joins(_f))
	}
	return &w
}

func (w workAreaDo) Preload(fields ...field.RelationField) IWorkAreaDo {
	for _, _f := range fields {
		w = *w.withDO(w.DO.Preload(_f))
	}
	return &w
}

func (w workAreaDo) FirstOrInit() (*models.WorkArea, error) {
	if result, err := w.DO.FirstOrInit(); err != nil {
		return nil, err
	} else {
		return result.(*models.WorkArea), nil
	}
}

func (w workAreaDo) FirstOrCreate() (*models.WorkArea, error) {
	if result, err := w.DO.FirstOrCreate(); err != nil {
		return nil, err
	} else {
		return result.(*models.WorkArea), nil
	}
}

func (w workAreaDo) FindByPage(offset int, limit int) (result []*models.WorkArea, count int64, err error) {
	result, err = w.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 = w.Offset(-1).Limit(-1).Count()
	return
}

func (w workAreaDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
	count, err = w.Count()
	if err != nil {
		return
	}

	err = w.Offset(offset).Limit(limit).Scan(result)
	return
}

func (w workAreaDo) Scan(result interface{}) (err error) {
	return w.DO.Scan(result)
}

func (w workAreaDo) Delete(models ...*models.WorkArea) (result gen.ResultInfo, err error) {
	return w.DO.Delete(models)
}

func (w *workAreaDo) withDO(do gen.Dao) *workAreaDo {
	w.DO = *do.(*gen.DO)
	return w
}
