Files
MonkeyCode/backend/ent/schema/apikey.go
Haoxin Li b5ecb92371 feat: feat: Implement workspace and real-time file synchronization
- 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.
2025-07-23 17:42:20 +08:00

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(),
}
}