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
@@ -158,6 +158,36 @@ func (c *aliyunClient) GetBytes(ctx context.Context, objectKey string) ([]byte,
return data, nil
}
func (c *aliyunClient) Exists(ctx context.Context, objectKey string) (bool, error) {
if err := c.Validate(); err != nil {
return false, err
}
if strings.TrimSpace(objectKey) == "" {
return false, nil
}
bucket, err := c.client.Bucket(c.bucket)
if err != nil {
c.logError(ctx, "aliyun get bucket failed",
zap.String("bucket", c.bucket),
zap.String("object_key", objectKey),
zap.Error(err),
)
return false, fmt.Errorf("get aliyun bucket: %w", err)
}
exists, err := bucket.IsObjectExist(objectKey)
if err != nil {
c.logError(ctx, "aliyun stat object failed",
zap.String("bucket", c.bucket),
zap.String("object_key", objectKey),
zap.Error(err),
)
return false, fmt.Errorf("stat aliyun object: %w", err)
}
return exists, nil
}
func (c *aliyunClient) Delete(ctx context.Context, objectKey string) error {
if err := c.Validate(); err != nil {
return err