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)
|
||||
|
||||
@@ -3902,10 +3902,17 @@ const docTemplate = `{
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Filter by creator",
|
||||
"description": "Filter by tenant",
|
||||
"name": "tenant_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Filter by author",
|
||||
"name": "author_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"latest",
|
||||
@@ -5576,7 +5583,7 @@ const docTemplate = `{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Content ID",
|
||||
"name": "contentId",
|
||||
"name": "content_id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
@@ -5718,7 +5725,7 @@ const docTemplate = `{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Content ID",
|
||||
"name": "contentId",
|
||||
"name": "content_id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
|
||||
@@ -3896,10 +3896,17 @@
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Filter by creator",
|
||||
"description": "Filter by tenant",
|
||||
"name": "tenant_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Filter by author",
|
||||
"name": "author_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"latest",
|
||||
@@ -5570,7 +5577,7 @@
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Content ID",
|
||||
"name": "contentId",
|
||||
"name": "content_id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
@@ -5712,7 +5719,7 @@
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Content ID",
|
||||
"name": "contentId",
|
||||
"name": "content_id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
|
||||
@@ -6171,11 +6171,16 @@ paths:
|
||||
in: query
|
||||
name: genre
|
||||
type: string
|
||||
- description: Filter by creator
|
||||
- description: Filter by tenant
|
||||
format: int64
|
||||
in: query
|
||||
name: tenant_id
|
||||
type: integer
|
||||
- description: Filter by author
|
||||
format: int64
|
||||
in: query
|
||||
name: author_id
|
||||
type: integer
|
||||
- description: Sort order
|
||||
enum:
|
||||
- latest
|
||||
@@ -7273,7 +7278,7 @@ paths:
|
||||
- description: Content ID
|
||||
format: int64
|
||||
in: query
|
||||
name: contentId
|
||||
name: content_id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
@@ -7367,7 +7372,7 @@ paths:
|
||||
- description: Content ID
|
||||
format: int64
|
||||
in: query
|
||||
name: contentId
|
||||
name: content_id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
|
||||
Reference in New Issue
Block a user