89 lines
2.7 KiB
Go
89 lines
2.7 KiB
Go
package v1
|
|
|
|
import (
|
|
dto "quyun/v2/app/http/super/v1/dto"
|
|
"quyun/v2/app/requests"
|
|
"quyun/v2/app/services"
|
|
"quyun/v2/database/models"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
// @provider
|
|
type contents struct{}
|
|
|
|
// List contents
|
|
//
|
|
// @Router /super/v1/contents [get]
|
|
// @Summary List contents
|
|
// @Description List contents
|
|
// @Tags Content
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param page query int false "Page number"
|
|
// @Param limit query int false "Page size"
|
|
// @Success 200 {object} requests.Pager{items=[]dto.AdminContentItem}
|
|
// @Bind filter query
|
|
func (c *contents) List(ctx fiber.Ctx, filter *dto.SuperContentListFilter) (*requests.Pager, error) {
|
|
return services.Super.ListContents(ctx, filter)
|
|
}
|
|
|
|
// List tenant contents
|
|
//
|
|
// @Router /super/v1/tenants/:tenantID<int>/contents [get]
|
|
// @Summary List tenant contents
|
|
// @Description List contents by tenant
|
|
// @Tags Content
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param tenantID path int64 true "Tenant ID"
|
|
// @Param page query int false "Page number"
|
|
// @Param limit query int false "Page size"
|
|
// @Success 200 {object} requests.Pager{items=[]dto.AdminContentItem}
|
|
// @Bind tenantID path
|
|
// @Bind filter query
|
|
func (c *contents) ListTenantContents(ctx fiber.Ctx, tenantID int64, filter *dto.SuperContentListFilter) (*requests.Pager, error) {
|
|
if filter == nil {
|
|
filter = &dto.SuperContentListFilter{}
|
|
}
|
|
filter.TenantID = &tenantID
|
|
return services.Super.ListContents(ctx, filter)
|
|
}
|
|
|
|
// Update content status
|
|
//
|
|
// @Router /super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status [patch]
|
|
// @Summary Update content status
|
|
// @Description Update content status
|
|
// @Tags Content
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param tenantID path int64 true "Tenant ID"
|
|
// @Param contentID path int64 true "Content ID"
|
|
// @Param form body dto.SuperTenantContentStatusUpdateForm true "Update form"
|
|
// @Success 200 {string} string "Updated"
|
|
// @Bind tenantID path
|
|
// @Bind contentID path
|
|
// @Bind form body
|
|
func (c *contents) UpdateStatus(ctx fiber.Ctx, tenantID, contentID int64, form *dto.SuperTenantContentStatusUpdateForm) error {
|
|
return services.Super.UpdateContentStatus(ctx, tenantID, contentID, form)
|
|
}
|
|
|
|
// Review content
|
|
//
|
|
// @Router /super/v1/contents/:id<int>/review [post]
|
|
// @Summary Review content
|
|
// @Description Review content
|
|
// @Tags Content
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id path int64 true "Content ID"
|
|
// @Param form body dto.SuperContentReviewForm true "Review form"
|
|
// @Success 200 {string} string "Reviewed"
|
|
// @Bind user local key(__ctx_user)
|
|
// @Bind id path
|
|
// @Bind form body
|
|
func (c *contents) Review(ctx fiber.Ctx, user *models.User, id int64, form *dto.SuperContentReviewForm) error {
|
|
return services.Super.ReviewContent(ctx, user.ID, id, form)
|
|
}
|