|
@@ -10,6 +10,7 @@ import (
|
|
|
"time"
|
|
|
"wechat-api/ent/agent"
|
|
|
"wechat-api/ent/batchmsg"
|
|
|
+ "wechat-api/ent/category"
|
|
|
"wechat-api/ent/contact"
|
|
|
"wechat-api/ent/custom_types"
|
|
|
"wechat-api/ent/employee"
|
|
@@ -44,6 +45,7 @@ const (
|
|
|
// Node types.
|
|
|
TypeAgent = "Agent"
|
|
|
TypeBatchMsg = "BatchMsg"
|
|
|
+ TypeCategory = "Category"
|
|
|
TypeContact = "Contact"
|
|
|
TypeEmployee = "Employee"
|
|
|
TypeEmployeeConfig = "EmployeeConfig"
|
|
@@ -2666,6 +2668,612 @@ func (m *BatchMsgMutation) ResetEdge(name string) error {
|
|
|
return fmt.Errorf("unknown BatchMsg edge %s", name)
|
|
|
}
|
|
|
|
|
|
+// CategoryMutation represents an operation that mutates the Category nodes in the graph.
|
|
|
+type CategoryMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ deleted_at *time.Time
|
|
|
+ name *string
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*Category, error)
|
|
|
+ predicates []predicate.Category
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*CategoryMutation)(nil)
|
|
|
+
|
|
|
+// categoryOption allows management of the mutation configuration using functional options.
|
|
|
+type categoryOption func(*CategoryMutation)
|
|
|
+
|
|
|
+// newCategoryMutation creates new mutation for the Category entity.
|
|
|
+func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
|
|
|
+ m := &CategoryMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeCategory,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withCategoryID sets the ID field of the mutation.
|
|
|
+func withCategoryID(id uint64) categoryOption {
|
|
|
+ return func(m *CategoryMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *Category
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*Category, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().Category.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withCategory sets the old Category of the mutation.
|
|
|
+func withCategory(node *Category) categoryOption {
|
|
|
+ return func(m *CategoryMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*Category, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
|
+// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
|
+func (m CategoryMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
|
+// it returns an error otherwise.
|
|
|
+func (m CategoryMutation) Tx() (*Tx, error) {
|
|
|
+ if _, ok := m.driver.(*txDriver); !ok {
|
|
|
+ return nil, errors.New("ent: mutation is not running in a transaction")
|
|
|
+ }
|
|
|
+ tx := &Tx{config: m.config}
|
|
|
+ tx.init()
|
|
|
+ return tx, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the value of the id field. Note that this
|
|
|
+// operation is only accepted on creation of Category entities.
|
|
|
+func (m *CategoryMutation) SetID(id uint64) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+// ID returns the ID value in the mutation. Note that the ID is only available
|
|
|
+// if it was provided to the builder or after it was returned from the database.
|
|
|
+func (m *CategoryMutation) ID() (id uint64, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
|
+// That means, if the mutation is applied within a transaction with an isolation level such
|
|
|
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
|
+// or updated by the mutation.
|
|
|
+func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []uint64{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (m *CategoryMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCreatedAt returns the old "created_at" field's value of the Category entity.
|
|
|
+// If the Category object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CreatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
+func (m *CategoryMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
|
|
|
+// If the Category object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.UpdatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
+func (m *CategoryMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (m *CategoryMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
|
+func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.deleted_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
|
|
|
+// If the Category object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.DeletedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (m *CategoryMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[category.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
|
+func (m *CategoryMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[category.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
|
+func (m *CategoryMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, category.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+// SetName sets the "name" field.
|
|
|
+func (m *CategoryMutation) SetName(s string) {
|
|
|
+ m.name = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Name returns the value of the "name" field in the mutation.
|
|
|
+func (m *CategoryMutation) Name() (r string, exists bool) {
|
|
|
+ v := m.name
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldName returns the old "name" field's value of the Category entity.
|
|
|
+// If the Category object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldName is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldName requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldName: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Name, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetName resets all changes to the "name" field.
|
|
|
+func (m *CategoryMutation) ResetName() {
|
|
|
+ m.name = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *CategoryMutation) SetOrganizationID(u uint64) {
|
|
|
+ m.organization_id = &u
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationID returns the value of the "organization_id" field in the mutation.
|
|
|
+func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
|
|
|
+ v := m.organization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOrganizationID returns the old "organization_id" field's value of the Category entity.
|
|
|
+// If the Category object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOrganizationID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OrganizationID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds u to the "organization_id" field.
|
|
|
+func (m *CategoryMutation) AddOrganizationID(u int64) {
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ *m.addorganization_id += u
|
|
|
+ } else {
|
|
|
+ m.addorganization_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
|
|
|
+func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
|
|
|
+ v := m.addorganization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOrganizationID resets all changes to the "organization_id" field.
|
|
|
+func (m *CategoryMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the CategoryMutation builder.
|
|
|
+func (m *CategoryMutation) Where(ps ...predicate.Category) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.Category, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *CategoryMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *CategoryMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (Category).
|
|
|
+func (m *CategoryMutation) Type() string {
|
|
|
+ return m.typ
|
|
|
+}
|
|
|
+
|
|
|
+// Fields returns all fields that were changed during this mutation. Note that in
|
|
|
+// order to get all numeric fields that were incremented/decremented, call
|
|
|
+// AddedFields().
|
|
|
+func (m *CategoryMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 5)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, category.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, category.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.deleted_at != nil {
|
|
|
+ fields = append(fields, category.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.name != nil {
|
|
|
+ fields = append(fields, category.FieldName)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, category.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// Field returns the value of a field with the given name. The second boolean
|
|
|
+// return value indicates that this field was not set, or was not defined in the
|
|
|
+// schema.
|
|
|
+func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case category.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case category.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case category.FieldDeletedAt:
|
|
|
+ return m.DeletedAt()
|
|
|
+ case category.FieldName:
|
|
|
+ return m.Name()
|
|
|
+ case category.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// OldField returns the old value of the field from the database. An error is
|
|
|
+// returned if the mutation operation is not UpdateOne, or the query to the
|
|
|
+// database failed.
|
|
|
+func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case category.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case category.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case category.FieldDeletedAt:
|
|
|
+ return m.OldDeletedAt(ctx)
|
|
|
+ case category.FieldName:
|
|
|
+ return m.OldName(ctx)
|
|
|
+ case category.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown Category field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// SetField sets the value of a field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *CategoryMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case category.FieldCreatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCreatedAt(v)
|
|
|
+ return nil
|
|
|
+ case category.FieldUpdatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetUpdatedAt(v)
|
|
|
+ return nil
|
|
|
+ case category.FieldDeletedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetDeletedAt(v)
|
|
|
+ return nil
|
|
|
+ case category.FieldName:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetName(v)
|
|
|
+ return nil
|
|
|
+ case category.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Category field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *CategoryMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, category.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// AddedField returns the numeric value that was incremented/decremented on a field
|
|
|
+// with the given name. The second boolean return value indicates that this field
|
|
|
+// was not set, or was not defined in the schema.
|
|
|
+func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case category.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// AddField adds the value to the field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *CategoryMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case category.FieldOrganizationID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Category numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *CategoryMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(category.FieldDeletedAt) {
|
|
|
+ fields = append(fields, category.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *CategoryMutation) FieldCleared(name string) bool {
|
|
|
+ _, ok := m.clearedFields[name]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ClearField clears the value of the field with the given name. It returns an
|
|
|
+// error if the field is not defined in the schema.
|
|
|
+func (m *CategoryMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case category.FieldDeletedAt:
|
|
|
+ m.ClearDeletedAt()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Category nullable field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetField resets all changes in the mutation for the field with the given name.
|
|
|
+// It returns an error if the field is not defined in the schema.
|
|
|
+func (m *CategoryMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case category.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case category.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case category.FieldDeletedAt:
|
|
|
+ m.ResetDeletedAt()
|
|
|
+ return nil
|
|
|
+ case category.FieldName:
|
|
|
+ m.ResetName()
|
|
|
+ return nil
|
|
|
+ case category.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Category field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *CategoryMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *CategoryMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *CategoryMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *CategoryMutation) EdgeCleared(name string) bool {
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
|
+// if that edge is not defined in the schema.
|
|
|
+func (m *CategoryMutation) ClearEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown Category unique edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
|
+// It returns an error if the edge is not defined in the schema.
|
|
|
+func (m *CategoryMutation) ResetEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown Category edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
// ContactMutation represents an operation that mutates the Contact nodes in the graph.
|
|
|
type ContactMutation struct {
|
|
|
config
|
|
@@ -4529,6 +5137,8 @@ type EmployeeMutation struct {
|
|
|
video_url *string
|
|
|
organization_id *uint64
|
|
|
addorganization_id *int64
|
|
|
+ category_id *uint64
|
|
|
+ addcategory_id *int64
|
|
|
clearedFields map[string]struct{}
|
|
|
em_work_experiences map[uint64]struct{}
|
|
|
removedem_work_experiences map[uint64]struct{}
|
|
@@ -5350,6 +5960,62 @@ func (m *EmployeeMutation) ResetOrganizationID() {
|
|
|
m.addorganization_id = nil
|
|
|
}
|
|
|
|
|
|
+// SetCategoryID sets the "category_id" field.
|
|
|
+func (m *EmployeeMutation) SetCategoryID(u uint64) {
|
|
|
+ m.category_id = &u
|
|
|
+ m.addcategory_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// CategoryID returns the value of the "category_id" field in the mutation.
|
|
|
+func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
|
|
|
+ v := m.category_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCategoryID returns the old "category_id" field's value of the Employee entity.
|
|
|
+// If the Employee object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCategoryID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CategoryID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddCategoryID adds u to the "category_id" field.
|
|
|
+func (m *EmployeeMutation) AddCategoryID(u int64) {
|
|
|
+ if m.addcategory_id != nil {
|
|
|
+ *m.addcategory_id += u
|
|
|
+ } else {
|
|
|
+ m.addcategory_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
|
|
|
+func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
|
|
|
+ v := m.addcategory_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCategoryID resets all changes to the "category_id" field.
|
|
|
+func (m *EmployeeMutation) ResetCategoryID() {
|
|
|
+ m.category_id = nil
|
|
|
+ m.addcategory_id = nil
|
|
|
+}
|
|
|
+
|
|
|
// AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
|
|
|
func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
|
|
|
if m.em_work_experiences == nil {
|
|
@@ -5492,7 +6158,7 @@ func (m *EmployeeMutation) Type() string {
|
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
|
// AddedFields().
|
|
|
func (m *EmployeeMutation) Fields() []string {
|
|
|
- fields := make([]string, 0, 17)
|
|
|
+ fields := make([]string, 0, 18)
|
|
|
if m.created_at != nil {
|
|
|
fields = append(fields, employee.FieldCreatedAt)
|
|
|
}
|
|
@@ -5544,6 +6210,9 @@ func (m *EmployeeMutation) Fields() []string {
|
|
|
if m.organization_id != nil {
|
|
|
fields = append(fields, employee.FieldOrganizationID)
|
|
|
}
|
|
|
+ if m.category_id != nil {
|
|
|
+ fields = append(fields, employee.FieldCategoryID)
|
|
|
+ }
|
|
|
return fields
|
|
|
}
|
|
|
|
|
@@ -5586,6 +6255,8 @@ func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
|
|
|
return m.VideoURL()
|
|
|
case employee.FieldOrganizationID:
|
|
|
return m.OrganizationID()
|
|
|
+ case employee.FieldCategoryID:
|
|
|
+ return m.CategoryID()
|
|
|
}
|
|
|
return nil, false
|
|
|
}
|
|
@@ -5629,6 +6300,8 @@ func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value
|
|
|
return m.OldVideoURL(ctx)
|
|
|
case employee.FieldOrganizationID:
|
|
|
return m.OldOrganizationID(ctx)
|
|
|
+ case employee.FieldCategoryID:
|
|
|
+ return m.OldCategoryID(ctx)
|
|
|
}
|
|
|
return nil, fmt.Errorf("unknown Employee field %s", name)
|
|
|
}
|
|
@@ -5757,6 +6430,13 @@ func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
|
|
|
}
|
|
|
m.SetOrganizationID(v)
|
|
|
return nil
|
|
|
+ case employee.FieldCategoryID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCategoryID(v)
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Employee field %s", name)
|
|
|
}
|
|
@@ -5777,6 +6457,9 @@ func (m *EmployeeMutation) AddedFields() []string {
|
|
|
if m.addorganization_id != nil {
|
|
|
fields = append(fields, employee.FieldOrganizationID)
|
|
|
}
|
|
|
+ if m.addcategory_id != nil {
|
|
|
+ fields = append(fields, employee.FieldCategoryID)
|
|
|
+ }
|
|
|
return fields
|
|
|
}
|
|
|
|
|
@@ -5793,6 +6476,8 @@ func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
return m.AddedAchievementCount()
|
|
|
case employee.FieldOrganizationID:
|
|
|
return m.AddedOrganizationID()
|
|
|
+ case employee.FieldCategoryID:
|
|
|
+ return m.AddedCategoryID()
|
|
|
}
|
|
|
return nil, false
|
|
|
}
|
|
@@ -5830,6 +6515,13 @@ func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
|
|
|
}
|
|
|
m.AddOrganizationID(v)
|
|
|
return nil
|
|
|
+ case employee.FieldCategoryID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddCategoryID(v)
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Employee numeric field %s", name)
|
|
|
}
|
|
@@ -5917,6 +6609,9 @@ func (m *EmployeeMutation) ResetField(name string) error {
|
|
|
case employee.FieldOrganizationID:
|
|
|
m.ResetOrganizationID()
|
|
|
return nil
|
|
|
+ case employee.FieldCategoryID:
|
|
|
+ m.ResetCategoryID()
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Employee field %s", name)
|
|
|
}
|