feat: 更新上传接口,使用新的上传表单结构并添加价格字段

This commit is contained in:
2025-12-31 16:41:19 +08:00
parent b82a69689d
commit 5a364a995a
5 changed files with 33 additions and 16 deletions

View File

@@ -13,8 +13,6 @@ import (
// @provider
type Common struct{}
// Upload file
//
// @Router /v1/upload [post]
// @Summary Upload file
// @Description Upload file
@@ -22,22 +20,22 @@ type Common struct{}
// @Accept multipart/form-data
// @Produce json
// @Param file formData file true "File"
// @Param type formData string false "Type enum(image, video, audio)"
// @Param form formData dto.UploadForm true "Upload form"
// @Success 200 {object} dto.UploadResult
// @Bind user local key(__ctx_user)
// @Bind file file
// @Bind typeArg body key(type)
// @Bind form body
func (c *Common) Upload(
ctx fiber.Ctx,
user *models.User,
file *multipart.FileHeader,
typeArg *string,
form *dto.UploadForm,
) (*dto.UploadResult, error) {
val := ""
if typeArg != nil {
val = *typeArg
if form != nil {
val = form.Type
}
return services.Common.Upload(ctx, user.ID, file, val)
return services.Common.Upload(ctx.Context(), user.ID, file, val)
}
// Get options (enums)

View File

@@ -14,3 +14,7 @@ type OptionsResponse struct {
ContentStatus []requests.KV `json:"content_status"`
ContentGenre []requests.KV `json:"content_genre"`
}
type UploadForm struct {
Type string `form:"type" json:"type"`
}

View File

@@ -55,13 +55,14 @@ type ContentEditDTO struct {
}
type CreatorContentItem struct {
ID string `json:"id"`
Title string `json:"title"`
Genre string `json:"genre"`
Key string `json:"key"`
Views int `json:"views"`
Likes int `json:"likes"`
IsPurchased bool `json:"is_purchased"`
ID string `json:"id"`
Title string `json:"title"`
Genre string `json:"genre"`
Key string `json:"key"`
Price float64 `json:"price"`
Views int `json:"views"`
Likes int `json:"likes"`
IsPurchased bool `json:"is_purchased"`
}
type AssetDTO struct {

View File

@@ -59,7 +59,7 @@ func (r *Routes) Register(router fiber.Router) {
r.common.Upload,
Local[*models.User]("__ctx_user"),
File[multipart.FileHeader]("file"),
Body[string]("type"),
Body[dto.UploadForm]("form"),
))
// Register routes for controller: Content
r.log.Debugf("Registering route: Get /v1/contents -> content.List")