mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-28 07:27:03 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
170 lines
5.8 KiB
Go
170 lines
5.8 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/agentrule"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentruleversion"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentRuleVersion is the model entity for the AgentRuleVersion schema.
|
|
type AgentRuleVersion struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// RuleID holds the value of the "rule_id" field.
|
|
RuleID uuid.UUID `json:"rule_id,omitempty"`
|
|
// Version holds the value of the "version" field.
|
|
Version string `json:"version,omitempty"`
|
|
// Content holds the value of the "content" field.
|
|
Content string `json:"content,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 AgentRuleVersionQuery when eager-loading is set.
|
|
Edges AgentRuleVersionEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// AgentRuleVersionEdges holds the relations/edges for other nodes in the graph.
|
|
type AgentRuleVersionEdges struct {
|
|
// Rule holds the value of the rule edge.
|
|
Rule *AgentRule `json:"rule,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// RuleOrErr returns the Rule value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e AgentRuleVersionEdges) RuleOrErr() (*AgentRule, error) {
|
|
if e.Rule != nil {
|
|
return e.Rule, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: agentrule.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "rule"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*AgentRuleVersion) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case agentruleversion.FieldVersion, agentruleversion.FieldContent:
|
|
values[i] = new(sql.NullString)
|
|
case agentruleversion.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case agentruleversion.FieldID, agentruleversion.FieldRuleID:
|
|
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 AgentRuleVersion fields.
|
|
func (_m *AgentRuleVersion) 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 agentruleversion.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 agentruleversion.FieldRuleID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field rule_id", values[i])
|
|
} else if value != nil {
|
|
_m.RuleID = *value
|
|
}
|
|
case agentruleversion.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 agentruleversion.FieldContent:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field content", values[i])
|
|
} else if value.Valid {
|
|
_m.Content = value.String
|
|
}
|
|
case agentruleversion.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 AgentRuleVersion.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *AgentRuleVersion) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryRule queries the "rule" edge of the AgentRuleVersion entity.
|
|
func (_m *AgentRuleVersion) QueryRule() *AgentRuleQuery {
|
|
return NewAgentRuleVersionClient(_m.config).QueryRule(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this AgentRuleVersion.
|
|
// Note that you need to call AgentRuleVersion.Unwrap() before calling this method if this AgentRuleVersion
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *AgentRuleVersion) Update() *AgentRuleVersionUpdateOne {
|
|
return NewAgentRuleVersionClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the AgentRuleVersion 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 *AgentRuleVersion) Unwrap() *AgentRuleVersion {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: AgentRuleVersion is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *AgentRuleVersion) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("AgentRuleVersion(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("rule_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.RuleID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("version=")
|
|
builder.WriteString(_m.Version)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("content=")
|
|
builder.WriteString(_m.Content)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// AgentRuleVersions is a parsable slice of AgentRuleVersion.
|
|
type AgentRuleVersions []*AgentRuleVersion
|