feat: Refactor user context handling and service methods
- Updated middleware to fetch user and tenant models by ID and set them in context. - Refactored common service methods to accept userID as a parameter instead of extracting from context. - Modified content service methods to include userID as a parameter for better clarity and performance. - Adjusted coupon, creator, notification, order, tenant, user, and wallet services to utilize userID directly. - Enhanced context key constants for improved readability and maintainability.
This commit is contained in:
@@ -5,8 +5,10 @@ import (
|
||||
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
// @provider
|
||||
@@ -30,5 +32,6 @@ func (c *Common) Upload(ctx fiber.Ctx, file *multipart.FileHeader, typeArg *stri
|
||||
if typeArg != nil {
|
||||
val = *typeArg
|
||||
}
|
||||
return services.Common.Upload(ctx, file, val)
|
||||
uid := cast.ToInt64(ctx.Locals(consts.CtxKeyUser))
|
||||
return services.Common.Upload(ctx.Context(), uid, file, val)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user