feat: update articles files and swagger
This commit is contained in:
parent
1776016b1a
commit
9240f25391
|
|
@ -4,7 +4,7 @@ import "time"
|
|||
|
||||
type ArticleFiles struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
||||
ArticleId int `json:"article_id" gorm:"type:int4"`
|
||||
ArticleId uint `json:"article_id" gorm:"type:int4"`
|
||||
FilePath string `json:"file_path" gorm:"type:varchar"`
|
||||
FileUrl string `json:"file_url" gorm:"type:varchar"`
|
||||
FileName string `json:"file_name" gorm:"type:varchar"`
|
||||
|
|
|
|||
|
|
@ -46,10 +46,9 @@ func (_i *ArticleFilesRouter) RegisterArticleFilesRoutes() {
|
|||
_i.App.Route("/article-files", func(router fiber.Router) {
|
||||
router.Get("/", articleFilesController.All)
|
||||
router.Get("/:id", articleFilesController.Show)
|
||||
router.Post("/", articleFilesController.Save)
|
||||
router.Post("/:articleId", articleFilesController.Save)
|
||||
router.Put("/:id", articleFilesController.Update)
|
||||
router.Delete("/:id", articleFilesController.Delete)
|
||||
router.Post("/uploader", articleFilesController.Uploader)
|
||||
router.Get("/viewer/:id", articleFilesController.Viewer)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ type ArticleFilesController interface {
|
|||
Save(c *fiber.Ctx) error
|
||||
Update(c *fiber.Ctx) error
|
||||
Delete(c *fiber.Ctx) error
|
||||
Uploader(c *fiber.Ctx) error
|
||||
Viewer(c *fiber.Ctx) error
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +32,7 @@ func NewArticleFilesController(articleFilesService service.ArticleFilesService)
|
|||
// All get all ArticleFiles
|
||||
// @Summary Get all ArticleFiles
|
||||
// @Description API for getting all ArticleFiles
|
||||
// @Tags Task
|
||||
// @Tags ArticleFiles
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
|
|
@ -56,6 +55,7 @@ func (_i *articleFilesController) All(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"ArticleFiles list successfully retrieved"},
|
||||
Data: articleFilesData,
|
||||
Meta: paging,
|
||||
|
|
@ -65,7 +65,7 @@ func (_i *articleFilesController) All(c *fiber.Ctx) error {
|
|||
// Show get one ArticleFiles
|
||||
// @Summary Get one ArticleFiles
|
||||
// @Description API for getting one ArticleFiles
|
||||
// @Tags Task
|
||||
// @Tags ArticleFiles
|
||||
// @Security Bearer
|
||||
// @Param id path int true "ArticleFiles ID"
|
||||
// @Success 200 {object} response.Response
|
||||
|
|
@ -86,45 +86,49 @@ func (_i *articleFilesController) Show(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"ArticleFiles successfully retrieved"},
|
||||
Data: articleFilesData,
|
||||
})
|
||||
}
|
||||
|
||||
// Save create ArticleFiles
|
||||
// @Summary Create ArticleFiles
|
||||
// Save ArticleFiles
|
||||
// @Summary Upload ArticleFiles
|
||||
// @Description API for create ArticleFiles
|
||||
// @Tags Task
|
||||
// @Tags ArticleFiles
|
||||
// @Security Bearer
|
||||
// @Body request.ArticleFilesCreateRequest
|
||||
// @Produce json
|
||||
// @Param files formData file true "Upload file"
|
||||
// @Param articleId path int true "Article ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
// @Failure 404 {object} response.Response
|
||||
// @Failure 422 {object} response.Response
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Router /article-files [post]
|
||||
// @Router /article-files/{articleId} [post]
|
||||
func (_i *articleFilesController) Save(c *fiber.Ctx) error {
|
||||
req := new(request.ArticleFilesCreateRequest)
|
||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||
id, err := strconv.ParseUint(c.Params("articleId"), 10, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := _i.articleFilesService.Save(*req)
|
||||
err = _i.articleFilesService.Save(c, uint(id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Messages: utilRes.Messages{"ArticleFiles successfully created"},
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"ArticleFiles successfully upload"},
|
||||
})
|
||||
}
|
||||
|
||||
// Update update ArticleFiles
|
||||
// Update ArticleFiles
|
||||
// @Summary update ArticleFiles
|
||||
// @Description API for update ArticleFiles
|
||||
// @Tags Task
|
||||
// @Tags ArticleFiles
|
||||
// @Security Bearer
|
||||
// @Body request.ArticleFilesUpdateRequest
|
||||
// @Param payload body request.ArticleFilesUpdateRequest true "Required payload"
|
||||
// @Param id path int true "ArticleFiles ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
|
|
@ -149,14 +153,15 @@ func (_i *articleFilesController) Update(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"ArticleFiles successfully updated"},
|
||||
})
|
||||
}
|
||||
|
||||
// Delete delete ArticleFiles
|
||||
// Delete ArticleFiles
|
||||
// @Summary delete ArticleFiles
|
||||
// @Description API for delete ArticleFiles
|
||||
// @Tags Task
|
||||
// @Tags ArticleFiles
|
||||
// @Security Bearer
|
||||
// @Param id path int true "ArticleFiles ID"
|
||||
// @Success 200 {object} response.Response
|
||||
|
|
@ -177,41 +182,17 @@ func (_i *articleFilesController) Delete(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"ArticleFiles successfully deleted"},
|
||||
})
|
||||
}
|
||||
|
||||
// Uploader upload ArticleFiles
|
||||
// @Summary Upload ArticleFiles
|
||||
// @Description API for create ArticleFiles
|
||||
// @Tags Task
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Param files formData file true "Upload file"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
// @Failure 404 {object} response.Response
|
||||
// @Failure 422 {object} response.Response
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Router /article-files/uploader [post]
|
||||
func (_i *articleFilesController) Uploader(c *fiber.Ctx) error {
|
||||
|
||||
err := _i.articleFilesService.Uploader(c, 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Messages: utilRes.Messages{"ArticleFiles successfully upload"},
|
||||
})
|
||||
}
|
||||
|
||||
// Viewer viewer ArticleFiles
|
||||
// Viewer ArticleFiles
|
||||
// @Summary Create ArticleFiles
|
||||
// @Description API for create ArticleFiles
|
||||
// @Tags Task
|
||||
// @Tags ArticleFiles
|
||||
// @Security Bearer
|
||||
// @Param id path string true "Filename"
|
||||
// @Param id path string true "Article File ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
// @Failure 404 {object} response.Response
|
||||
|
|
@ -219,6 +200,9 @@ func (_i *articleFilesController) Uploader(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} response.Response
|
||||
// @Router /article-files/viewer/{id} [get]
|
||||
func (_i *articleFilesController) Viewer(c *fiber.Ctx) error {
|
||||
|
||||
return _i.articleFilesService.Viewer(c, c.Params("id"))
|
||||
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return _i.articleFilesService.Viewer(c, uint(id))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ type ArticleFilesQueryRequest struct {
|
|||
}
|
||||
|
||||
type ArticleFilesCreateRequest struct {
|
||||
ArticleId int `json:"article_id" validate:"required"`
|
||||
ArticleId uint `json:"article_id" validate:"required"`
|
||||
FilePath string `json:"file_path" validate:"required"`
|
||||
FileUrl string `json:"file_url" validate:"required"`
|
||||
FileName string `json:"file_name" validate:"required"`
|
||||
|
|
@ -69,7 +69,7 @@ func (req ArticleFilesCreateRequest) ToEntity() *entity.ArticleFiles {
|
|||
|
||||
type ArticleFilesUpdateRequest struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
ArticleId int `json:"article_id" validate:"required"`
|
||||
ArticleId uint `json:"article_id" validate:"required"`
|
||||
FilePath string `json:"file_path" validate:"required"`
|
||||
FileUrl string `json:"file_url" validate:"required"`
|
||||
FileName string `json:"file_name" validate:"required"`
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import "time"
|
|||
|
||||
type ArticleFilesResponse struct {
|
||||
ID uint `json:"id"`
|
||||
ArticleId int `json:"article_id"`
|
||||
ArticleId uint `json:"article_id"`
|
||||
FilePath string `json:"file_path"`
|
||||
FileUrl string `json:"file_url"`
|
||||
FileName string `json:"file_name"`
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"mime"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -29,11 +31,10 @@ type articleFilesService struct {
|
|||
type ArticleFilesService interface {
|
||||
All(req request.ArticleFilesQueryRequest) (articleFiles []*response.ArticleFilesResponse, paging paginator.Pagination, err error)
|
||||
Show(id uint) (articleFiles *response.ArticleFilesResponse, err error)
|
||||
Save(req request.ArticleFilesCreateRequest) (err error)
|
||||
Save(c *fiber.Ctx, id uint) error
|
||||
Update(id uint, req request.ArticleFilesUpdateRequest) (err error)
|
||||
Delete(id uint) error
|
||||
Uploader(c *fiber.Ctx, id uint) error
|
||||
Viewer(c *fiber.Ctx, id string) error
|
||||
Viewer(c *fiber.Ctx, id uint) error
|
||||
}
|
||||
|
||||
// NewArticleFilesService init ArticleFilesService
|
||||
|
|
@ -69,22 +70,7 @@ func (_i *articleFilesService) Show(id uint) (articleFiles *response.ArticleFile
|
|||
return mapper.ArticleFilesResponseMapper(result), nil
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Save(req request.ArticleFilesCreateRequest) (err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
|
||||
return _i.Repo.Create(req.ToEntity())
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Update(id uint, req request.ArticleFilesUpdateRequest) (err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
return _i.Repo.Update(id, req.ToEntity())
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Delete(id uint) error {
|
||||
return _i.Repo.Delete(id)
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Uploader(c *fiber.Ctx, id uint) (err error) {
|
||||
func (_i *articleFilesService) Save(c *fiber.Ctx, id uint) (err error) {
|
||||
bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName
|
||||
|
||||
form, err := c.MultipartForm()
|
||||
|
|
@ -116,8 +102,24 @@ func (_i *articleFilesService) Uploader(c *fiber.Ctx, id uint) (err error) {
|
|||
}
|
||||
defer src.Close()
|
||||
|
||||
objectName := "articles/upload/" + file.Filename
|
||||
filenameOnly := file.Filename[:len(file.Filename)-len(filepath.Ext(file.Filename))]
|
||||
|
||||
req := request.ArticleFilesCreateRequest{
|
||||
ArticleId: id,
|
||||
FilePath: objectName,
|
||||
FileName: file.Filename,
|
||||
FileAlt: filenameOnly,
|
||||
Size: strconv.FormatInt(file.Size, 10),
|
||||
}
|
||||
|
||||
err = _i.Repo.Create(req.ToEntity())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Upload file ke MinIO
|
||||
_, err = minioClient.PutObject(context.Background(), bucketName, file.Filename, src, file.Size, minio.PutObjectOptions{})
|
||||
_, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, file.Size, minio.PutObjectOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -130,10 +132,24 @@ func (_i *articleFilesService) Uploader(c *fiber.Ctx, id uint) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Viewer(c *fiber.Ctx, id string) (err error) {
|
||||
func (_i *articleFilesService) Update(id uint, req request.ArticleFilesUpdateRequest) (err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
return _i.Repo.Update(id, req.ToEntity())
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Delete(id uint) error {
|
||||
return _i.Repo.Delete(id)
|
||||
}
|
||||
|
||||
func (_i *articleFilesService) Viewer(c *fiber.Ctx, id uint) (err error) {
|
||||
result, err := _i.Repo.FindOne(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName
|
||||
objectName := id
|
||||
objectName := result.FilePath
|
||||
|
||||
_i.Log.Info().Str("timestamp", time.Now().
|
||||
Format(time.RFC3339)).Str("Service:Resource", "Article:Uploads").
|
||||
|
|
|
|||
|
|
@ -581,8 +581,10 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"/article-files/viewer/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
|
|
@ -593,61 +595,12 @@ const docTemplate = `{
|
|||
"Task"
|
||||
],
|
||||
"summary": "Create ArticleFiles",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/article-files/uploader": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for create ArticleFiles",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Upload ArticleFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "file",
|
||||
"description": "Upload file",
|
||||
"name": "files",
|
||||
"in": "formData",
|
||||
"type": "string",
|
||||
"description": "Article File ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
|
|
@ -685,23 +638,33 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/article-files/viewer/{id}": {
|
||||
"get": {
|
||||
"/article-files/{articleId}": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for create ArticleFiles",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Create ArticleFiles",
|
||||
"summary": "Upload ArticleFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filename",
|
||||
"name": "id",
|
||||
"type": "file",
|
||||
"description": "Upload file",
|
||||
"name": "files",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Article ID",
|
||||
"name": "articleId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
|
|
@ -806,6 +769,15 @@ const docTemplate = `{
|
|||
],
|
||||
"summary": "update ArticleFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.ArticleFilesUpdateRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ArticleFiles ID",
|
||||
|
|
@ -5217,6 +5189,83 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.ArticleFilesUpdateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"article_id",
|
||||
"created_by_id",
|
||||
"download_count",
|
||||
"file_alt",
|
||||
"file_name",
|
||||
"file_path",
|
||||
"file_thumbnail",
|
||||
"file_url",
|
||||
"height_pixel",
|
||||
"id",
|
||||
"is_active",
|
||||
"is_publish",
|
||||
"published_at",
|
||||
"size",
|
||||
"status_id",
|
||||
"width_pixel"
|
||||
],
|
||||
"properties": {
|
||||
"article_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_by_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"download_count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"file_alt": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_path": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_thumbnail": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"height_pixel": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"is_active": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_publish": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"published_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"size": {
|
||||
"type": "string"
|
||||
},
|
||||
"status_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"width_pixel": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.ArticlesCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -570,8 +570,10 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"/article-files/viewer/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
|
|
@ -582,61 +584,12 @@
|
|||
"Task"
|
||||
],
|
||||
"summary": "Create ArticleFiles",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/article-files/uploader": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for create ArticleFiles",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Upload ArticleFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "file",
|
||||
"description": "Upload file",
|
||||
"name": "files",
|
||||
"in": "formData",
|
||||
"type": "string",
|
||||
"description": "Article File ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
|
|
@ -674,23 +627,33 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/article-files/viewer/{id}": {
|
||||
"get": {
|
||||
"/article-files/{articleId}": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for create ArticleFiles",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Create ArticleFiles",
|
||||
"summary": "Upload ArticleFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filename",
|
||||
"name": "id",
|
||||
"type": "file",
|
||||
"description": "Upload file",
|
||||
"name": "files",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Article ID",
|
||||
"name": "articleId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
|
|
@ -795,6 +758,15 @@
|
|||
],
|
||||
"summary": "update ArticleFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.ArticleFilesUpdateRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ArticleFiles ID",
|
||||
|
|
@ -5206,6 +5178,83 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.ArticleFilesUpdateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"article_id",
|
||||
"created_by_id",
|
||||
"download_count",
|
||||
"file_alt",
|
||||
"file_name",
|
||||
"file_path",
|
||||
"file_thumbnail",
|
||||
"file_url",
|
||||
"height_pixel",
|
||||
"id",
|
||||
"is_active",
|
||||
"is_publish",
|
||||
"published_at",
|
||||
"size",
|
||||
"status_id",
|
||||
"width_pixel"
|
||||
],
|
||||
"properties": {
|
||||
"article_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_by_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"download_count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"file_alt": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_path": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_thumbnail": {
|
||||
"type": "string"
|
||||
},
|
||||
"file_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"height_pixel": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"is_active": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_publish": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"published_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"size": {
|
||||
"type": "string"
|
||||
},
|
||||
"status_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"width_pixel": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.ArticlesCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -51,6 +51,62 @@ definitions:
|
|||
- thumbnail_url
|
||||
- title
|
||||
type: object
|
||||
request.ArticleFilesUpdateRequest:
|
||||
properties:
|
||||
article_id:
|
||||
type: integer
|
||||
created_at:
|
||||
type: string
|
||||
created_by_id:
|
||||
type: integer
|
||||
download_count:
|
||||
type: integer
|
||||
file_alt:
|
||||
type: string
|
||||
file_name:
|
||||
type: string
|
||||
file_path:
|
||||
type: string
|
||||
file_thumbnail:
|
||||
type: string
|
||||
file_url:
|
||||
type: string
|
||||
height_pixel:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
is_active:
|
||||
type: boolean
|
||||
is_publish:
|
||||
type: boolean
|
||||
published_at:
|
||||
type: string
|
||||
size:
|
||||
type: string
|
||||
status_id:
|
||||
type: integer
|
||||
updated_at:
|
||||
type: string
|
||||
width_pixel:
|
||||
type: string
|
||||
required:
|
||||
- article_id
|
||||
- created_by_id
|
||||
- download_count
|
||||
- file_alt
|
||||
- file_name
|
||||
- file_path
|
||||
- file_thumbnail
|
||||
- file_url
|
||||
- height_pixel
|
||||
- id
|
||||
- is_active
|
||||
- is_publish
|
||||
- published_at
|
||||
- size
|
||||
- status_id
|
||||
- width_pixel
|
||||
type: object
|
||||
request.ArticlesCreateRequest:
|
||||
properties:
|
||||
createdById:
|
||||
|
|
@ -693,8 +749,22 @@ paths:
|
|||
summary: Get all ArticleFiles
|
||||
tags:
|
||||
- Task
|
||||
/article-files/{articleId}:
|
||||
post:
|
||||
description: API for create ArticleFiles
|
||||
parameters:
|
||||
- description: Upload file
|
||||
in: formData
|
||||
name: files
|
||||
required: true
|
||||
type: file
|
||||
- description: Article ID
|
||||
in: path
|
||||
name: articleId
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
|
|
@ -718,7 +788,7 @@ paths:
|
|||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create ArticleFiles
|
||||
summary: Upload ArticleFiles
|
||||
tags:
|
||||
- Task
|
||||
/article-files/{id}:
|
||||
|
|
@ -793,6 +863,12 @@ paths:
|
|||
put:
|
||||
description: API for update ArticleFiles
|
||||
parameters:
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.ArticleFilesUpdateRequest'
|
||||
- description: ArticleFiles ID
|
||||
in: path
|
||||
name: id
|
||||
|
|
@ -824,48 +900,11 @@ paths:
|
|||
summary: update ArticleFiles
|
||||
tags:
|
||||
- Task
|
||||
/article-files/uploader:
|
||||
post:
|
||||
description: API for create ArticleFiles
|
||||
parameters:
|
||||
- description: Upload file
|
||||
in: formData
|
||||
name: files
|
||||
required: true
|
||||
type: file
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"422":
|
||||
description: Unprocessable Entity
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Upload ArticleFiles
|
||||
tags:
|
||||
- Task
|
||||
/article-files/viewer/{id}:
|
||||
get:
|
||||
description: API for create ArticleFiles
|
||||
parameters:
|
||||
- description: Filename
|
||||
- description: Article File ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
|
|
|
|||
Loading…
Reference in New Issue