mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-25 13:48:18 +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
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package schema
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/chaitin/MonkeyCode/backend/pkg/entx"
|
|
)
|
|
|
|
// Team holds the schema definition for the Team entity.
|
|
type Team struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (Team) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.Table("teams"),
|
|
}
|
|
}
|
|
|
|
func (Team) Mixin() []ent.Mixin {
|
|
return []ent.Mixin{
|
|
entx.SoftDeleteMixin2{},
|
|
}
|
|
}
|
|
|
|
// Fields of the Team.
|
|
func (Team) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.UUID("id", uuid.UUID{}).Unique(),
|
|
field.String("name").NotEmpty(),
|
|
field.Int("member_limit"),
|
|
field.Time("created_at").Default(time.Now),
|
|
field.Time("updated_at").Default(time.Now),
|
|
}
|
|
}
|
|
|
|
// Edges of the Team.
|
|
func (Team) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("groups", TeamGroup.Type),
|
|
edge.From("members", User.Type).Ref("teams").Through("team_members", TeamMember.Type),
|
|
edge.To("models", Model.Type).Through("team_models", TeamModel.Type),
|
|
edge.To("images", Image.Type).Through("team_images", TeamImage.Type),
|
|
}
|
|
}
|