mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-04 07:43:28 +08:00
- Added WorkspaceFileHandler for handling workspace file operations including create, update, delete, and list functionalities. - Introduced WorkspaceFileRepo for database interactions related to workspace files. - Created WorkspaceFileUsecase to encapsulate business logic for workspace file management. - Implemented API endpoints for workspace file operations with appropriate request and response structures. - Added database migrations for creating workspaces and workspace_files tables with necessary constraints and indexes. - Enhanced user authentication and authorization for workspace file operations.
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/consts"
|
|
)
|
|
|
|
// ApiKey holds the schema definition for the ApiKey entity.
|
|
type ApiKey struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (ApiKey) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.Annotation{
|
|
Table: "api_keys",
|
|
},
|
|
}
|
|
}
|
|
|
|
// Fields of the ApiKey.
|
|
func (ApiKey) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.UUID("id", uuid.UUID{}),
|
|
field.UUID("user_id", uuid.UUID{}),
|
|
field.String("key"),
|
|
field.String("name"),
|
|
field.String("status").GoType(consts.ApiKeyStatus("")).Default(string(consts.ApiKeyStatusActive)),
|
|
field.Time("last_used").Optional(),
|
|
field.Time("created_at").Default(time.Now),
|
|
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
|
}
|
|
}
|
|
|
|
// Edges of the ApiKey.
|
|
func (ApiKey) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.From("user", User.Type).
|
|
Ref("api_keys").
|
|
Field("user_id").
|
|
Required().
|
|
Unique(),
|
|
}
|
|
}
|