mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-30 00:27:42 +08:00
271 lines
9.8 KiB
Go
271 lines
9.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/google/uuid"
|
|
)
|
|
|
|
// AgentRule is the model entity for the AgentRule schema.
|
|
type AgentRule struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Description holds the value of the "description" field.
|
|
Description string `json:"description,omitempty"`
|
|
// ScopeType holds the value of the "scope_type" field.
|
|
ScopeType agentrule.ScopeType `json:"scope_type,omitempty"`
|
|
// ScopeID holds the value of the "scope_id" field.
|
|
ScopeID string `json:"scope_id,omitempty"`
|
|
// CreatedBy holds the value of the "created_by" field.
|
|
CreatedBy uuid.UUID `json:"created_by,omitempty"`
|
|
// ActiveVersionID holds the value of the "active_version_id" field.
|
|
ActiveVersionID *uuid.UUID `json:"active_version_id,omitempty"`
|
|
// ExtensionPackageID holds the value of the "extension_package_id" field.
|
|
ExtensionPackageID *string `json:"extension_package_id,omitempty"`
|
|
// ExtensionRuleID holds the value of the "extension_rule_id" field.
|
|
ExtensionRuleID *string `json:"extension_rule_id,omitempty"`
|
|
// ExtensionVersion holds the value of the "extension_version" field.
|
|
ExtensionVersion *string `json:"extension_version,omitempty"`
|
|
// IsDeleted holds the value of the "is_deleted" field.
|
|
IsDeleted bool `json:"is_deleted,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the AgentRuleQuery when eager-loading is set.
|
|
Edges AgentRuleEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// AgentRuleEdges holds the relations/edges for other nodes in the graph.
|
|
type AgentRuleEdges struct {
|
|
// Versions holds the value of the versions edge.
|
|
Versions []*AgentRuleVersion `json:"versions,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// VersionsOrErr returns the Versions value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e AgentRuleEdges) VersionsOrErr() ([]*AgentRuleVersion, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.Versions, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "versions"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*AgentRule) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case agentrule.FieldActiveVersionID:
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
case agentrule.FieldIsDeleted:
|
|
values[i] = new(sql.NullBool)
|
|
case agentrule.FieldName, agentrule.FieldDescription, agentrule.FieldScopeType, agentrule.FieldScopeID, agentrule.FieldExtensionPackageID, agentrule.FieldExtensionRuleID, agentrule.FieldExtensionVersion:
|
|
values[i] = new(sql.NullString)
|
|
case agentrule.FieldCreatedAt, agentrule.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case agentrule.FieldID, agentrule.FieldCreatedBy:
|
|
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 AgentRule fields.
|
|
func (_m *AgentRule) 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 agentrule.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 agentrule.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
_m.Name = value.String
|
|
}
|
|
case agentrule.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
_m.Description = value.String
|
|
}
|
|
case agentrule.FieldScopeType:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field scope_type", values[i])
|
|
} else if value.Valid {
|
|
_m.ScopeType = agentrule.ScopeType(value.String)
|
|
}
|
|
case agentrule.FieldScopeID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field scope_id", values[i])
|
|
} else if value.Valid {
|
|
_m.ScopeID = value.String
|
|
}
|
|
case agentrule.FieldCreatedBy:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_by", values[i])
|
|
} else if value != nil {
|
|
_m.CreatedBy = *value
|
|
}
|
|
case agentrule.FieldActiveVersionID:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field active_version_id", values[i])
|
|
} else if value.Valid {
|
|
_m.ActiveVersionID = new(uuid.UUID)
|
|
*_m.ActiveVersionID = *value.S.(*uuid.UUID)
|
|
}
|
|
case agentrule.FieldExtensionPackageID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field extension_package_id", values[i])
|
|
} else if value.Valid {
|
|
_m.ExtensionPackageID = new(string)
|
|
*_m.ExtensionPackageID = value.String
|
|
}
|
|
case agentrule.FieldExtensionRuleID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field extension_rule_id", values[i])
|
|
} else if value.Valid {
|
|
_m.ExtensionRuleID = new(string)
|
|
*_m.ExtensionRuleID = value.String
|
|
}
|
|
case agentrule.FieldExtensionVersion:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field extension_version", values[i])
|
|
} else if value.Valid {
|
|
_m.ExtensionVersion = new(string)
|
|
*_m.ExtensionVersion = value.String
|
|
}
|
|
case agentrule.FieldIsDeleted:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_deleted", values[i])
|
|
} else if value.Valid {
|
|
_m.IsDeleted = value.Bool
|
|
}
|
|
case agentrule.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
|
|
}
|
|
case agentrule.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = 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 AgentRule.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *AgentRule) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryVersions queries the "versions" edge of the AgentRule entity.
|
|
func (_m *AgentRule) QueryVersions() *AgentRuleVersionQuery {
|
|
return NewAgentRuleClient(_m.config).QueryVersions(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this AgentRule.
|
|
// Note that you need to call AgentRule.Unwrap() before calling this method if this AgentRule
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *AgentRule) Update() *AgentRuleUpdateOne {
|
|
return NewAgentRuleClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the AgentRule 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 *AgentRule) Unwrap() *AgentRule {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: AgentRule is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *AgentRule) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("AgentRule(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("name=")
|
|
builder.WriteString(_m.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("description=")
|
|
builder.WriteString(_m.Description)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("scope_type=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ScopeType))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("scope_id=")
|
|
builder.WriteString(_m.ScopeID)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_by=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy))
|
|
builder.WriteString(", ")
|
|
if v := _m.ActiveVersionID; v != nil {
|
|
builder.WriteString("active_version_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := _m.ExtensionPackageID; v != nil {
|
|
builder.WriteString("extension_package_id=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := _m.ExtensionRuleID; v != nil {
|
|
builder.WriteString("extension_rule_id=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := _m.ExtensionVersion; v != nil {
|
|
builder.WriteString("extension_version=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_deleted=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// AgentRules is a parsable slice of AgentRule.
|
|
type AgentRules []*AgentRule
|