1371 lines
41 KiB
Go
1371 lines
41 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"online-order/ent/business"
|
|
"online-order/ent/businesscategory"
|
|
"online-order/ent/businessconfig"
|
|
"online-order/ent/domain"
|
|
"online-order/ent/predicate"
|
|
"online-order/ent/product"
|
|
"online-order/ent/productcategory"
|
|
"online-order/ent/user"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// BusinessUpdate is the builder for updating Business entities.
|
|
type BusinessUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *BusinessMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the BusinessUpdate builder.
|
|
func (bu *BusinessUpdate) Where(ps ...predicate.Business) *BusinessUpdate {
|
|
bu.mutation.Where(ps...)
|
|
return bu
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (bu *BusinessUpdate) SetName(s string) *BusinessUpdate {
|
|
bu.mutation.SetName(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableName(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetName(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetSlug sets the "slug" field.
|
|
func (bu *BusinessUpdate) SetSlug(s string) *BusinessUpdate {
|
|
bu.mutation.SetSlug(s)
|
|
return bu
|
|
}
|
|
|
|
// SetBotID sets the "bot_id" field.
|
|
func (bu *BusinessUpdate) SetBotID(s string) *BusinessUpdate {
|
|
bu.mutation.SetBotID(s)
|
|
return bu
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (bu *BusinessUpdate) SetDescription(s string) *BusinessUpdate {
|
|
bu.mutation.SetDescription(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableDescription(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetDescription(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (bu *BusinessUpdate) ClearDescription() *BusinessUpdate {
|
|
bu.mutation.ClearDescription()
|
|
return bu
|
|
}
|
|
|
|
// SetAboutUs sets the "about_us" field.
|
|
func (bu *BusinessUpdate) SetAboutUs(s string) *BusinessUpdate {
|
|
bu.mutation.SetAboutUs(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableAboutUs sets the "about_us" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableAboutUs(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetAboutUs(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// ClearAboutUs clears the value of the "about_us" field.
|
|
func (bu *BusinessUpdate) ClearAboutUs() *BusinessUpdate {
|
|
bu.mutation.ClearAboutUs()
|
|
return bu
|
|
}
|
|
|
|
// SetBusinessCategoryID sets the "business_category_id" field.
|
|
func (bu *BusinessUpdate) SetBusinessCategoryID(i int) *BusinessUpdate {
|
|
bu.mutation.SetBusinessCategoryID(i)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableBusinessCategoryID sets the "business_category_id" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableBusinessCategoryID(i *int) *BusinessUpdate {
|
|
if i != nil {
|
|
bu.SetBusinessCategoryID(*i)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// ClearBusinessCategoryID clears the value of the "business_category_id" field.
|
|
func (bu *BusinessUpdate) ClearBusinessCategoryID() *BusinessUpdate {
|
|
bu.mutation.ClearBusinessCategoryID()
|
|
return bu
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (bu *BusinessUpdate) SetUserID(i int) *BusinessUpdate {
|
|
bu.mutation.SetUserID(i)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableUserID(i *int) *BusinessUpdate {
|
|
if i != nil {
|
|
bu.SetUserID(*i)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (bu *BusinessUpdate) ClearUserID() *BusinessUpdate {
|
|
bu.mutation.ClearUserID()
|
|
return bu
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (bu *BusinessUpdate) SetCreatedAt(t time.Time) *BusinessUpdate {
|
|
bu.mutation.SetCreatedAt(t)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableCreatedAt(t *time.Time) *BusinessUpdate {
|
|
if t != nil {
|
|
bu.SetCreatedAt(*t)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (bu *BusinessUpdate) SetUpdatedAt(t time.Time) *BusinessUpdate {
|
|
bu.mutation.SetUpdatedAt(t)
|
|
return bu
|
|
}
|
|
|
|
// SetBusinessCategoriesID sets the "business_categories" edge to the BusinessCategory entity by ID.
|
|
func (bu *BusinessUpdate) SetBusinessCategoriesID(id int) *BusinessUpdate {
|
|
bu.mutation.SetBusinessCategoriesID(id)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableBusinessCategoriesID sets the "business_categories" edge to the BusinessCategory entity by ID if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableBusinessCategoriesID(id *int) *BusinessUpdate {
|
|
if id != nil {
|
|
bu = bu.SetBusinessCategoriesID(*id)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetBusinessCategories sets the "business_categories" edge to the BusinessCategory entity.
|
|
func (bu *BusinessUpdate) SetBusinessCategories(b *BusinessCategory) *BusinessUpdate {
|
|
return bu.SetBusinessCategoriesID(b.ID)
|
|
}
|
|
|
|
// SetUsersID sets the "users" edge to the User entity by ID.
|
|
func (bu *BusinessUpdate) SetUsersID(id int) *BusinessUpdate {
|
|
bu.mutation.SetUsersID(id)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableUsersID sets the "users" edge to the User entity by ID if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableUsersID(id *int) *BusinessUpdate {
|
|
if id != nil {
|
|
bu = bu.SetUsersID(*id)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetUsers sets the "users" edge to the User entity.
|
|
func (bu *BusinessUpdate) SetUsers(u *User) *BusinessUpdate {
|
|
return bu.SetUsersID(u.ID)
|
|
}
|
|
|
|
// AddProductIDs adds the "products" edge to the Product entity by IDs.
|
|
func (bu *BusinessUpdate) AddProductIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.AddProductIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// AddProducts adds the "products" edges to the Product entity.
|
|
func (bu *BusinessUpdate) AddProducts(p ...*Product) *BusinessUpdate {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return bu.AddProductIDs(ids...)
|
|
}
|
|
|
|
// AddProductCategoryIDs adds the "product_categories" edge to the ProductCategory entity by IDs.
|
|
func (bu *BusinessUpdate) AddProductCategoryIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.AddProductCategoryIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// AddProductCategories adds the "product_categories" edges to the ProductCategory entity.
|
|
func (bu *BusinessUpdate) AddProductCategories(p ...*ProductCategory) *BusinessUpdate {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return bu.AddProductCategoryIDs(ids...)
|
|
}
|
|
|
|
// AddDomainIDs adds the "domains" edge to the Domain entity by IDs.
|
|
func (bu *BusinessUpdate) AddDomainIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.AddDomainIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// AddDomains adds the "domains" edges to the Domain entity.
|
|
func (bu *BusinessUpdate) AddDomains(d ...*Domain) *BusinessUpdate {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return bu.AddDomainIDs(ids...)
|
|
}
|
|
|
|
// AddBusinessConfigIDs adds the "business_configs" edge to the BusinessConfig entity by IDs.
|
|
func (bu *BusinessUpdate) AddBusinessConfigIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.AddBusinessConfigIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// AddBusinessConfigs adds the "business_configs" edges to the BusinessConfig entity.
|
|
func (bu *BusinessUpdate) AddBusinessConfigs(b ...*BusinessConfig) *BusinessUpdate {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return bu.AddBusinessConfigIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the BusinessMutation object of the builder.
|
|
func (bu *BusinessUpdate) Mutation() *BusinessMutation {
|
|
return bu.mutation
|
|
}
|
|
|
|
// ClearBusinessCategories clears the "business_categories" edge to the BusinessCategory entity.
|
|
func (bu *BusinessUpdate) ClearBusinessCategories() *BusinessUpdate {
|
|
bu.mutation.ClearBusinessCategories()
|
|
return bu
|
|
}
|
|
|
|
// ClearUsers clears the "users" edge to the User entity.
|
|
func (bu *BusinessUpdate) ClearUsers() *BusinessUpdate {
|
|
bu.mutation.ClearUsers()
|
|
return bu
|
|
}
|
|
|
|
// ClearProducts clears all "products" edges to the Product entity.
|
|
func (bu *BusinessUpdate) ClearProducts() *BusinessUpdate {
|
|
bu.mutation.ClearProducts()
|
|
return bu
|
|
}
|
|
|
|
// RemoveProductIDs removes the "products" edge to Product entities by IDs.
|
|
func (bu *BusinessUpdate) RemoveProductIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.RemoveProductIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// RemoveProducts removes "products" edges to Product entities.
|
|
func (bu *BusinessUpdate) RemoveProducts(p ...*Product) *BusinessUpdate {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return bu.RemoveProductIDs(ids...)
|
|
}
|
|
|
|
// ClearProductCategories clears all "product_categories" edges to the ProductCategory entity.
|
|
func (bu *BusinessUpdate) ClearProductCategories() *BusinessUpdate {
|
|
bu.mutation.ClearProductCategories()
|
|
return bu
|
|
}
|
|
|
|
// RemoveProductCategoryIDs removes the "product_categories" edge to ProductCategory entities by IDs.
|
|
func (bu *BusinessUpdate) RemoveProductCategoryIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.RemoveProductCategoryIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// RemoveProductCategories removes "product_categories" edges to ProductCategory entities.
|
|
func (bu *BusinessUpdate) RemoveProductCategories(p ...*ProductCategory) *BusinessUpdate {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return bu.RemoveProductCategoryIDs(ids...)
|
|
}
|
|
|
|
// ClearDomains clears all "domains" edges to the Domain entity.
|
|
func (bu *BusinessUpdate) ClearDomains() *BusinessUpdate {
|
|
bu.mutation.ClearDomains()
|
|
return bu
|
|
}
|
|
|
|
// RemoveDomainIDs removes the "domains" edge to Domain entities by IDs.
|
|
func (bu *BusinessUpdate) RemoveDomainIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.RemoveDomainIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// RemoveDomains removes "domains" edges to Domain entities.
|
|
func (bu *BusinessUpdate) RemoveDomains(d ...*Domain) *BusinessUpdate {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return bu.RemoveDomainIDs(ids...)
|
|
}
|
|
|
|
// ClearBusinessConfigs clears all "business_configs" edges to the BusinessConfig entity.
|
|
func (bu *BusinessUpdate) ClearBusinessConfigs() *BusinessUpdate {
|
|
bu.mutation.ClearBusinessConfigs()
|
|
return bu
|
|
}
|
|
|
|
// RemoveBusinessConfigIDs removes the "business_configs" edge to BusinessConfig entities by IDs.
|
|
func (bu *BusinessUpdate) RemoveBusinessConfigIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.RemoveBusinessConfigIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// RemoveBusinessConfigs removes "business_configs" edges to BusinessConfig entities.
|
|
func (bu *BusinessUpdate) RemoveBusinessConfigs(b ...*BusinessConfig) *BusinessUpdate {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return bu.RemoveBusinessConfigIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (bu *BusinessUpdate) Save(ctx context.Context) (int, error) {
|
|
bu.defaults()
|
|
return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (bu *BusinessUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := bu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (bu *BusinessUpdate) Exec(ctx context.Context) error {
|
|
_, err := bu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (bu *BusinessUpdate) ExecX(ctx context.Context) {
|
|
if err := bu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (bu *BusinessUpdate) defaults() {
|
|
if _, ok := bu.mutation.UpdatedAt(); !ok {
|
|
v := business.UpdateDefaultUpdatedAt()
|
|
bu.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
func (bu *BusinessUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(business.Table, business.Columns, sqlgraph.NewFieldSpec(business.FieldID, field.TypeInt))
|
|
if ps := bu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := bu.mutation.Name(); ok {
|
|
_spec.SetField(business.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.Slug(); ok {
|
|
_spec.SetField(business.FieldSlug, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.BotID(); ok {
|
|
_spec.SetField(business.FieldBotID, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.Description(); ok {
|
|
_spec.SetField(business.FieldDescription, field.TypeString, value)
|
|
}
|
|
if bu.mutation.DescriptionCleared() {
|
|
_spec.ClearField(business.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := bu.mutation.AboutUs(); ok {
|
|
_spec.SetField(business.FieldAboutUs, field.TypeString, value)
|
|
}
|
|
if bu.mutation.AboutUsCleared() {
|
|
_spec.ClearField(business.FieldAboutUs, field.TypeString)
|
|
}
|
|
if value, ok := bu.mutation.CreatedAt(); ok {
|
|
_spec.SetField(business.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := bu.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(business.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if bu.mutation.BusinessCategoriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoriesTable,
|
|
Columns: []string{business.BusinessCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.BusinessCategoriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoriesTable,
|
|
Columns: []string{business.BusinessCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if bu.mutation.UsersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.UsersTable,
|
|
Columns: []string{business.UsersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.UsersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.UsersTable,
|
|
Columns: []string{business.UsersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if bu.mutation.ProductsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductsTable,
|
|
Columns: []string{business.ProductsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.RemovedProductsIDs(); len(nodes) > 0 && !bu.mutation.ProductsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductsTable,
|
|
Columns: []string{business.ProductsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.ProductsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductsTable,
|
|
Columns: []string{business.ProductsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if bu.mutation.ProductCategoriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductCategoriesTable,
|
|
Columns: []string{business.ProductCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(productcategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.RemovedProductCategoriesIDs(); len(nodes) > 0 && !bu.mutation.ProductCategoriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductCategoriesTable,
|
|
Columns: []string{business.ProductCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(productcategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.ProductCategoriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductCategoriesTable,
|
|
Columns: []string{business.ProductCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(productcategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if bu.mutation.DomainsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.DomainsTable,
|
|
Columns: []string{business.DomainsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(domain.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.RemovedDomainsIDs(); len(nodes) > 0 && !bu.mutation.DomainsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.DomainsTable,
|
|
Columns: []string{business.DomainsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(domain.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.DomainsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.DomainsTable,
|
|
Columns: []string{business.DomainsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(domain.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if bu.mutation.BusinessConfigsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.BusinessConfigsTable,
|
|
Columns: []string{business.BusinessConfigsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.RemovedBusinessConfigsIDs(); len(nodes) > 0 && !bu.mutation.BusinessConfigsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.BusinessConfigsTable,
|
|
Columns: []string{business.BusinessConfigsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.BusinessConfigsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.BusinessConfigsTable,
|
|
Columns: []string{business.BusinessConfigsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{business.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
bu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// BusinessUpdateOne is the builder for updating a single Business entity.
|
|
type BusinessUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *BusinessMutation
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (buo *BusinessUpdateOne) SetName(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetName(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableName(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetName(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetSlug sets the "slug" field.
|
|
func (buo *BusinessUpdateOne) SetSlug(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetSlug(s)
|
|
return buo
|
|
}
|
|
|
|
// SetBotID sets the "bot_id" field.
|
|
func (buo *BusinessUpdateOne) SetBotID(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetBotID(s)
|
|
return buo
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (buo *BusinessUpdateOne) SetDescription(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetDescription(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableDescription(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetDescription(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (buo *BusinessUpdateOne) ClearDescription() *BusinessUpdateOne {
|
|
buo.mutation.ClearDescription()
|
|
return buo
|
|
}
|
|
|
|
// SetAboutUs sets the "about_us" field.
|
|
func (buo *BusinessUpdateOne) SetAboutUs(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetAboutUs(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableAboutUs sets the "about_us" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableAboutUs(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetAboutUs(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// ClearAboutUs clears the value of the "about_us" field.
|
|
func (buo *BusinessUpdateOne) ClearAboutUs() *BusinessUpdateOne {
|
|
buo.mutation.ClearAboutUs()
|
|
return buo
|
|
}
|
|
|
|
// SetBusinessCategoryID sets the "business_category_id" field.
|
|
func (buo *BusinessUpdateOne) SetBusinessCategoryID(i int) *BusinessUpdateOne {
|
|
buo.mutation.SetBusinessCategoryID(i)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableBusinessCategoryID sets the "business_category_id" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableBusinessCategoryID(i *int) *BusinessUpdateOne {
|
|
if i != nil {
|
|
buo.SetBusinessCategoryID(*i)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// ClearBusinessCategoryID clears the value of the "business_category_id" field.
|
|
func (buo *BusinessUpdateOne) ClearBusinessCategoryID() *BusinessUpdateOne {
|
|
buo.mutation.ClearBusinessCategoryID()
|
|
return buo
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (buo *BusinessUpdateOne) SetUserID(i int) *BusinessUpdateOne {
|
|
buo.mutation.SetUserID(i)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableUserID(i *int) *BusinessUpdateOne {
|
|
if i != nil {
|
|
buo.SetUserID(*i)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (buo *BusinessUpdateOne) ClearUserID() *BusinessUpdateOne {
|
|
buo.mutation.ClearUserID()
|
|
return buo
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (buo *BusinessUpdateOne) SetCreatedAt(t time.Time) *BusinessUpdateOne {
|
|
buo.mutation.SetCreatedAt(t)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableCreatedAt(t *time.Time) *BusinessUpdateOne {
|
|
if t != nil {
|
|
buo.SetCreatedAt(*t)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (buo *BusinessUpdateOne) SetUpdatedAt(t time.Time) *BusinessUpdateOne {
|
|
buo.mutation.SetUpdatedAt(t)
|
|
return buo
|
|
}
|
|
|
|
// SetBusinessCategoriesID sets the "business_categories" edge to the BusinessCategory entity by ID.
|
|
func (buo *BusinessUpdateOne) SetBusinessCategoriesID(id int) *BusinessUpdateOne {
|
|
buo.mutation.SetBusinessCategoriesID(id)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableBusinessCategoriesID sets the "business_categories" edge to the BusinessCategory entity by ID if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableBusinessCategoriesID(id *int) *BusinessUpdateOne {
|
|
if id != nil {
|
|
buo = buo.SetBusinessCategoriesID(*id)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetBusinessCategories sets the "business_categories" edge to the BusinessCategory entity.
|
|
func (buo *BusinessUpdateOne) SetBusinessCategories(b *BusinessCategory) *BusinessUpdateOne {
|
|
return buo.SetBusinessCategoriesID(b.ID)
|
|
}
|
|
|
|
// SetUsersID sets the "users" edge to the User entity by ID.
|
|
func (buo *BusinessUpdateOne) SetUsersID(id int) *BusinessUpdateOne {
|
|
buo.mutation.SetUsersID(id)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableUsersID sets the "users" edge to the User entity by ID if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableUsersID(id *int) *BusinessUpdateOne {
|
|
if id != nil {
|
|
buo = buo.SetUsersID(*id)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetUsers sets the "users" edge to the User entity.
|
|
func (buo *BusinessUpdateOne) SetUsers(u *User) *BusinessUpdateOne {
|
|
return buo.SetUsersID(u.ID)
|
|
}
|
|
|
|
// AddProductIDs adds the "products" edge to the Product entity by IDs.
|
|
func (buo *BusinessUpdateOne) AddProductIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.AddProductIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// AddProducts adds the "products" edges to the Product entity.
|
|
func (buo *BusinessUpdateOne) AddProducts(p ...*Product) *BusinessUpdateOne {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return buo.AddProductIDs(ids...)
|
|
}
|
|
|
|
// AddProductCategoryIDs adds the "product_categories" edge to the ProductCategory entity by IDs.
|
|
func (buo *BusinessUpdateOne) AddProductCategoryIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.AddProductCategoryIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// AddProductCategories adds the "product_categories" edges to the ProductCategory entity.
|
|
func (buo *BusinessUpdateOne) AddProductCategories(p ...*ProductCategory) *BusinessUpdateOne {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return buo.AddProductCategoryIDs(ids...)
|
|
}
|
|
|
|
// AddDomainIDs adds the "domains" edge to the Domain entity by IDs.
|
|
func (buo *BusinessUpdateOne) AddDomainIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.AddDomainIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// AddDomains adds the "domains" edges to the Domain entity.
|
|
func (buo *BusinessUpdateOne) AddDomains(d ...*Domain) *BusinessUpdateOne {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return buo.AddDomainIDs(ids...)
|
|
}
|
|
|
|
// AddBusinessConfigIDs adds the "business_configs" edge to the BusinessConfig entity by IDs.
|
|
func (buo *BusinessUpdateOne) AddBusinessConfigIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.AddBusinessConfigIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// AddBusinessConfigs adds the "business_configs" edges to the BusinessConfig entity.
|
|
func (buo *BusinessUpdateOne) AddBusinessConfigs(b ...*BusinessConfig) *BusinessUpdateOne {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return buo.AddBusinessConfigIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the BusinessMutation object of the builder.
|
|
func (buo *BusinessUpdateOne) Mutation() *BusinessMutation {
|
|
return buo.mutation
|
|
}
|
|
|
|
// ClearBusinessCategories clears the "business_categories" edge to the BusinessCategory entity.
|
|
func (buo *BusinessUpdateOne) ClearBusinessCategories() *BusinessUpdateOne {
|
|
buo.mutation.ClearBusinessCategories()
|
|
return buo
|
|
}
|
|
|
|
// ClearUsers clears the "users" edge to the User entity.
|
|
func (buo *BusinessUpdateOne) ClearUsers() *BusinessUpdateOne {
|
|
buo.mutation.ClearUsers()
|
|
return buo
|
|
}
|
|
|
|
// ClearProducts clears all "products" edges to the Product entity.
|
|
func (buo *BusinessUpdateOne) ClearProducts() *BusinessUpdateOne {
|
|
buo.mutation.ClearProducts()
|
|
return buo
|
|
}
|
|
|
|
// RemoveProductIDs removes the "products" edge to Product entities by IDs.
|
|
func (buo *BusinessUpdateOne) RemoveProductIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.RemoveProductIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// RemoveProducts removes "products" edges to Product entities.
|
|
func (buo *BusinessUpdateOne) RemoveProducts(p ...*Product) *BusinessUpdateOne {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return buo.RemoveProductIDs(ids...)
|
|
}
|
|
|
|
// ClearProductCategories clears all "product_categories" edges to the ProductCategory entity.
|
|
func (buo *BusinessUpdateOne) ClearProductCategories() *BusinessUpdateOne {
|
|
buo.mutation.ClearProductCategories()
|
|
return buo
|
|
}
|
|
|
|
// RemoveProductCategoryIDs removes the "product_categories" edge to ProductCategory entities by IDs.
|
|
func (buo *BusinessUpdateOne) RemoveProductCategoryIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.RemoveProductCategoryIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// RemoveProductCategories removes "product_categories" edges to ProductCategory entities.
|
|
func (buo *BusinessUpdateOne) RemoveProductCategories(p ...*ProductCategory) *BusinessUpdateOne {
|
|
ids := make([]int, len(p))
|
|
for i := range p {
|
|
ids[i] = p[i].ID
|
|
}
|
|
return buo.RemoveProductCategoryIDs(ids...)
|
|
}
|
|
|
|
// ClearDomains clears all "domains" edges to the Domain entity.
|
|
func (buo *BusinessUpdateOne) ClearDomains() *BusinessUpdateOne {
|
|
buo.mutation.ClearDomains()
|
|
return buo
|
|
}
|
|
|
|
// RemoveDomainIDs removes the "domains" edge to Domain entities by IDs.
|
|
func (buo *BusinessUpdateOne) RemoveDomainIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.RemoveDomainIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// RemoveDomains removes "domains" edges to Domain entities.
|
|
func (buo *BusinessUpdateOne) RemoveDomains(d ...*Domain) *BusinessUpdateOne {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return buo.RemoveDomainIDs(ids...)
|
|
}
|
|
|
|
// ClearBusinessConfigs clears all "business_configs" edges to the BusinessConfig entity.
|
|
func (buo *BusinessUpdateOne) ClearBusinessConfigs() *BusinessUpdateOne {
|
|
buo.mutation.ClearBusinessConfigs()
|
|
return buo
|
|
}
|
|
|
|
// RemoveBusinessConfigIDs removes the "business_configs" edge to BusinessConfig entities by IDs.
|
|
func (buo *BusinessUpdateOne) RemoveBusinessConfigIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.RemoveBusinessConfigIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// RemoveBusinessConfigs removes "business_configs" edges to BusinessConfig entities.
|
|
func (buo *BusinessUpdateOne) RemoveBusinessConfigs(b ...*BusinessConfig) *BusinessUpdateOne {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return buo.RemoveBusinessConfigIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the BusinessUpdate builder.
|
|
func (buo *BusinessUpdateOne) Where(ps ...predicate.Business) *BusinessUpdateOne {
|
|
buo.mutation.Where(ps...)
|
|
return buo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (buo *BusinessUpdateOne) Select(field string, fields ...string) *BusinessUpdateOne {
|
|
buo.fields = append([]string{field}, fields...)
|
|
return buo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Business entity.
|
|
func (buo *BusinessUpdateOne) Save(ctx context.Context) (*Business, error) {
|
|
buo.defaults()
|
|
return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (buo *BusinessUpdateOne) SaveX(ctx context.Context) *Business {
|
|
node, err := buo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (buo *BusinessUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := buo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (buo *BusinessUpdateOne) ExecX(ctx context.Context) {
|
|
if err := buo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (buo *BusinessUpdateOne) defaults() {
|
|
if _, ok := buo.mutation.UpdatedAt(); !ok {
|
|
v := business.UpdateDefaultUpdatedAt()
|
|
buo.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
func (buo *BusinessUpdateOne) sqlSave(ctx context.Context) (_node *Business, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(business.Table, business.Columns, sqlgraph.NewFieldSpec(business.FieldID, field.TypeInt))
|
|
id, ok := buo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Business.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := buo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, business.FieldID)
|
|
for _, f := range fields {
|
|
if !business.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != business.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := buo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := buo.mutation.Name(); ok {
|
|
_spec.SetField(business.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.Slug(); ok {
|
|
_spec.SetField(business.FieldSlug, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.BotID(); ok {
|
|
_spec.SetField(business.FieldBotID, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.Description(); ok {
|
|
_spec.SetField(business.FieldDescription, field.TypeString, value)
|
|
}
|
|
if buo.mutation.DescriptionCleared() {
|
|
_spec.ClearField(business.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := buo.mutation.AboutUs(); ok {
|
|
_spec.SetField(business.FieldAboutUs, field.TypeString, value)
|
|
}
|
|
if buo.mutation.AboutUsCleared() {
|
|
_spec.ClearField(business.FieldAboutUs, field.TypeString)
|
|
}
|
|
if value, ok := buo.mutation.CreatedAt(); ok {
|
|
_spec.SetField(business.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := buo.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(business.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if buo.mutation.BusinessCategoriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoriesTable,
|
|
Columns: []string{business.BusinessCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.BusinessCategoriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoriesTable,
|
|
Columns: []string{business.BusinessCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if buo.mutation.UsersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.UsersTable,
|
|
Columns: []string{business.UsersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.UsersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: business.UsersTable,
|
|
Columns: []string{business.UsersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if buo.mutation.ProductsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductsTable,
|
|
Columns: []string{business.ProductsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.RemovedProductsIDs(); len(nodes) > 0 && !buo.mutation.ProductsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductsTable,
|
|
Columns: []string{business.ProductsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.ProductsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductsTable,
|
|
Columns: []string{business.ProductsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if buo.mutation.ProductCategoriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductCategoriesTable,
|
|
Columns: []string{business.ProductCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(productcategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.RemovedProductCategoriesIDs(); len(nodes) > 0 && !buo.mutation.ProductCategoriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductCategoriesTable,
|
|
Columns: []string{business.ProductCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(productcategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.ProductCategoriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.ProductCategoriesTable,
|
|
Columns: []string{business.ProductCategoriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(productcategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if buo.mutation.DomainsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.DomainsTable,
|
|
Columns: []string{business.DomainsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(domain.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.RemovedDomainsIDs(); len(nodes) > 0 && !buo.mutation.DomainsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.DomainsTable,
|
|
Columns: []string{business.DomainsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(domain.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.DomainsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.DomainsTable,
|
|
Columns: []string{business.DomainsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(domain.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if buo.mutation.BusinessConfigsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.BusinessConfigsTable,
|
|
Columns: []string{business.BusinessConfigsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.RemovedBusinessConfigsIDs(); len(nodes) > 0 && !buo.mutation.BusinessConfigsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.BusinessConfigsTable,
|
|
Columns: []string{business.BusinessConfigsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.BusinessConfigsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: business.BusinessConfigsTable,
|
|
Columns: []string{business.BusinessConfigsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Business{config: buo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{business.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
buo.mutation.done = true
|
|
return _node, nil
|
|
}
|