2026-03-18 18:25:32 +08:00
|
|
|
// 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/consts"
|
2026-03-18 18:25:40 +08:00
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
2026-03-18 18:25:32 +08:00
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/image"
|
|
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/model"
|
2026-03-18 18:25:40 +08:00
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissue"
|
2026-03-18 18:25:32 +08:00
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
|
|
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ProjectTask is the model entity for the ProjectTask schema.
|
|
|
|
|
type ProjectTask 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"`
|
|
|
|
|
// ModelID holds the value of the "model_id" field.
|
|
|
|
|
ModelID uuid.UUID `json:"model_id,omitempty"`
|
|
|
|
|
// ImageID holds the value of the "image_id" field.
|
|
|
|
|
ImageID uuid.UUID `json:"image_id,omitempty"`
|
|
|
|
|
// GitIdentityID holds the value of the "git_identity_id" field.
|
|
|
|
|
GitIdentityID uuid.UUID `json:"git_identity_id,omitempty"`
|
|
|
|
|
// ProjectID holds the value of the "project_id" field.
|
|
|
|
|
ProjectID *uuid.UUID `json:"project_id,omitempty"`
|
|
|
|
|
// IssueID holds the value of the "issue_id" field.
|
|
|
|
|
IssueID uuid.UUID `json:"issue_id,omitempty"`
|
|
|
|
|
// RepoURL holds the value of the "repo_url" field.
|
|
|
|
|
RepoURL string `json:"repo_url,omitempty"`
|
|
|
|
|
// RepoFilename holds the value of the "repo_filename" field.
|
|
|
|
|
RepoFilename string `json:"repo_filename,omitempty"`
|
|
|
|
|
// Branch holds the value of the "branch" field.
|
|
|
|
|
Branch string `json:"branch,omitempty"`
|
|
|
|
|
// CliName holds the value of the "cli_name" field.
|
|
|
|
|
CliName consts.CliName `json:"cli_name,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 ProjectTaskQuery when eager-loading is set.
|
|
|
|
|
Edges ProjectTaskEdges `json:"edges"`
|
|
|
|
|
selectValues sql.SelectValues
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProjectTaskEdges holds the relations/edges for other nodes in the graph.
|
|
|
|
|
type ProjectTaskEdges struct {
|
|
|
|
|
// Task holds the value of the task edge.
|
|
|
|
|
Task *Task `json:"task,omitempty"`
|
|
|
|
|
// Model holds the value of the model edge.
|
|
|
|
|
Model *Model `json:"model,omitempty"`
|
|
|
|
|
// Image holds the value of the image edge.
|
|
|
|
|
Image *Image `json:"image,omitempty"`
|
2026-03-18 18:25:40 +08:00
|
|
|
// GitIdentity holds the value of the git_identity edge.
|
|
|
|
|
GitIdentity *GitIdentity `json:"git_identity,omitempty"`
|
|
|
|
|
// Project holds the value of the project edge.
|
|
|
|
|
Project *Project `json:"project,omitempty"`
|
|
|
|
|
// Issue holds the value of the issue edge.
|
|
|
|
|
Issue *ProjectIssue `json:"issue,omitempty"`
|
2026-03-18 18:25:32 +08:00
|
|
|
// loadedTypes holds the information for reporting if a
|
|
|
|
|
// type was loaded (or requested) in eager-loading or not.
|
2026-03-18 18:25:40 +08:00
|
|
|
loadedTypes [6]bool
|
2026-03-18 18:25:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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 ProjectTaskEdges) 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"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ModelOrErr returns the Model value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
|
|
|
func (e ProjectTaskEdges) ModelOrErr() (*Model, error) {
|
|
|
|
|
if e.Model != nil {
|
|
|
|
|
return e.Model, nil
|
|
|
|
|
} else if e.loadedTypes[1] {
|
|
|
|
|
return nil, &NotFoundError{label: model.Label}
|
|
|
|
|
}
|
|
|
|
|
return nil, &NotLoadedError{edge: "model"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ImageOrErr returns the Image value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
|
|
|
func (e ProjectTaskEdges) ImageOrErr() (*Image, error) {
|
|
|
|
|
if e.Image != nil {
|
|
|
|
|
return e.Image, nil
|
|
|
|
|
} else if e.loadedTypes[2] {
|
|
|
|
|
return nil, &NotFoundError{label: image.Label}
|
|
|
|
|
}
|
|
|
|
|
return nil, &NotLoadedError{edge: "image"}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 18:25:40 +08:00
|
|
|
// GitIdentityOrErr returns the GitIdentity value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
|
|
|
func (e ProjectTaskEdges) GitIdentityOrErr() (*GitIdentity, error) {
|
|
|
|
|
if e.GitIdentity != nil {
|
|
|
|
|
return e.GitIdentity, nil
|
|
|
|
|
} else if e.loadedTypes[3] {
|
|
|
|
|
return nil, &NotFoundError{label: gitidentity.Label}
|
|
|
|
|
}
|
|
|
|
|
return nil, &NotLoadedError{edge: "git_identity"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProjectOrErr returns the Project value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
|
|
|
func (e ProjectTaskEdges) ProjectOrErr() (*Project, error) {
|
|
|
|
|
if e.Project != nil {
|
|
|
|
|
return e.Project, nil
|
|
|
|
|
} else if e.loadedTypes[4] {
|
|
|
|
|
return nil, &NotFoundError{label: project.Label}
|
|
|
|
|
}
|
|
|
|
|
return nil, &NotLoadedError{edge: "project"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IssueOrErr returns the Issue value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
|
|
|
func (e ProjectTaskEdges) IssueOrErr() (*ProjectIssue, error) {
|
|
|
|
|
if e.Issue != nil {
|
|
|
|
|
return e.Issue, nil
|
|
|
|
|
} else if e.loadedTypes[5] {
|
|
|
|
|
return nil, &NotFoundError{label: projectissue.Label}
|
|
|
|
|
}
|
|
|
|
|
return nil, &NotLoadedError{edge: "issue"}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 18:25:32 +08:00
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
|
|
|
func (*ProjectTask) scanValues(columns []string) ([]any, error) {
|
|
|
|
|
values := make([]any, len(columns))
|
|
|
|
|
for i := range columns {
|
|
|
|
|
switch columns[i] {
|
|
|
|
|
case projecttask.FieldProjectID:
|
|
|
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
|
|
|
case projecttask.FieldRepoURL, projecttask.FieldRepoFilename, projecttask.FieldBranch, projecttask.FieldCliName:
|
|
|
|
|
values[i] = new(sql.NullString)
|
|
|
|
|
case projecttask.FieldCreatedAt:
|
|
|
|
|
values[i] = new(sql.NullTime)
|
|
|
|
|
case projecttask.FieldID, projecttask.FieldTaskID, projecttask.FieldModelID, projecttask.FieldImageID, projecttask.FieldGitIdentityID, projecttask.FieldIssueID:
|
|
|
|
|
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 ProjectTask fields.
|
|
|
|
|
func (_m *ProjectTask) 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 projecttask.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 projecttask.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 projecttask.FieldModelID:
|
|
|
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field model_id", values[i])
|
|
|
|
|
} else if value != nil {
|
|
|
|
|
_m.ModelID = *value
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldImageID:
|
|
|
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field image_id", values[i])
|
|
|
|
|
} else if value != nil {
|
|
|
|
|
_m.ImageID = *value
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldGitIdentityID:
|
|
|
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field git_identity_id", values[i])
|
|
|
|
|
} else if value != nil {
|
|
|
|
|
_m.GitIdentityID = *value
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldProjectID:
|
|
|
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field project_id", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.ProjectID = new(uuid.UUID)
|
|
|
|
|
*_m.ProjectID = *value.S.(*uuid.UUID)
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldIssueID:
|
|
|
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field issue_id", values[i])
|
|
|
|
|
} else if value != nil {
|
|
|
|
|
_m.IssueID = *value
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldRepoURL:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field repo_url", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.RepoURL = value.String
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldRepoFilename:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field repo_filename", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.RepoFilename = value.String
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldBranch:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field branch", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.Branch = value.String
|
|
|
|
|
}
|
|
|
|
|
case projecttask.FieldCliName:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field cli_name", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.CliName = consts.CliName(value.String)
|
|
|
|
|
}
|
|
|
|
|
case projecttask.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 ProjectTask.
|
|
|
|
|
// This includes values selected through modifiers, order, etc.
|
|
|
|
|
func (_m *ProjectTask) Value(name string) (ent.Value, error) {
|
|
|
|
|
return _m.selectValues.Get(name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QueryTask queries the "task" edge of the ProjectTask entity.
|
|
|
|
|
func (_m *ProjectTask) QueryTask() *TaskQuery {
|
|
|
|
|
return NewProjectTaskClient(_m.config).QueryTask(_m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QueryModel queries the "model" edge of the ProjectTask entity.
|
|
|
|
|
func (_m *ProjectTask) QueryModel() *ModelQuery {
|
|
|
|
|
return NewProjectTaskClient(_m.config).QueryModel(_m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QueryImage queries the "image" edge of the ProjectTask entity.
|
|
|
|
|
func (_m *ProjectTask) QueryImage() *ImageQuery {
|
|
|
|
|
return NewProjectTaskClient(_m.config).QueryImage(_m)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 18:25:40 +08:00
|
|
|
// QueryGitIdentity queries the "git_identity" edge of the ProjectTask entity.
|
|
|
|
|
func (_m *ProjectTask) QueryGitIdentity() *GitIdentityQuery {
|
|
|
|
|
return NewProjectTaskClient(_m.config).QueryGitIdentity(_m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QueryProject queries the "project" edge of the ProjectTask entity.
|
|
|
|
|
func (_m *ProjectTask) QueryProject() *ProjectQuery {
|
|
|
|
|
return NewProjectTaskClient(_m.config).QueryProject(_m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QueryIssue queries the "issue" edge of the ProjectTask entity.
|
|
|
|
|
func (_m *ProjectTask) QueryIssue() *ProjectIssueQuery {
|
|
|
|
|
return NewProjectTaskClient(_m.config).QueryIssue(_m)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 18:25:32 +08:00
|
|
|
// Update returns a builder for updating this ProjectTask.
|
|
|
|
|
// Note that you need to call ProjectTask.Unwrap() before calling this method if this ProjectTask
|
|
|
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
|
|
|
func (_m *ProjectTask) Update() *ProjectTaskUpdateOne {
|
|
|
|
|
return NewProjectTaskClient(_m.config).UpdateOne(_m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Unwrap unwraps the ProjectTask 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 *ProjectTask) Unwrap() *ProjectTask {
|
|
|
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
|
|
|
if !ok {
|
|
|
|
|
panic("db: ProjectTask is not a transactional entity")
|
|
|
|
|
}
|
|
|
|
|
_m.config.driver = _tx.drv
|
|
|
|
|
return _m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer.
|
|
|
|
|
func (_m *ProjectTask) String() string {
|
|
|
|
|
var builder strings.Builder
|
|
|
|
|
builder.WriteString("ProjectTask(")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
|
|
|
builder.WriteString("task_id=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.TaskID))
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("model_id=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ModelID))
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("image_id=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ImageID))
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("git_identity_id=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.GitIdentityID))
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
if v := _m.ProjectID; v != nil {
|
|
|
|
|
builder.WriteString("project_id=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
|
|
|
}
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("issue_id=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.IssueID))
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("repo_url=")
|
|
|
|
|
builder.WriteString(_m.RepoURL)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("repo_filename=")
|
|
|
|
|
builder.WriteString(_m.RepoFilename)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("branch=")
|
|
|
|
|
builder.WriteString(_m.Branch)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("cli_name=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CliName))
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("created_at=")
|
|
|
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
|
|
|
builder.WriteByte(')')
|
|
|
|
|
return builder.String()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProjectTasks is a parsable slice of ProjectTask.
|
|
|
|
|
type ProjectTasks []*ProjectTask
|