mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
176 lines
6.3 KiB
Go
176 lines
6.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskill"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teamgroup"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentSkillGroupBinding is the model entity for the AgentSkillGroupBinding schema.
|
|
type AgentSkillGroupBinding struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// SkillID holds the value of the "skill_id" field.
|
|
SkillID uuid.UUID `json:"skill_id,omitempty"`
|
|
// GroupID holds the value of the "group_id" field.
|
|
GroupID uuid.UUID `json:"group_id,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the AgentSkillGroupBindingQuery when eager-loading is set.
|
|
Edges AgentSkillGroupBindingEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// AgentSkillGroupBindingEdges holds the relations/edges for other nodes in the graph.
|
|
type AgentSkillGroupBindingEdges struct {
|
|
// Skill holds the value of the skill edge.
|
|
Skill *AgentSkill `json:"skill,omitempty"`
|
|
// Group holds the value of the group edge.
|
|
Group *TeamGroup `json:"group,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [2]bool
|
|
}
|
|
|
|
// SkillOrErr returns the Skill value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e AgentSkillGroupBindingEdges) SkillOrErr() (*AgentSkill, error) {
|
|
if e.Skill != nil {
|
|
return e.Skill, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: agentskill.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "skill"}
|
|
}
|
|
|
|
// GroupOrErr returns the Group value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e AgentSkillGroupBindingEdges) GroupOrErr() (*TeamGroup, error) {
|
|
if e.Group != nil {
|
|
return e.Group, nil
|
|
} else if e.loadedTypes[1] {
|
|
return nil, &NotFoundError{label: teamgroup.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "group"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*AgentSkillGroupBinding) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case agentskillgroupbinding.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case agentskillgroupbinding.FieldID, agentskillgroupbinding.FieldSkillID, agentskillgroupbinding.FieldGroupID:
|
|
values[i] = new(uuid.UUID)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the AgentSkillGroupBinding fields.
|
|
func (_m *AgentSkillGroupBinding) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case agentskillgroupbinding.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
_m.ID = *value
|
|
}
|
|
case agentskillgroupbinding.FieldSkillID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field skill_id", values[i])
|
|
} else if value != nil {
|
|
_m.SkillID = *value
|
|
}
|
|
case agentskillgroupbinding.FieldGroupID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
|
} else if value != nil {
|
|
_m.GroupID = *value
|
|
}
|
|
case agentskillgroupbinding.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Time
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the AgentSkillGroupBinding.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *AgentSkillGroupBinding) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QuerySkill queries the "skill" edge of the AgentSkillGroupBinding entity.
|
|
func (_m *AgentSkillGroupBinding) QuerySkill() *AgentSkillQuery {
|
|
return NewAgentSkillGroupBindingClient(_m.config).QuerySkill(_m)
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the AgentSkillGroupBinding entity.
|
|
func (_m *AgentSkillGroupBinding) QueryGroup() *TeamGroupQuery {
|
|
return NewAgentSkillGroupBindingClient(_m.config).QueryGroup(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this AgentSkillGroupBinding.
|
|
// Note that you need to call AgentSkillGroupBinding.Unwrap() before calling this method if this AgentSkillGroupBinding
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *AgentSkillGroupBinding) Update() *AgentSkillGroupBindingUpdateOne {
|
|
return NewAgentSkillGroupBindingClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the AgentSkillGroupBinding entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *AgentSkillGroupBinding) Unwrap() *AgentSkillGroupBinding {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: AgentSkillGroupBinding is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *AgentSkillGroupBinding) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("AgentSkillGroupBinding(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("skill_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.SkillID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("group_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.GroupID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// AgentSkillGroupBindings is a parsable slice of AgentSkillGroupBinding.
|
|
type AgentSkillGroupBindings []*AgentSkillGroupBinding
|