fix: align portal queries and super auth
This commit is contained in:
@@ -5,5 +5,7 @@ func (r *Routes) Path() string {
|
||||
}
|
||||
|
||||
func (r *Routes) Middlewares() []any {
|
||||
return []any{}
|
||||
return []any{
|
||||
r.middlewares.SuperAuth,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ type Content struct{}
|
||||
// @Produce json
|
||||
// @Param keyword query string false "Search keyword"
|
||||
// @Param genre query string false "Genre"
|
||||
// @Param tenant_id query int64 false "Filter by creator"
|
||||
// @Param tenant_id query int64 false "Filter by tenant"
|
||||
// @Param author_id query int64 false "Filter by author"
|
||||
// @Param sort query string false "Sort order" Enums(latest, hot, price_asc)
|
||||
// @Param page query int false "Page number"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.ContentItem}
|
||||
|
||||
@@ -496,13 +496,13 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
router.Post("/t/:tenantCode/v1/me/favorites"[len(r.Path()):], Func2(
|
||||
r.user.AddFavorite,
|
||||
Local[*models.User]("__ctx_user"),
|
||||
QueryParam[int64]("contentId"),
|
||||
QueryParam[int64]("content_id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /t/:tenantCode/v1/me/likes -> user.AddLike")
|
||||
router.Post("/t/:tenantCode/v1/me/likes"[len(r.Path()):], Func2(
|
||||
r.user.AddLike,
|
||||
Local[*models.User]("__ctx_user"),
|
||||
QueryParam[int64]("contentId"),
|
||||
QueryParam[int64]("content_id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /t/:tenantCode/v1/me/notifications/:id<int>/read -> user.MarkNotificationRead")
|
||||
router.Post("/t/:tenantCode/v1/me/notifications/:id<int>/read"[len(r.Path()):], Func2(
|
||||
|
||||
@@ -78,7 +78,7 @@ func (t *Tenant) Get(ctx fiber.Ctx, user *models.User, id int64) (*dto.TenantPro
|
||||
if tenantID > 0 && id != tenantID {
|
||||
return nil, errorx.ErrForbidden.WithMsg("租户不匹配")
|
||||
}
|
||||
return services.Tenant.GetPublicProfile(ctx, tenantID, uid)
|
||||
return services.Tenant.GetPublicProfile(ctx, id, uid)
|
||||
}
|
||||
|
||||
// Follow a tenant
|
||||
|
||||
@@ -165,10 +165,10 @@ func (u *User) Favorites(ctx fiber.Ctx, user *models.User) ([]dto.ContentItem, e
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param contentId query int64 true "Content ID"
|
||||
// @Param content_id query int64 true "Content ID"
|
||||
// @Success 200 {string} string "Added"
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind contentId query
|
||||
// @Bind contentId query key(content_id)
|
||||
func (u *User) AddFavorite(ctx fiber.Ctx, user *models.User, contentId int64) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Content.AddFavorite(ctx, tenantID, user.ID, contentId)
|
||||
@@ -214,10 +214,10 @@ func (u *User) Likes(ctx fiber.Ctx, user *models.User) ([]dto.ContentItem, error
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param contentId query int64 true "Content ID"
|
||||
// @Param content_id query int64 true "Content ID"
|
||||
// @Success 200 {string} string "Liked"
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind contentId query
|
||||
// @Bind contentId query key(content_id)
|
||||
func (u *User) AddLike(ctx fiber.Ctx, user *models.User, contentId int64) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Content.AddLike(ctx, tenantID, user.ID, contentId)
|
||||
|
||||
Reference in New Issue
Block a user