feat: add image management functionality

- Implemented image folder repository with CRUD operations.
- Added image reference repository for managing image references to articles.
- Created image repository for handling image assets, including listing, inserting, updating, and deleting images.
- Introduced image usage repository to track storage usage and quotas for tenants.
- Added SQL queries for image assets, folders, references, and usage.
- Developed image handler for HTTP endpoints to manage images and folders.
- Created database migration scripts for image-related tables and structures.
This commit is contained in:
2026-04-16 20:40:41 +08:00
parent 0a3558fc51
commit 27389164b0
57 changed files with 8063 additions and 153 deletions
@@ -136,6 +136,38 @@ type GenerationTask struct {
OperatorID pgtype.Int8 `json:"operator_id"`
}
type ImageAsset struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
FolderID pgtype.Int8 `json:"folder_id"`
ObjectKey string `json:"object_key"`
Name string `json:"name"`
SizeBytes int64 `json:"size_bytes"`
Status string `json:"status"`
CreatedBy int64 `json:"created_by"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type ImageAssetReference struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
ImageAssetID int64 `json:"image_asset_id"`
ArticleID int64 `json:"article_id"`
RefScope string `json:"ref_scope"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type ImageFolder struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
Name string `json:"name"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type KnowledgeChunksMetum struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
@@ -357,20 +389,23 @@ type QuotaReservation struct {
}
type ScheduleTask struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PromptRuleID int64 `json:"prompt_rule_id"`
BrandID pgtype.Int8 `json:"brand_id"`
Name string `json:"name"`
CronExpr string `json:"cron_expr"`
TargetPlatform pgtype.Text `json:"target_platform"`
StartAt pgtype.Timestamptz `json:"start_at"`
EndAt pgtype.Timestamptz `json:"end_at"`
NextRunAt pgtype.Timestamptz `json:"next_run_at"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PromptRuleID int64 `json:"prompt_rule_id"`
BrandID pgtype.Int8 `json:"brand_id"`
Name string `json:"name"`
CronExpr string `json:"cron_expr"`
TargetPlatform pgtype.Text `json:"target_platform"`
StartAt pgtype.Timestamptz `json:"start_at"`
EndAt pgtype.Timestamptz `json:"end_at"`
NextRunAt pgtype.Timestamptz `json:"next_run_at"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
OperatorID pgtype.Int8 `json:"operator_id"`
EnableWebSearch bool `json:"enable_web_search"`
GenerateCount int32 `json:"generate_count"`
}
type TaskRecord struct {
@@ -414,6 +449,12 @@ type Tenant struct {
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type TenantImageStorageUsage struct {
TenantID int64 `json:"tenant_id"`
UsedBytes int64 `json:"used_bytes"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type TenantMembership struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
@@ -424,6 +465,20 @@ type TenantMembership struct {
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type TenantMonitoringQuota struct {
TenantID int64 `json:"tenant_id"`
MaxBrands int32 `json:"max_brands"`
CollectionMode string `json:"collection_mode"`
QuestionSelectionMode string `json:"question_selection_mode"`
CollectFrequency string `json:"collect_frequency"`
EnabledPlatforms []byte `json:"enabled_platforms"`
PrimaryInstallationID pgtype.Int8 `json:"primary_installation_id"`
TaskDailyHardCap int32 `json:"task_daily_hard_cap"`
PlanTier string `json:"plan_tier"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type TenantPlanSubscription struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`