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
@@ -135,6 +135,32 @@ func (c *minioClient) GetBytes(ctx context.Context, objectKey string) ([]byte, e
return data, nil
}
func (c *minioClient) Exists(ctx context.Context, objectKey string) (bool, error) {
if err := c.Validate(); err != nil {
return false, err
}
if strings.TrimSpace(objectKey) == "" {
return false, nil
}
_, err := c.client.StatObject(ctx, c.bucket, objectKey, minio.StatObjectOptions{})
if err == nil {
return true, nil
}
responseErr := minio.ToErrorResponse(err)
if responseErr.StatusCode == 404 || responseErr.Code == "NoSuchKey" || responseErr.Code == "NoSuchObject" {
return false, nil
}
c.logError(ctx, "minio stat object failed",
zap.String("bucket", c.bucket),
zap.String("object_key", objectKey),
zap.Error(err),
)
return false, fmt.Errorf("stat minio object: %w", err)
}
func (c *minioClient) Delete(ctx context.Context, objectKey string) error {
if err := c.Validate(); err != nil {
return err