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.9 KiB
Go
176 lines
5.9 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/teamgroup"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teamgroupimage"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// TeamGroupImage is the model entity for the TeamGroupImage schema.
|
|
type TeamGroupImage struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// GroupID holds the value of the "group_id" field.
|
|
GroupID uuid.UUID `json:"group_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 TeamGroupImageQuery when eager-loading is set.
|
|
Edges TeamGroupImageEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// TeamGroupImageEdges holds the relations/edges for other nodes in the graph.
|
|
type TeamGroupImageEdges struct {
|
|
// Group holds the value of the group edge.
|
|
Group *TeamGroup `json:"group,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
|
|
}
|
|
|
|
// GroupOrErr returns the Group value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e TeamGroupImageEdges) GroupOrErr() (*TeamGroup, error) {
|
|
if e.Group != nil {
|
|
return e.Group, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: teamgroup.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "group"}
|
|
}
|
|
|
|
// 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 TeamGroupImageEdges) 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 (*TeamGroupImage) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case teamgroupimage.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case teamgroupimage.FieldID, teamgroupimage.FieldGroupID, teamgroupimage.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 TeamGroupImage fields.
|
|
func (_m *TeamGroupImage) 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 teamgroupimage.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 teamgroupimage.FieldGroupID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
|
} else if value != nil {
|
|
_m.GroupID = *value
|
|
}
|
|
case teamgroupimage.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 teamgroupimage.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 TeamGroupImage.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *TeamGroupImage) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the TeamGroupImage entity.
|
|
func (_m *TeamGroupImage) QueryGroup() *TeamGroupQuery {
|
|
return NewTeamGroupImageClient(_m.config).QueryGroup(_m)
|
|
}
|
|
|
|
// QueryImage queries the "image" edge of the TeamGroupImage entity.
|
|
func (_m *TeamGroupImage) QueryImage() *ImageQuery {
|
|
return NewTeamGroupImageClient(_m.config).QueryImage(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this TeamGroupImage.
|
|
// Note that you need to call TeamGroupImage.Unwrap() before calling this method if this TeamGroupImage
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *TeamGroupImage) Update() *TeamGroupImageUpdateOne {
|
|
return NewTeamGroupImageClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the TeamGroupImage 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 *TeamGroupImage) Unwrap() *TeamGroupImage {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: TeamGroupImage is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *TeamGroupImage) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("TeamGroupImage(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("group_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.GroupID))
|
|
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()
|
|
}
|
|
|
|
// TeamGroupImages is a parsable slice of TeamGroupImage.
|
|
type TeamGroupImages []*TeamGroupImage
|