mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 03:18:50 +08:00
- 新增 git_bots, git_bot_users, git_bot_tasks, project_git_bots 表 - 添加 user, host, project 到 gitbot 的关联边 - 使用 soft delete 和 created_at 游标
176 lines
5.7 KiB
Go
176 lines
5.7 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/gitbot"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// GitBotUser is the model entity for the GitBotUser schema.
|
|
type GitBotUser struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// GitBotID holds the value of the "git_bot_id" field.
|
|
GitBotID uuid.UUID `json:"git_bot_id,omitempty"`
|
|
// UserID holds the value of the "user_id" field.
|
|
UserID uuid.UUID `json:"user_id,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 GitBotUserQuery when eager-loading is set.
|
|
Edges GitBotUserEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// GitBotUserEdges holds the relations/edges for other nodes in the graph.
|
|
type GitBotUserEdges struct {
|
|
// GitBot holds the value of the git_bot edge.
|
|
GitBot *GitBot `json:"git_bot,omitempty"`
|
|
// User holds the value of the user edge.
|
|
User *User `json:"user,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [2]bool
|
|
}
|
|
|
|
// GitBotOrErr returns the GitBot value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e GitBotUserEdges) GitBotOrErr() (*GitBot, error) {
|
|
if e.GitBot != nil {
|
|
return e.GitBot, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: gitbot.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "git_bot"}
|
|
}
|
|
|
|
// 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 GitBotUserEdges) 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"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*GitBotUser) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case gitbotuser.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case gitbotuser.FieldID, gitbotuser.FieldGitBotID, gitbotuser.FieldUserID:
|
|
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 GitBotUser fields.
|
|
func (_m *GitBotUser) 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 gitbotuser.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 gitbotuser.FieldGitBotID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field git_bot_id", values[i])
|
|
} else if value != nil {
|
|
_m.GitBotID = *value
|
|
}
|
|
case gitbotuser.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 gitbotuser.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 GitBotUser.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *GitBotUser) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryGitBot queries the "git_bot" edge of the GitBotUser entity.
|
|
func (_m *GitBotUser) QueryGitBot() *GitBotQuery {
|
|
return NewGitBotUserClient(_m.config).QueryGitBot(_m)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the GitBotUser entity.
|
|
func (_m *GitBotUser) QueryUser() *UserQuery {
|
|
return NewGitBotUserClient(_m.config).QueryUser(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this GitBotUser.
|
|
// Note that you need to call GitBotUser.Unwrap() before calling this method if this GitBotUser
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *GitBotUser) Update() *GitBotUserUpdateOne {
|
|
return NewGitBotUserClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the GitBotUser 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 *GitBotUser) Unwrap() *GitBotUser {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: GitBotUser is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *GitBotUser) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("GitBotUser(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("git_bot_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.GitBotID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("user_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// GitBotUsers is a parsable slice of GitBotUser.
|
|
type GitBotUsers []*GitBotUser
|