refactor: 移除不必要的上下文调用,简化服务方法参数
This commit is contained in:
@@ -22,7 +22,7 @@ type User struct{}
|
||||
// @Produce json
|
||||
// @Success 200 {object} auth_dto.User
|
||||
func (u *User) Me(ctx fiber.Ctx) (*auth_dto.User, error) {
|
||||
return services.User.Me(ctx.Context())
|
||||
return services.User.Me(ctx)
|
||||
}
|
||||
|
||||
// Update user profile
|
||||
@@ -37,7 +37,7 @@ func (u *User) Me(ctx fiber.Ctx) (*auth_dto.User, error) {
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind form body
|
||||
func (u *User) Update(ctx fiber.Ctx, form *dto.UserUpdate) error {
|
||||
return services.User.Update(ctx.Context(), form)
|
||||
return services.User.Update(ctx, form)
|
||||
}
|
||||
|
||||
// Submit real-name authentication
|
||||
@@ -52,7 +52,7 @@ func (u *User) Update(ctx fiber.Ctx, form *dto.UserUpdate) error {
|
||||
// @Success 200 {string} string "Submitted"
|
||||
// @Bind form body
|
||||
func (u *User) RealName(ctx fiber.Ctx, form *dto.RealNameForm) error {
|
||||
return services.User.RealName(ctx.Context(), form)
|
||||
return services.User.RealName(ctx, form)
|
||||
}
|
||||
|
||||
// Get wallet balance and transactions
|
||||
@@ -65,7 +65,7 @@ func (u *User) RealName(ctx fiber.Ctx, form *dto.RealNameForm) error {
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.WalletResponse
|
||||
func (u *User) Wallet(ctx fiber.Ctx) (*dto.WalletResponse, error) {
|
||||
return services.Wallet.GetWallet(ctx.Context())
|
||||
return services.Wallet.GetWallet(ctx)
|
||||
}
|
||||
|
||||
// Recharge wallet
|
||||
@@ -80,7 +80,7 @@ func (u *User) Wallet(ctx fiber.Ctx) (*dto.WalletResponse, error) {
|
||||
// @Success 200 {object} dto.RechargeResponse
|
||||
// @Bind form body
|
||||
func (u *User) Recharge(ctx fiber.Ctx, form *dto.RechargeForm) (*dto.RechargeResponse, error) {
|
||||
return services.Wallet.Recharge(ctx.Context(), form)
|
||||
return services.Wallet.Recharge(ctx, form)
|
||||
}
|
||||
|
||||
// List user orders
|
||||
@@ -95,7 +95,7 @@ func (u *User) Recharge(ctx fiber.Ctx, form *dto.RechargeForm) (*dto.RechargeRes
|
||||
// @Success 200 {array} dto.Order
|
||||
// @Bind status query
|
||||
func (u *User) ListOrders(ctx fiber.Ctx, status string) ([]dto.Order, error) {
|
||||
return services.Order.ListUserOrders(ctx.Context(), status)
|
||||
return services.Order.ListUserOrders(ctx, status)
|
||||
}
|
||||
|
||||
// Get user order detail
|
||||
@@ -110,7 +110,7 @@ func (u *User) ListOrders(ctx fiber.Ctx, status string) ([]dto.Order, error) {
|
||||
// @Success 200 {object} dto.Order
|
||||
// @Bind id path
|
||||
func (u *User) GetOrder(ctx fiber.Ctx, id string) (*dto.Order, error) {
|
||||
return services.Order.GetUserOrder(ctx.Context(), id)
|
||||
return services.Order.GetUserOrder(ctx, id)
|
||||
}
|
||||
|
||||
// Get purchased content
|
||||
@@ -123,7 +123,7 @@ func (u *User) GetOrder(ctx fiber.Ctx, id string) (*dto.Order, error) {
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
func (u *User) Library(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
return services.Content.GetLibrary(ctx.Context())
|
||||
return services.Content.GetLibrary(ctx)
|
||||
}
|
||||
|
||||
// Get favorites
|
||||
@@ -136,7 +136,7 @@ func (u *User) Library(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
func (u *User) Favorites(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
return services.Content.GetFavorites(ctx.Context())
|
||||
return services.Content.GetFavorites(ctx)
|
||||
}
|
||||
|
||||
// Add to favorites
|
||||
@@ -151,7 +151,7 @@ func (u *User) Favorites(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
// @Success 200 {string} string "Added"
|
||||
// @Bind contentId query
|
||||
func (u *User) AddFavorite(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.AddFavorite(ctx.Context(), contentId)
|
||||
return services.Content.AddFavorite(ctx, contentId)
|
||||
}
|
||||
|
||||
// Remove from favorites
|
||||
@@ -166,7 +166,7 @@ func (u *User) AddFavorite(ctx fiber.Ctx, contentId string) error {
|
||||
// @Success 200 {string} string "Removed"
|
||||
// @Bind contentId path
|
||||
func (u *User) RemoveFavorite(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.RemoveFavorite(ctx.Context(), contentId)
|
||||
return services.Content.RemoveFavorite(ctx, contentId)
|
||||
}
|
||||
|
||||
// Get liked contents
|
||||
@@ -179,7 +179,7 @@ func (u *User) RemoveFavorite(ctx fiber.Ctx, contentId string) error {
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
func (u *User) Likes(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
return services.Content.GetLikes(ctx.Context())
|
||||
return services.Content.GetLikes(ctx)
|
||||
}
|
||||
|
||||
// Like content
|
||||
@@ -194,7 +194,7 @@ func (u *User) Likes(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
// @Success 200 {string} string "Liked"
|
||||
// @Bind contentId query
|
||||
func (u *User) AddLike(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.AddLike(ctx.Context(), contentId)
|
||||
return services.Content.AddLike(ctx, contentId)
|
||||
}
|
||||
|
||||
// Unlike content
|
||||
@@ -209,7 +209,7 @@ func (u *User) AddLike(ctx fiber.Ctx, contentId string) error {
|
||||
// @Success 200 {string} string "Unliked"
|
||||
// @Bind contentId path
|
||||
func (u *User) RemoveLike(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.RemoveLike(ctx.Context(), contentId)
|
||||
return services.Content.RemoveLike(ctx, contentId)
|
||||
}
|
||||
|
||||
// Get following tenants
|
||||
@@ -222,7 +222,7 @@ func (u *User) RemoveLike(ctx fiber.Ctx, contentId string) error {
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.TenantProfile
|
||||
func (u *User) Following(ctx fiber.Ctx) ([]dto.TenantProfile, error) {
|
||||
return services.Tenant.ListFollowed(ctx.Context())
|
||||
return services.Tenant.ListFollowed(ctx)
|
||||
}
|
||||
|
||||
// Get notifications
|
||||
@@ -239,7 +239,7 @@ func (u *User) Following(ctx fiber.Ctx) ([]dto.TenantProfile, error) {
|
||||
// @Bind typeArg query key(type)
|
||||
// @Bind page query
|
||||
func (u *User) Notifications(ctx fiber.Ctx, typeArg string, page int) (*requests.Pager, error) {
|
||||
return services.Notification.List(ctx.Context(), page, typeArg)
|
||||
return services.Notification.List(ctx, page, typeArg)
|
||||
}
|
||||
|
||||
// List my coupons
|
||||
@@ -254,5 +254,5 @@ func (u *User) Notifications(ctx fiber.Ctx, typeArg string, page int) (*requests
|
||||
// @Success 200 {array} dto.UserCouponItem
|
||||
// @Bind status query
|
||||
func (u *User) MyCoupons(ctx fiber.Ctx, status string) ([]dto.UserCouponItem, error) {
|
||||
return services.Coupon.ListUserCoupons(ctx.Context(), status)
|
||||
return services.Coupon.ListUserCoupons(ctx, status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user