pending
This commit is contained in:
157
backend/app/http/tenant/content.go
Normal file
157
backend/app/http/tenant/content.go
Normal file
@@ -0,0 +1,157 @@
|
||||
package tenant
|
||||
|
||||
import (
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// content provides tenant-side read-only content endpoints.
|
||||
//
|
||||
// @provider
|
||||
type content struct{}
|
||||
|
||||
// list
|
||||
//
|
||||
// @Summary 内容列表(已发布)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param filter query dto.ContentListFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.ContentItem}
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/contents [get]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind user local key(user)
|
||||
// @Bind filter query
|
||||
func (*content) list(ctx fiber.Ctx, tenant *models.Tenant, user *models.User, filter *dto.ContentListFilter) (*requests.Pager, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": user.ID,
|
||||
}).Info("tenant.contents.list")
|
||||
|
||||
filter.Pagination.Format()
|
||||
return services.Content.ListPublished(ctx, tenant.ID, user.ID, filter)
|
||||
}
|
||||
|
||||
// show
|
||||
//
|
||||
// @Summary 内容详情(可见性+权益校验)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Success 200 {object} dto.ContentDetail
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/contents/:contentID [get]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind user local key(user)
|
||||
// @Bind contentID path
|
||||
func (*content) show(ctx fiber.Ctx, tenant *models.Tenant, user *models.User, contentID int64) (*dto.ContentDetail, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": user.ID,
|
||||
"content_id": contentID,
|
||||
}).Info("tenant.contents.show")
|
||||
|
||||
item, err := services.Content.Detail(ctx, tenant.ID, user.ID, contentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dto.ContentDetail{
|
||||
Content: item.Content,
|
||||
Price: item.Price,
|
||||
HasAccess: item.HasAccess,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// previewAssets
|
||||
//
|
||||
// @Summary 获取试看资源(preview role)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Success 200 {object} dto.ContentAssetsResponse
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/contents/:contentID/preview [get]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind user local key(user)
|
||||
// @Bind contentID path
|
||||
func (*content) previewAssets(ctx fiber.Ctx, tenant *models.Tenant, user *models.User, contentID int64) (*dto.ContentAssetsResponse, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": user.ID,
|
||||
"content_id": contentID,
|
||||
}).Info("tenant.contents.preview_assets")
|
||||
|
||||
detail, err := services.Content.Detail(ctx, tenant.ID, user.ID, contentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
assets, err := services.Content.AssetsByRole(ctx, tenant.ID, contentID, consts.ContentAssetRolePreview)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
previewSeconds := int32(detail.Content.PreviewSeconds)
|
||||
if previewSeconds <= 0 {
|
||||
previewSeconds = 60
|
||||
}
|
||||
return &dto.ContentAssetsResponse{
|
||||
Content: detail.Content,
|
||||
Assets: assets,
|
||||
PreviewSeconds: previewSeconds,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// mainAssets
|
||||
//
|
||||
// @Summary 获取正片资源(main role,需要已购或免费)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Success 200 {object} dto.ContentAssetsResponse
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/contents/:contentID/assets [get]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind user local key(user)
|
||||
// @Bind contentID path
|
||||
func (*content) mainAssets(ctx fiber.Ctx, tenant *models.Tenant, user *models.User, contentID int64) (*dto.ContentAssetsResponse, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": user.ID,
|
||||
"content_id": contentID,
|
||||
}).Info("tenant.contents.main_assets")
|
||||
|
||||
detail, err := services.Content.Detail(ctx, tenant.ID, user.ID, contentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !detail.HasAccess {
|
||||
return nil, errorx.ErrPermissionDenied.WithMsg("未购买或无权限访问")
|
||||
}
|
||||
|
||||
assets, err := services.Content.AssetsByRole(ctx, tenant.ID, contentID, consts.ContentAssetRoleMain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dto.ContentAssetsResponse{
|
||||
Content: detail.Content,
|
||||
Assets: assets,
|
||||
}, nil
|
||||
}
|
||||
158
backend/app/http/tenant/content_admin.go
Normal file
158
backend/app/http/tenant/content_admin.go
Normal file
@@ -0,0 +1,158 @@
|
||||
package tenant
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// contentAdmin provides tenant-admin content management endpoints.
|
||||
//
|
||||
// @provider
|
||||
type contentAdmin struct{}
|
||||
|
||||
func requireTenantAdmin(tenantUser *models.TenantUser) error {
|
||||
if tenantUser == nil {
|
||||
return errorx.ErrPermissionDenied
|
||||
}
|
||||
if !tenantUser.Role.Contains(consts.TenantUserRoleTenantAdmin) {
|
||||
return errorx.ErrPermissionDenied
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// create
|
||||
//
|
||||
// @Summary 创建内容(草稿)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param form body dto.ContentCreateForm true "Form"
|
||||
// @Success 200 {object} models.Content
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/admin/contents [post]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind tenantUser local key(tenant_user)
|
||||
// @Bind form body
|
||||
func (*contentAdmin) create(ctx fiber.Ctx, tenant *models.Tenant, tenantUser *models.TenantUser, form *dto.ContentCreateForm) (*models.Content, error) {
|
||||
if err := requireTenantAdmin(tenantUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": tenantUser.UserID,
|
||||
}).Info("tenant.admin.contents.create")
|
||||
|
||||
return services.Content.Create(ctx, tenant.ID, tenantUser.UserID, form)
|
||||
}
|
||||
|
||||
// update
|
||||
//
|
||||
// @Summary 更新内容(标题/描述/状态等)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Param form body dto.ContentUpdateForm true "Form"
|
||||
// @Success 200 {object} models.Content
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/admin/contents/:contentID [patch]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind tenantUser local key(tenant_user)
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (*contentAdmin) update(ctx fiber.Ctx, tenant *models.Tenant, tenantUser *models.TenantUser, contentID int64, form *dto.ContentUpdateForm) (*models.Content, error) {
|
||||
if err := requireTenantAdmin(tenantUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": tenantUser.UserID,
|
||||
"content_id": contentID,
|
||||
}).Info("tenant.admin.contents.update")
|
||||
|
||||
return services.Content.Update(ctx, tenant.ID, tenantUser.UserID, contentID, form)
|
||||
}
|
||||
|
||||
// upsertPrice
|
||||
//
|
||||
// @Summary 设置内容价格与折扣
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Param form body dto.ContentPriceUpsertForm true "Form"
|
||||
// @Success 200 {object} models.ContentPrice
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/admin/contents/:contentID/price [put]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind tenantUser local key(tenant_user)
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (*contentAdmin) upsertPrice(ctx fiber.Ctx, tenant *models.Tenant, tenantUser *models.TenantUser, contentID int64, form *dto.ContentPriceUpsertForm) (*models.ContentPrice, error) {
|
||||
if err := requireTenantAdmin(tenantUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": tenantUser.UserID,
|
||||
"content_id": contentID,
|
||||
}).Info("tenant.admin.contents.upsert_price")
|
||||
|
||||
return services.Content.UpsertPrice(ctx, tenant.ID, tenantUser.UserID, contentID, form)
|
||||
}
|
||||
|
||||
// attachAsset
|
||||
//
|
||||
// @Summary 绑定媒体资源到内容(main/cover/preview)
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenant_code path string true "Tenant Code"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Param form body dto.ContentAssetAttachForm true "Form"
|
||||
// @Success 200 {object} models.ContentAsset
|
||||
//
|
||||
// @Router /t/:tenant_code/v1/admin/contents/:contentID/assets [post]
|
||||
// @Bind tenant local key(tenant)
|
||||
// @Bind tenantUser local key(tenant_user)
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (*contentAdmin) attachAsset(ctx fiber.Ctx, tenant *models.Tenant, tenantUser *models.TenantUser, contentID int64, form *dto.ContentAssetAttachForm) (*models.ContentAsset, error) {
|
||||
if err := requireTenantAdmin(tenantUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"tenant_id": tenant.ID,
|
||||
"user_id": tenantUser.UserID,
|
||||
"content_id": contentID,
|
||||
"asset_id": form.AssetID,
|
||||
"role": form.Role,
|
||||
}).Info("tenant.admin.contents.attach_asset")
|
||||
|
||||
role := form.Role
|
||||
if role == "" {
|
||||
role = consts.ContentAssetRoleMain
|
||||
}
|
||||
|
||||
sort := int32(0)
|
||||
if form.Sort > 0 {
|
||||
sort = form.Sort
|
||||
}
|
||||
|
||||
return services.Content.AttachAsset(ctx, tenant.ID, tenantUser.UserID, contentID, form.AssetID, role, sort, time.Now())
|
||||
}
|
||||
43
backend/app/http/tenant/dto/content.go
Normal file
43
backend/app/http/tenant/dto/content.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
)
|
||||
|
||||
type ContentListFilter struct {
|
||||
// Pagination controls paging parameters (page/limit).
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
// Keyword filters by title keyword (LIKE).
|
||||
Keyword *string `json:"keyword,omitempty" query:"keyword"`
|
||||
}
|
||||
|
||||
// ContentItem is a list item with price snapshot and access indicator for current user.
|
||||
type ContentItem struct {
|
||||
// Content is the content entity.
|
||||
Content *models.Content `json:"content,omitempty"`
|
||||
// Price is the current price settings for the content (may be nil if not set).
|
||||
Price *models.ContentPrice `json:"price,omitempty"`
|
||||
// HasAccess indicates whether current user can access main assets (free/owner/purchased).
|
||||
HasAccess bool `json:"has_access"`
|
||||
}
|
||||
|
||||
// ContentDetail is the detail payload with price snapshot and access indicator for current user.
|
||||
type ContentDetail struct {
|
||||
// Content is the content entity.
|
||||
Content *models.Content `json:"content,omitempty"`
|
||||
// Price is the current price settings for the content (may be nil if not set).
|
||||
Price *models.ContentPrice `json:"price,omitempty"`
|
||||
// HasAccess indicates whether current user can access main assets (free/owner/purchased).
|
||||
HasAccess bool `json:"has_access"`
|
||||
}
|
||||
|
||||
// ContentAssetsResponse returns assets for either preview or main role.
|
||||
type ContentAssetsResponse struct {
|
||||
// Content is the content entity.
|
||||
Content *models.Content `json:"content,omitempty"`
|
||||
// Assets is the list of media assets for the requested role (preview/main).
|
||||
Assets []*models.MediaAsset `json:"assets,omitempty"`
|
||||
// PreviewSeconds indicates the max preview duration (only meaningful for preview response).
|
||||
PreviewSeconds int32 `json:"preview_seconds,omitempty"`
|
||||
}
|
||||
58
backend/app/http/tenant/dto/content_admin.go
Normal file
58
backend/app/http/tenant/dto/content_admin.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
type ContentCreateForm struct {
|
||||
// Title is the content title.
|
||||
Title string `json:"title,omitempty"`
|
||||
// Description is the content description.
|
||||
Description string `json:"description,omitempty"`
|
||||
// Visibility controls who can view the content detail (main assets still require free/purchase).
|
||||
Visibility consts.ContentVisibility `json:"visibility,omitempty"`
|
||||
// PreviewSeconds controls preview duration (defaults to 60 when omitted).
|
||||
PreviewSeconds *int32 `json:"preview_seconds,omitempty"`
|
||||
}
|
||||
|
||||
// ContentUpdateForm updates mutable fields of a content.
|
||||
type ContentUpdateForm struct {
|
||||
// Title updates the title when provided.
|
||||
Title *string `json:"title,omitempty"`
|
||||
// Description updates the description when provided.
|
||||
Description *string `json:"description,omitempty"`
|
||||
// Visibility updates the visibility when provided.
|
||||
Visibility *consts.ContentVisibility `json:"visibility,omitempty"`
|
||||
// Status updates the content status when provided (e.g. publish/unpublish).
|
||||
Status *consts.ContentStatus `json:"status,omitempty"`
|
||||
// PreviewSeconds updates preview duration when provided (must be > 0).
|
||||
PreviewSeconds *int32 `json:"preview_seconds,omitempty"`
|
||||
}
|
||||
|
||||
// ContentPriceUpsertForm upserts pricing and discount settings for a content.
|
||||
type ContentPriceUpsertForm struct {
|
||||
// PriceAmount is the base price in cents (CNY 分).
|
||||
PriceAmount int64 `json:"price_amount,omitempty"`
|
||||
// Currency is fixed to CNY for now.
|
||||
Currency consts.Currency `json:"currency,omitempty"`
|
||||
// DiscountType defines the discount algorithm (none/percent/amount).
|
||||
DiscountType consts.DiscountType `json:"discount_type,omitempty"`
|
||||
// DiscountValue is interpreted based on DiscountType.
|
||||
DiscountValue int64 `json:"discount_value,omitempty"`
|
||||
// DiscountStartAt enables discount from this time (optional).
|
||||
DiscountStartAt *time.Time `json:"discount_start_at,omitempty"`
|
||||
// DiscountEndAt disables discount after this time (optional).
|
||||
DiscountEndAt *time.Time `json:"discount_end_at,omitempty"`
|
||||
}
|
||||
|
||||
// ContentAssetAttachForm attaches a media asset to a content with a role and sort order.
|
||||
type ContentAssetAttachForm struct {
|
||||
// AssetID is the media asset id to attach.
|
||||
AssetID int64 `json:"asset_id,omitempty"`
|
||||
// Role indicates how this asset is used (main/cover/preview).
|
||||
Role consts.ContentAssetRole `json:"role,omitempty"`
|
||||
// Sort controls ordering under the same role.
|
||||
Sort int32 `json:"sort,omitempty"`
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package dto
|
||||
|
||||
import "quyun/v2/database/models"
|
||||
|
||||
// MeResponse returns the resolved tenant context for the current request.
|
||||
type MeResponse struct {
|
||||
Tenant *models.Tenant `json:"tenant,omitempty"`
|
||||
User *models.User `json:"user,omitempty"`
|
||||
// Tenant is the resolved tenant by `tenant_code`.
|
||||
Tenant *models.Tenant `json:"tenant,omitempty"`
|
||||
// User is the authenticated user derived from JWT `user_id`.
|
||||
User *models.User `json:"user,omitempty"`
|
||||
// TenantUser is the membership record of the authenticated user within the tenant.
|
||||
TenantUser *models.TenantUser `json:"tenant_user,omitempty"`
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// me provides tenant context introspection endpoints (current tenant/user/tenant_user).
|
||||
//
|
||||
// @provider
|
||||
type me struct{}
|
||||
|
||||
|
||||
@@ -10,6 +10,20 @@ import (
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func() (*content, error) {
|
||||
obj := &content{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*contentAdmin, error) {
|
||||
obj := &contentAdmin{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*me, error) {
|
||||
obj := &me{}
|
||||
|
||||
@@ -18,12 +32,16 @@ func Provide(opts ...opt.Option) error {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
content *content,
|
||||
contentAdmin *contentAdmin,
|
||||
me *me,
|
||||
middlewares *middlewares.Middlewares,
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
me: me,
|
||||
middlewares: middlewares,
|
||||
content: content,
|
||||
contentAdmin: contentAdmin,
|
||||
me: me,
|
||||
middlewares: middlewares,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package tenant
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/middlewares"
|
||||
"quyun/v2/database/models"
|
||||
|
||||
@@ -23,7 +24,9 @@ type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
middlewares *middlewares.Middlewares
|
||||
// Controller instances
|
||||
me *me
|
||||
content *content
|
||||
contentAdmin *contentAdmin
|
||||
me *me
|
||||
}
|
||||
|
||||
// Prepare initializes the routes provider with logging configuration.
|
||||
@@ -41,6 +44,67 @@ func (r *Routes) Name() string {
|
||||
// Register registers all HTTP routes with the provided fiber router.
|
||||
// Each route is registered with its corresponding controller action and parameter bindings.
|
||||
func (r *Routes) Register(router fiber.Router) {
|
||||
// Register routes for controller: content
|
||||
r.log.Debugf("Registering route: Get /t/:tenant_code/v1/contents -> content.list")
|
||||
router.Get("/t/:tenant_code/v1/contents"[len(r.Path()):], DataFunc3(
|
||||
r.content.list,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.User]("user"),
|
||||
Query[dto.ContentListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /t/:tenant_code/v1/contents/:contentID -> content.show")
|
||||
router.Get("/t/:tenant_code/v1/contents/:contentID"[len(r.Path()):], DataFunc3(
|
||||
r.content.show,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.User]("user"),
|
||||
PathParam[int64]("contentID"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /t/:tenant_code/v1/contents/:contentID/assets -> content.mainAssets")
|
||||
router.Get("/t/:tenant_code/v1/contents/:contentID/assets"[len(r.Path()):], DataFunc3(
|
||||
r.content.mainAssets,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.User]("user"),
|
||||
PathParam[int64]("contentID"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /t/:tenant_code/v1/contents/:contentID/preview -> content.previewAssets")
|
||||
router.Get("/t/:tenant_code/v1/contents/:contentID/preview"[len(r.Path()):], DataFunc3(
|
||||
r.content.previewAssets,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.User]("user"),
|
||||
PathParam[int64]("contentID"),
|
||||
))
|
||||
// Register routes for controller: contentAdmin
|
||||
r.log.Debugf("Registering route: Patch /t/:tenant_code/v1/admin/contents/:contentID -> contentAdmin.update")
|
||||
router.Patch("/t/:tenant_code/v1/admin/contents/:contentID"[len(r.Path()):], DataFunc4(
|
||||
r.contentAdmin.update,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.TenantUser]("tenant_user"),
|
||||
PathParam[int64]("contentID"),
|
||||
Body[dto.ContentUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /t/:tenant_code/v1/admin/contents -> contentAdmin.create")
|
||||
router.Post("/t/:tenant_code/v1/admin/contents"[len(r.Path()):], DataFunc3(
|
||||
r.contentAdmin.create,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.TenantUser]("tenant_user"),
|
||||
Body[dto.ContentCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /t/:tenant_code/v1/admin/contents/:contentID/assets -> contentAdmin.attachAsset")
|
||||
router.Post("/t/:tenant_code/v1/admin/contents/:contentID/assets"[len(r.Path()):], DataFunc4(
|
||||
r.contentAdmin.attachAsset,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.TenantUser]("tenant_user"),
|
||||
PathParam[int64]("contentID"),
|
||||
Body[dto.ContentAssetAttachForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /t/:tenant_code/v1/admin/contents/:contentID/price -> contentAdmin.upsertPrice")
|
||||
router.Put("/t/:tenant_code/v1/admin/contents/:contentID/price"[len(r.Path()):], DataFunc4(
|
||||
r.contentAdmin.upsertPrice,
|
||||
Local[*models.Tenant]("tenant"),
|
||||
Local[*models.TenantUser]("tenant_user"),
|
||||
PathParam[int64]("contentID"),
|
||||
Body[dto.ContentPriceUpsertForm]("form"),
|
||||
))
|
||||
// Register routes for controller: me
|
||||
r.log.Debugf("Registering route: Get /t/:tenant_code/v1/me -> me.get")
|
||||
router.Get("/t/:tenant_code/v1/me"[len(r.Path()):], DataFunc3(
|
||||
|
||||
Reference in New Issue
Block a user