mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 11:28:46 +08:00
256 lines
9.3 KiB
Go
256 lines
9.3 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/projectissue"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissuecomment"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ProjectIssueComment is the model entity for the ProjectIssueComment schema.
|
|
type ProjectIssueComment struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// DeletedAt holds the value of the "deleted_at" field.
|
|
DeletedAt time.Time `json:"deleted_at,omitempty"`
|
|
// UserID holds the value of the "user_id" field.
|
|
UserID uuid.UUID `json:"user_id,omitempty"`
|
|
// IssueID holds the value of the "issue_id" field.
|
|
IssueID uuid.UUID `json:"issue_id,omitempty"`
|
|
// ParentID holds the value of the "parent_id" field.
|
|
ParentID uuid.UUID `json:"parent_id,omitempty"`
|
|
// Comment holds the value of the "comment" field.
|
|
Comment string `json:"comment,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 ProjectIssueCommentQuery when eager-loading is set.
|
|
Edges ProjectIssueCommentEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// ProjectIssueCommentEdges holds the relations/edges for other nodes in the graph.
|
|
type ProjectIssueCommentEdges struct {
|
|
// User holds the value of the user edge.
|
|
User *User `json:"user,omitempty"`
|
|
// Issue holds the value of the issue edge.
|
|
Issue *ProjectIssue `json:"issue,omitempty"`
|
|
// Parent holds the value of the parent edge.
|
|
Parent *ProjectIssueComment `json:"parent,omitempty"`
|
|
// Replies holds the value of the replies edge.
|
|
Replies []*ProjectIssueComment `json:"replies,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [4]bool
|
|
}
|
|
|
|
// 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 ProjectIssueCommentEdges) UserOrErr() (*User, error) {
|
|
if e.User != nil {
|
|
return e.User, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: user.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "user"}
|
|
}
|
|
|
|
// 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 ProjectIssueCommentEdges) IssueOrErr() (*ProjectIssue, error) {
|
|
if e.Issue != nil {
|
|
return e.Issue, nil
|
|
} else if e.loadedTypes[1] {
|
|
return nil, &NotFoundError{label: projectissue.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "issue"}
|
|
}
|
|
|
|
// ParentOrErr returns the Parent value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e ProjectIssueCommentEdges) ParentOrErr() (*ProjectIssueComment, error) {
|
|
if e.Parent != nil {
|
|
return e.Parent, nil
|
|
} else if e.loadedTypes[2] {
|
|
return nil, &NotFoundError{label: projectissuecomment.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "parent"}
|
|
}
|
|
|
|
// RepliesOrErr returns the Replies value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e ProjectIssueCommentEdges) RepliesOrErr() ([]*ProjectIssueComment, error) {
|
|
if e.loadedTypes[3] {
|
|
return e.Replies, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "replies"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*ProjectIssueComment) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case projectissuecomment.FieldComment:
|
|
values[i] = new(sql.NullString)
|
|
case projectissuecomment.FieldDeletedAt, projectissuecomment.FieldCreatedAt, projectissuecomment.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case projectissuecomment.FieldID, projectissuecomment.FieldUserID, projectissuecomment.FieldIssueID, projectissuecomment.FieldParentID:
|
|
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 ProjectIssueComment fields.
|
|
func (_m *ProjectIssueComment) 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 projectissuecomment.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 projectissuecomment.FieldDeletedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
|
} else if value.Valid {
|
|
_m.DeletedAt = value.Time
|
|
}
|
|
case projectissuecomment.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 projectissuecomment.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 projectissuecomment.FieldParentID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field parent_id", values[i])
|
|
} else if value != nil {
|
|
_m.ParentID = *value
|
|
}
|
|
case projectissuecomment.FieldComment:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field comment", values[i])
|
|
} else if value.Valid {
|
|
_m.Comment = value.String
|
|
}
|
|
case projectissuecomment.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 projectissuecomment.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 ProjectIssueComment.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *ProjectIssueComment) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the ProjectIssueComment entity.
|
|
func (_m *ProjectIssueComment) QueryUser() *UserQuery {
|
|
return NewProjectIssueCommentClient(_m.config).QueryUser(_m)
|
|
}
|
|
|
|
// QueryIssue queries the "issue" edge of the ProjectIssueComment entity.
|
|
func (_m *ProjectIssueComment) QueryIssue() *ProjectIssueQuery {
|
|
return NewProjectIssueCommentClient(_m.config).QueryIssue(_m)
|
|
}
|
|
|
|
// QueryParent queries the "parent" edge of the ProjectIssueComment entity.
|
|
func (_m *ProjectIssueComment) QueryParent() *ProjectIssueCommentQuery {
|
|
return NewProjectIssueCommentClient(_m.config).QueryParent(_m)
|
|
}
|
|
|
|
// QueryReplies queries the "replies" edge of the ProjectIssueComment entity.
|
|
func (_m *ProjectIssueComment) QueryReplies() *ProjectIssueCommentQuery {
|
|
return NewProjectIssueCommentClient(_m.config).QueryReplies(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this ProjectIssueComment.
|
|
// Note that you need to call ProjectIssueComment.Unwrap() before calling this method if this ProjectIssueComment
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *ProjectIssueComment) Update() *ProjectIssueCommentUpdateOne {
|
|
return NewProjectIssueCommentClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the ProjectIssueComment 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 *ProjectIssueComment) Unwrap() *ProjectIssueComment {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: ProjectIssueComment is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *ProjectIssueComment) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("ProjectIssueComment(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("deleted_at=")
|
|
builder.WriteString(_m.DeletedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("user_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("issue_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.IssueID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("parent_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ParentID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("comment=")
|
|
builder.WriteString(_m.Comment)
|
|
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()
|
|
}
|
|
|
|
// ProjectIssueComments is a parsable slice of ProjectIssueComment.
|
|
type ProjectIssueComments []*ProjectIssueComment
|