mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-23 04:09:15 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
474 lines
15 KiB
Go
474 lines
15 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskill"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teamgroup"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentSkillGroupBindingUpdate is the builder for updating AgentSkillGroupBinding entities.
|
|
type AgentSkillGroupBindingUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *AgentSkillGroupBindingMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the AgentSkillGroupBindingUpdate builder.
|
|
func (_u *AgentSkillGroupBindingUpdate) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetSkillID sets the "skill_id" field.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpdate {
|
|
_u.mutation.SetSkillID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSkillID sets the "skill_id" field if the given value is not nil.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetNillableSkillID(v *uuid.UUID) *AgentSkillGroupBindingUpdate {
|
|
if v != nil {
|
|
_u.SetSkillID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group_id" field.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpdate {
|
|
_u.mutation.SetGroupID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetNillableGroupID(v *uuid.UUID) *AgentSkillGroupBindingUpdate {
|
|
if v != nil {
|
|
_u.SetGroupID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetNillableCreatedAt(v *time.Time) *AgentSkillGroupBindingUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSkill sets the "skill" edge to the AgentSkill entity.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetSkill(v *AgentSkill) *AgentSkillGroupBindingUpdate {
|
|
return _u.SetSkillID(v.ID)
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the TeamGroup entity.
|
|
func (_u *AgentSkillGroupBindingUpdate) SetGroup(v *TeamGroup) *AgentSkillGroupBindingUpdate {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the AgentSkillGroupBindingMutation object of the builder.
|
|
func (_u *AgentSkillGroupBindingUpdate) Mutation() *AgentSkillGroupBindingMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearSkill clears the "skill" edge to the AgentSkill entity.
|
|
func (_u *AgentSkillGroupBindingUpdate) ClearSkill() *AgentSkillGroupBindingUpdate {
|
|
_u.mutation.ClearSkill()
|
|
return _u
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the TeamGroup entity.
|
|
func (_u *AgentSkillGroupBindingUpdate) ClearGroup() *AgentSkillGroupBindingUpdate {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *AgentSkillGroupBindingUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *AgentSkillGroupBindingUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *AgentSkillGroupBindingUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *AgentSkillGroupBindingUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *AgentSkillGroupBindingUpdate) check() error {
|
|
if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.skill"`)
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *AgentSkillGroupBindingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillGroupBindingUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *AgentSkillGroupBindingUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(agentskillgroupbinding.Table, agentskillgroupbinding.Columns, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentskillgroupbinding.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SkillCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.SkillTable,
|
|
Columns: []string{agentskillgroupbinding.SkillColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.SkillTable,
|
|
Columns: []string{agentskillgroupbinding.SkillColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.GroupTable,
|
|
Columns: []string{agentskillgroupbinding.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.GroupTable,
|
|
Columns: []string{agentskillgroupbinding.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{agentskillgroupbinding.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// AgentSkillGroupBindingUpdateOne is the builder for updating a single AgentSkillGroupBinding entity.
|
|
type AgentSkillGroupBindingUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *AgentSkillGroupBindingMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetSkillID sets the "skill_id" field.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpdateOne {
|
|
_u.mutation.SetSkillID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSkillID sets the "skill_id" field if the given value is not nil.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetNillableSkillID(v *uuid.UUID) *AgentSkillGroupBindingUpdateOne {
|
|
if v != nil {
|
|
_u.SetSkillID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group_id" field.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpdateOne {
|
|
_u.mutation.SetGroupID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetNillableGroupID(v *uuid.UUID) *AgentSkillGroupBindingUpdateOne {
|
|
if v != nil {
|
|
_u.SetGroupID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSkillGroupBindingUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSkill sets the "skill" edge to the AgentSkill entity.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetSkill(v *AgentSkill) *AgentSkillGroupBindingUpdateOne {
|
|
return _u.SetSkillID(v.ID)
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the TeamGroup entity.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SetGroup(v *TeamGroup) *AgentSkillGroupBindingUpdateOne {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the AgentSkillGroupBindingMutation object of the builder.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) Mutation() *AgentSkillGroupBindingMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearSkill clears the "skill" edge to the AgentSkill entity.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) ClearSkill() *AgentSkillGroupBindingUpdateOne {
|
|
_u.mutation.ClearSkill()
|
|
return _u
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the TeamGroup entity.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) ClearGroup() *AgentSkillGroupBindingUpdateOne {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the AgentSkillGroupBindingUpdate builder.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) Select(field string, fields ...string) *AgentSkillGroupBindingUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated AgentSkillGroupBinding entity.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) Save(ctx context.Context) (*AgentSkillGroupBinding, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) SaveX(ctx context.Context) *AgentSkillGroupBinding {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) check() error {
|
|
if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.skill"`)
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *AgentSkillGroupBindingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillGroupBindingUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *AgentSkillGroupBindingUpdateOne) sqlSave(ctx context.Context) (_node *AgentSkillGroupBinding, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(agentskillgroupbinding.Table, agentskillgroupbinding.Columns, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSkillGroupBinding.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, agentskillgroupbinding.FieldID)
|
|
for _, f := range fields {
|
|
if !agentskillgroupbinding.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != agentskillgroupbinding.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentskillgroupbinding.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SkillCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.SkillTable,
|
|
Columns: []string{agentskillgroupbinding.SkillColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.SkillTable,
|
|
Columns: []string{agentskillgroupbinding.SkillColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.GroupTable,
|
|
Columns: []string{agentskillgroupbinding.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: agentskillgroupbinding.GroupTable,
|
|
Columns: []string{agentskillgroupbinding.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &AgentSkillGroupBinding{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{agentskillgroupbinding.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|