mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 11:28:46 +08:00
313 lines
11 KiB
Go
313 lines
11 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/model"
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
"github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// TaskModelSwitch is the model entity for the TaskModelSwitch schema.
|
|
type TaskModelSwitch struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// TaskID holds the value of the "task_id" field.
|
|
TaskID uuid.UUID `json:"task_id,omitempty"`
|
|
// UserID holds the value of the "user_id" field.
|
|
UserID uuid.UUID `json:"user_id,omitempty"`
|
|
// FromModelID holds the value of the "from_model_id" field.
|
|
FromModelID *uuid.UUID `json:"from_model_id,omitempty"`
|
|
// ToModelID holds the value of the "to_model_id" field.
|
|
ToModelID uuid.UUID `json:"to_model_id,omitempty"`
|
|
// RequestID holds the value of the "request_id" field.
|
|
RequestID string `json:"request_id,omitempty"`
|
|
// LoadSession holds the value of the "load_session" field.
|
|
LoadSession bool `json:"load_session,omitempty"`
|
|
// Success holds the value of the "success" field.
|
|
Success *bool `json:"success,omitempty"`
|
|
// Message holds the value of the "message" field.
|
|
Message string `json:"message,omitempty"`
|
|
// SessionID holds the value of the "session_id" field.
|
|
SessionID string `json:"session_id,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 TaskModelSwitchQuery when eager-loading is set.
|
|
Edges TaskModelSwitchEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// TaskModelSwitchEdges holds the relations/edges for other nodes in the graph.
|
|
type TaskModelSwitchEdges struct {
|
|
// Task holds the value of the task edge.
|
|
Task *Task `json:"task,omitempty"`
|
|
// User holds the value of the user edge.
|
|
User *User `json:"user,omitempty"`
|
|
// FromModel holds the value of the from_model edge.
|
|
FromModel *Model `json:"from_model,omitempty"`
|
|
// ToModel holds the value of the to_model edge.
|
|
ToModel *Model `json:"to_model,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [4]bool
|
|
}
|
|
|
|
// TaskOrErr returns the Task value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e TaskModelSwitchEdges) TaskOrErr() (*Task, error) {
|
|
if e.Task != nil {
|
|
return e.Task, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: task.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "task"}
|
|
}
|
|
|
|
// UserOrErr returns the User value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e TaskModelSwitchEdges) UserOrErr() (*User, error) {
|
|
if e.User != nil {
|
|
return e.User, nil
|
|
} else if e.loadedTypes[1] {
|
|
return nil, &NotFoundError{label: user.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "user"}
|
|
}
|
|
|
|
// FromModelOrErr returns the FromModel value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e TaskModelSwitchEdges) FromModelOrErr() (*Model, error) {
|
|
if e.FromModel != nil {
|
|
return e.FromModel, nil
|
|
} else if e.loadedTypes[2] {
|
|
return nil, &NotFoundError{label: model.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "from_model"}
|
|
}
|
|
|
|
// ToModelOrErr returns the ToModel value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e TaskModelSwitchEdges) ToModelOrErr() (*Model, error) {
|
|
if e.ToModel != nil {
|
|
return e.ToModel, nil
|
|
} else if e.loadedTypes[3] {
|
|
return nil, &NotFoundError{label: model.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "to_model"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*TaskModelSwitch) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case taskmodelswitch.FieldFromModelID:
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
case taskmodelswitch.FieldLoadSession, taskmodelswitch.FieldSuccess:
|
|
values[i] = new(sql.NullBool)
|
|
case taskmodelswitch.FieldRequestID, taskmodelswitch.FieldMessage, taskmodelswitch.FieldSessionID:
|
|
values[i] = new(sql.NullString)
|
|
case taskmodelswitch.FieldCreatedAt, taskmodelswitch.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case taskmodelswitch.FieldID, taskmodelswitch.FieldTaskID, taskmodelswitch.FieldUserID, taskmodelswitch.FieldToModelID:
|
|
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 TaskModelSwitch fields.
|
|
func (_m *TaskModelSwitch) 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 taskmodelswitch.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 taskmodelswitch.FieldTaskID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field task_id", values[i])
|
|
} else if value != nil {
|
|
_m.TaskID = *value
|
|
}
|
|
case taskmodelswitch.FieldUserID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
|
} else if value != nil {
|
|
_m.UserID = *value
|
|
}
|
|
case taskmodelswitch.FieldFromModelID:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field from_model_id", values[i])
|
|
} else if value.Valid {
|
|
_m.FromModelID = new(uuid.UUID)
|
|
*_m.FromModelID = *value.S.(*uuid.UUID)
|
|
}
|
|
case taskmodelswitch.FieldToModelID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field to_model_id", values[i])
|
|
} else if value != nil {
|
|
_m.ToModelID = *value
|
|
}
|
|
case taskmodelswitch.FieldRequestID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field request_id", values[i])
|
|
} else if value.Valid {
|
|
_m.RequestID = value.String
|
|
}
|
|
case taskmodelswitch.FieldLoadSession:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field load_session", values[i])
|
|
} else if value.Valid {
|
|
_m.LoadSession = value.Bool
|
|
}
|
|
case taskmodelswitch.FieldSuccess:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field success", values[i])
|
|
} else if value.Valid {
|
|
_m.Success = new(bool)
|
|
*_m.Success = value.Bool
|
|
}
|
|
case taskmodelswitch.FieldMessage:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field message", values[i])
|
|
} else if value.Valid {
|
|
_m.Message = value.String
|
|
}
|
|
case taskmodelswitch.FieldSessionID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field session_id", values[i])
|
|
} else if value.Valid {
|
|
_m.SessionID = value.String
|
|
}
|
|
case taskmodelswitch.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 taskmodelswitch.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 TaskModelSwitch.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *TaskModelSwitch) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryTask queries the "task" edge of the TaskModelSwitch entity.
|
|
func (_m *TaskModelSwitch) QueryTask() *TaskQuery {
|
|
return NewTaskModelSwitchClient(_m.config).QueryTask(_m)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the TaskModelSwitch entity.
|
|
func (_m *TaskModelSwitch) QueryUser() *UserQuery {
|
|
return NewTaskModelSwitchClient(_m.config).QueryUser(_m)
|
|
}
|
|
|
|
// QueryFromModel queries the "from_model" edge of the TaskModelSwitch entity.
|
|
func (_m *TaskModelSwitch) QueryFromModel() *ModelQuery {
|
|
return NewTaskModelSwitchClient(_m.config).QueryFromModel(_m)
|
|
}
|
|
|
|
// QueryToModel queries the "to_model" edge of the TaskModelSwitch entity.
|
|
func (_m *TaskModelSwitch) QueryToModel() *ModelQuery {
|
|
return NewTaskModelSwitchClient(_m.config).QueryToModel(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this TaskModelSwitch.
|
|
// Note that you need to call TaskModelSwitch.Unwrap() before calling this method if this TaskModelSwitch
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *TaskModelSwitch) Update() *TaskModelSwitchUpdateOne {
|
|
return NewTaskModelSwitchClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the TaskModelSwitch 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 *TaskModelSwitch) Unwrap() *TaskModelSwitch {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: TaskModelSwitch is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *TaskModelSwitch) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("TaskModelSwitch(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("task_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.TaskID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("user_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
|
|
builder.WriteString(", ")
|
|
if v := _m.FromModelID; v != nil {
|
|
builder.WriteString("from_model_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("to_model_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ToModelID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("request_id=")
|
|
builder.WriteString(_m.RequestID)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("load_session=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.LoadSession))
|
|
builder.WriteString(", ")
|
|
if v := _m.Success; v != nil {
|
|
builder.WriteString("success=")
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("message=")
|
|
builder.WriteString(_m.Message)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("session_id=")
|
|
builder.WriteString(_m.SessionID)
|
|
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()
|
|
}
|
|
|
|
// TaskModelSwitches is a parsable slice of TaskModelSwitch.
|
|
type TaskModelSwitches []*TaskModelSwitch
|