mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 00:56:37 +08:00
feat(contracts): provide SystemConfigService, UploadService and TaskService.GetExecutionByTaskID
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SystemConfigDTO represents a system configuration key-value entry.
|
||||
type SystemConfigDTO struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Type string `json:"type"`
|
||||
Visibility int `json:"visibility"`
|
||||
Description string `json:"description"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// SystemConfigService defines the unified contract for querying and mutating system configurations.
|
||||
type SystemConfigService interface {
|
||||
GetByKey(ctx context.Context, key string) (SystemConfigDTO, error)
|
||||
ListByKeys(ctx context.Context, keys []string) (map[string]SystemConfigDTO, error)
|
||||
ListVisible(ctx context.Context) ([]SystemConfigDTO, error)
|
||||
ListByType(ctx context.Context, configType string) ([]SystemConfigDTO, error)
|
||||
GetIntByKey(ctx context.Context, key string) (int, error)
|
||||
GetBoolByKey(ctx context.Context, key string) (bool, error)
|
||||
SaveOrUpdate(ctx context.Context, key, value string) error
|
||||
InvalidateCache(ctx context.Context, key string) error
|
||||
InvalidateAllCaches(ctx context.Context) error
|
||||
}
|
||||
@@ -90,4 +90,5 @@ type TaskService interface {
|
||||
AppendLog(ctx context.Context, format string, args ...any)
|
||||
ListExecutions(ctx context.Context, taskType, status string, page, pageSize int) ([]TaskExecutionDTO, int64, error)
|
||||
GetExecution(ctx context.Context, id uint64) (*TaskExecutionDTO, error)
|
||||
GetExecutionByTaskID(ctx context.Context, taskID string) (*TaskExecutionDTO, error)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UploadDTO represents an uploaded file record.
|
||||
type UploadDTO struct {
|
||||
ID uint64 `json:"id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
FileName string `json:"file_name"`
|
||||
FilePath string `json:"file_path"`
|
||||
MimeType string `json:"mime_type"`
|
||||
Size int64 `json:"size"`
|
||||
Hash string `json:"hash"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// OpenedUploadDTO encapsulates the retrieved object stream and its metadata.
|
||||
type OpenedUploadDTO struct {
|
||||
Upload UploadDTO
|
||||
Body io.ReadCloser
|
||||
ContentType string
|
||||
ContentLength int64
|
||||
}
|
||||
|
||||
// UploadService defines the unified contract for managed file uploads and media entities.
|
||||
type UploadService interface {
|
||||
GetByID(ctx context.Context, id uint64) (*UploadDTO, error)
|
||||
OpenStoredUpload(ctx context.Context, id uint64) (*OpenedUploadDTO, error)
|
||||
Remove(ctx context.Context, id uint64) error
|
||||
RemoveOwned(ctx context.Context, id uint64, userID uint64) error
|
||||
FindByHash(ctx context.Context, hash string, size int64) (*UploadDTO, error)
|
||||
RebuildStats(ctx context.Context) error
|
||||
}
|
||||
Reference in New Issue
Block a user