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>
187 lines
6.6 KiB
Go
187 lines
6.6 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskill"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillversion"
|
|
"github.com/chaitin/MonkeyCode/backend/ent/types"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentSkillVersion is the model entity for the AgentSkillVersion schema.
|
|
type AgentSkillVersion struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// ResourceID holds the value of the "resource_id" field.
|
|
ResourceID uuid.UUID `json:"resource_id,omitempty"`
|
|
// Version holds the value of the "version" field.
|
|
Version string `json:"version,omitempty"`
|
|
// S3Key holds the value of the "s3_key" field.
|
|
S3Key string `json:"s3_key,omitempty"`
|
|
// ParsedMeta holds the value of the "parsed_meta" field.
|
|
ParsedMeta types.SkillParsedMeta `json:"parsed_meta,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 AgentSkillVersionQuery when eager-loading is set.
|
|
Edges AgentSkillVersionEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// AgentSkillVersionEdges holds the relations/edges for other nodes in the graph.
|
|
type AgentSkillVersionEdges struct {
|
|
// Skill holds the value of the skill edge.
|
|
Skill *AgentSkill `json:"skill,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]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 AgentSkillVersionEdges) 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"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*AgentSkillVersion) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case agentskillversion.FieldParsedMeta:
|
|
values[i] = new([]byte)
|
|
case agentskillversion.FieldVersion, agentskillversion.FieldS3Key:
|
|
values[i] = new(sql.NullString)
|
|
case agentskillversion.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case agentskillversion.FieldID, agentskillversion.FieldResourceID:
|
|
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 AgentSkillVersion fields.
|
|
func (_m *AgentSkillVersion) 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 agentskillversion.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 agentskillversion.FieldResourceID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field resource_id", values[i])
|
|
} else if value != nil {
|
|
_m.ResourceID = *value
|
|
}
|
|
case agentskillversion.FieldVersion:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field version", values[i])
|
|
} else if value.Valid {
|
|
_m.Version = value.String
|
|
}
|
|
case agentskillversion.FieldS3Key:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field s3_key", values[i])
|
|
} else if value.Valid {
|
|
_m.S3Key = value.String
|
|
}
|
|
case agentskillversion.FieldParsedMeta:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field parsed_meta", values[i])
|
|
} else if value != nil && len(*value) > 0 {
|
|
if err := json.Unmarshal(*value, &_m.ParsedMeta); err != nil {
|
|
return fmt.Errorf("unmarshal field parsed_meta: %w", err)
|
|
}
|
|
}
|
|
case agentskillversion.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 AgentSkillVersion.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *AgentSkillVersion) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QuerySkill queries the "skill" edge of the AgentSkillVersion entity.
|
|
func (_m *AgentSkillVersion) QuerySkill() *AgentSkillQuery {
|
|
return NewAgentSkillVersionClient(_m.config).QuerySkill(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this AgentSkillVersion.
|
|
// Note that you need to call AgentSkillVersion.Unwrap() before calling this method if this AgentSkillVersion
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *AgentSkillVersion) Update() *AgentSkillVersionUpdateOne {
|
|
return NewAgentSkillVersionClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the AgentSkillVersion 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 *AgentSkillVersion) Unwrap() *AgentSkillVersion {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: AgentSkillVersion is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *AgentSkillVersion) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("AgentSkillVersion(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("resource_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ResourceID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("version=")
|
|
builder.WriteString(_m.Version)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("s3_key=")
|
|
builder.WriteString(_m.S3Key)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("parsed_meta=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ParsedMeta))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// AgentSkillVersions is a parsable slice of AgentSkillVersion.
|
|
type AgentSkillVersions []*AgentSkillVersion
|