mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
从内部项目迁移模型配置和镜像配置模块,包括个人用户设置和团队级管理, 涵盖完整 CRUD、健康检查、供应商模型列表、所有权模型和 Swagger 注释。 - Ent schema: model, image, team_model, team_image, team_group_model, team_group_image - Domain 层: 接口、请求/响应类型、From 转换器 - Setting 模块: 个人模型/镜像 repo、usecase(代理重试、健康检查)、handler - Team 模块: 团队模型/镜像 repo、usecase、handler(TeamAuth + 审计中间件) - SQL 迁移: 000002_model_image up/down
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/image"
|
|
"github.com/chaitin/MonkeyCode/backend/db/team"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teamimage"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// TeamImage is the model entity for the TeamImage schema.
|
|
type TeamImage struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// TeamID holds the value of the "team_id" field.
|
|
TeamID uuid.UUID `json:"team_id,omitempty"`
|
|
// ImageID holds the value of the "image_id" field.
|
|
ImageID uuid.UUID `json:"image_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 TeamImageQuery when eager-loading is set.
|
|
Edges TeamImageEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// TeamImageEdges holds the relations/edges for other nodes in the graph.
|
|
type TeamImageEdges struct {
|
|
// Team holds the value of the team edge.
|
|
Team *Team `json:"team,omitempty"`
|
|
// Image holds the value of the image edge.
|
|
Image *Image `json:"image,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [2]bool
|
|
}
|
|
|
|
// TeamOrErr returns the Team value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e TeamImageEdges) TeamOrErr() (*Team, error) {
|
|
if e.Team != nil {
|
|
return e.Team, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: team.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "team"}
|
|
}
|
|
|
|
// 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 TeamImageEdges) ImageOrErr() (*Image, error) {
|
|
if e.Image != nil {
|
|
return e.Image, nil
|
|
} else if e.loadedTypes[1] {
|
|
return nil, &NotFoundError{label: image.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "image"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*TeamImage) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case teamimage.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case teamimage.FieldID, teamimage.FieldTeamID, teamimage.FieldImageID:
|
|
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 TeamImage fields.
|
|
func (_m *TeamImage) 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 teamimage.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 teamimage.FieldTeamID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field team_id", values[i])
|
|
} else if value != nil {
|
|
_m.TeamID = *value
|
|
}
|
|
case teamimage.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 teamimage.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 TeamImage.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *TeamImage) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryTeam queries the "team" edge of the TeamImage entity.
|
|
func (_m *TeamImage) QueryTeam() *TeamQuery {
|
|
return NewTeamImageClient(_m.config).QueryTeam(_m)
|
|
}
|
|
|
|
// QueryImage queries the "image" edge of the TeamImage entity.
|
|
func (_m *TeamImage) QueryImage() *ImageQuery {
|
|
return NewTeamImageClient(_m.config).QueryImage(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this TeamImage.
|
|
// Note that you need to call TeamImage.Unwrap() before calling this method if this TeamImage
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *TeamImage) Update() *TeamImageUpdateOne {
|
|
return NewTeamImageClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the TeamImage 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 *TeamImage) Unwrap() *TeamImage {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: TeamImage is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *TeamImage) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("TeamImage(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("team_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.TeamID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("image_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ImageID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// TeamImages is a parsable slice of TeamImage.
|
|
type TeamImages []*TeamImage
|