feat: tenant-scoped routing and portal navigation
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
// @provider
|
||||
type Common struct{}
|
||||
|
||||
// @Router /v1/upload [post]
|
||||
// @Router /t/:tenantCode/v1/upload [post]
|
||||
// @Summary Upload file
|
||||
// @Description Upload file
|
||||
// @Tags Common
|
||||
@@ -31,16 +31,17 @@ func (c *Common) Upload(
|
||||
file *multipart.FileHeader,
|
||||
form *dto.UploadForm,
|
||||
) (*dto.UploadResult, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
val := ""
|
||||
if form != nil {
|
||||
val = form.Type
|
||||
}
|
||||
return services.Common.Upload(ctx, user.ID, file, val)
|
||||
return services.Common.Upload(ctx, tenantID, user.ID, file, val)
|
||||
}
|
||||
|
||||
// Get options (enums)
|
||||
//
|
||||
// @Router /v1/common/options [get]
|
||||
// @Router /t/:tenantCode/v1/common/options [get]
|
||||
// @Summary Get options
|
||||
// @Description Get global options (enums)
|
||||
// @Tags Common
|
||||
@@ -53,7 +54,7 @@ func (c *Common) GetOptions(ctx fiber.Ctx) (*dto.OptionsResponse, error) {
|
||||
|
||||
// Check file hash for deduplication
|
||||
//
|
||||
// @Router /v1/upload/check [get]
|
||||
// @Router /t/:tenantCode/v1/upload/check [get]
|
||||
// @Summary Check hash
|
||||
// @Description Check if file hash exists
|
||||
// @Tags Common
|
||||
@@ -64,10 +65,11 @@ func (c *Common) GetOptions(ctx fiber.Ctx) (*dto.OptionsResponse, error) {
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind hash query
|
||||
func (c *Common) CheckHash(ctx fiber.Ctx, user *models.User, hash string) (*dto.UploadResult, error) {
|
||||
return services.Common.CheckHash(ctx, user.ID, hash)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Common.CheckHash(ctx, tenantID, user.ID, hash)
|
||||
}
|
||||
|
||||
// @Router /v1/upload/init [post]
|
||||
// @Router /t/:tenantCode/v1/upload/init [post]
|
||||
// @Summary Init multipart upload
|
||||
// @Description Initialize multipart upload
|
||||
// @Tags Common
|
||||
@@ -78,10 +80,11 @@ func (c *Common) CheckHash(ctx fiber.Ctx, user *models.User, hash string) (*dto.
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind form body
|
||||
func (c *Common) InitUpload(ctx fiber.Ctx, user *models.User, form *dto.UploadInitForm) (*dto.UploadInitResponse, error) {
|
||||
return services.Common.InitUpload(ctx.Context(), user.ID, form)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Common.InitUpload(ctx.Context(), tenantID, user.ID, form)
|
||||
}
|
||||
|
||||
// @Router /v1/upload/part [post]
|
||||
// @Router /t/:tenantCode/v1/upload/part [post]
|
||||
// @Summary Upload part
|
||||
// @Description Upload a part
|
||||
// @Tags Common
|
||||
@@ -94,10 +97,11 @@ func (c *Common) InitUpload(ctx fiber.Ctx, user *models.User, form *dto.UploadIn
|
||||
// @Bind file file
|
||||
// @Bind form body
|
||||
func (c *Common) UploadPart(ctx fiber.Ctx, user *models.User, file *multipart.FileHeader, form *dto.UploadPartForm) error {
|
||||
return services.Common.UploadPart(ctx.Context(), user.ID, file, form)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Common.UploadPart(ctx.Context(), tenantID, user.ID, file, form)
|
||||
}
|
||||
|
||||
// @Router /v1/upload/complete [post]
|
||||
// @Router /t/:tenantCode/v1/upload/complete [post]
|
||||
// @Summary Complete upload
|
||||
// @Description Complete multipart upload
|
||||
// @Tags Common
|
||||
@@ -108,10 +112,11 @@ func (c *Common) UploadPart(ctx fiber.Ctx, user *models.User, file *multipart.Fi
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind form body
|
||||
func (c *Common) CompleteUpload(ctx fiber.Ctx, user *models.User, form *dto.UploadCompleteForm) (*dto.UploadResult, error) {
|
||||
return services.Common.CompleteUpload(ctx.Context(), user.ID, form)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Common.CompleteUpload(ctx.Context(), tenantID, user.ID, form)
|
||||
}
|
||||
|
||||
// @Router /v1/upload/:uploadId [delete]
|
||||
// @Router /t/:tenantCode/v1/upload/:uploadId [delete]
|
||||
// @Summary Abort upload
|
||||
// @Description Abort multipart upload
|
||||
// @Tags Common
|
||||
@@ -122,10 +127,11 @@ func (c *Common) CompleteUpload(ctx fiber.Ctx, user *models.User, form *dto.Uplo
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind uploadId path
|
||||
func (c *Common) AbortUpload(ctx fiber.Ctx, user *models.User, uploadId string) error {
|
||||
return services.Common.AbortUpload(ctx.Context(), user.ID, uploadId)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Common.AbortUpload(ctx.Context(), tenantID, user.ID, uploadId)
|
||||
}
|
||||
|
||||
// @Router /v1/media-assets/:id<int> [delete]
|
||||
// @Router /t/:tenantCode/v1/media-assets/:id<int> [delete]
|
||||
// @Summary Delete media asset
|
||||
// @Description Delete media asset
|
||||
// @Tags Common
|
||||
@@ -136,7 +142,8 @@ func (c *Common) AbortUpload(ctx fiber.Ctx, user *models.User, uploadId string)
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind id path
|
||||
func (c *Common) DeleteMediaAsset(ctx fiber.Ctx, user *models.User, id int64) error {
|
||||
return services.Common.DeleteMediaAsset(ctx.Context(), user.ID, id)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Common.DeleteMediaAsset(ctx.Context(), tenantID, user.ID, id)
|
||||
}
|
||||
|
||||
// Upload file
|
||||
|
||||
Reference in New Issue
Block a user