From ab78f94e50d655c7a7fbbb335456f1edf120c6fd Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Mon, 1 Apr 2024 06:25:59 +0700 Subject: [PATCH] feat: update articles files and swagger --- app/database/entity/article_files.entity.go | 38 ++-- .../article_files/article_files.module.go | 3 +- .../controller/article_files.controller.go | 78 ++++---- .../request/article_files.request.go | 4 +- .../response/article_files.response.go | 38 ++-- .../service/article_files.service.go | 60 +++--- docs/swagger/docs.go | 171 +++++++++++------- docs/swagger/swagger.json | 171 +++++++++++------- docs/swagger/swagger.yaml | 117 ++++++++---- 9 files changed, 408 insertions(+), 272 deletions(-) diff --git a/app/database/entity/article_files.entity.go b/app/database/entity/article_files.entity.go index eaa85a8..81c72df 100644 --- a/app/database/entity/article_files.entity.go +++ b/app/database/entity/article_files.entity.go @@ -3,22 +3,22 @@ package entity import "time" type ArticleFiles struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - ArticleId int `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"` - FileThumbnail string `json:"file_thumbnail" gorm:"type:varchar"` - FileAlt string `json:"file_alt" gorm:"type:varchar"` - WidthPixel string `json:"width_pixel" gorm:"type:varchar"` - HeightPixel string `json:"height_pixel" gorm:"type:varchar"` - Size string `json:"size" gorm:"type:varchar"` - DownloadCount int `json:"download_count" gorm:"type:int4"` - CreatedById int `json:"created_by_id" gorm:"type:int4"` - StatusId int `json:"status_id" gorm:"type:int4"` - IsPublish bool `json:"is_publish" gorm:"type:bool"` - PublishedAt time.Time `json:"published_at" gorm:"type:timestamp"` - IsActive bool `json:"is_active" gorm:"type:bool"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} \ No newline at end of file + ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` + 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"` + FileThumbnail string `json:"file_thumbnail" gorm:"type:varchar"` + FileAlt string `json:"file_alt" gorm:"type:varchar"` + WidthPixel string `json:"width_pixel" gorm:"type:varchar"` + HeightPixel string `json:"height_pixel" gorm:"type:varchar"` + Size string `json:"size" gorm:"type:varchar"` + DownloadCount int `json:"download_count" gorm:"type:int4"` + CreatedById int `json:"created_by_id" gorm:"type:int4"` + StatusId int `json:"status_id" gorm:"type:int4"` + IsPublish bool `json:"is_publish" gorm:"type:bool"` + PublishedAt time.Time `json:"published_at" gorm:"type:timestamp"` + IsActive bool `json:"is_active" gorm:"type:bool"` + CreatedAt time.Time `json:"created_at" gorm:"default:now()"` + UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` +} diff --git a/app/module/article_files/article_files.module.go b/app/module/article_files/article_files.module.go index 0635994..10527ae 100644 --- a/app/module/article_files/article_files.module.go +++ b/app/module/article_files/article_files.module.go @@ -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) }) } diff --git a/app/module/article_files/controller/article_files.controller.go b/app/module/article_files/controller/article_files.controller.go index 2c54b2c..3b08978 100644 --- a/app/module/article_files/controller/article_files.controller.go +++ b/app/module/article_files/controller/article_files.controller.go @@ -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)) } diff --git a/app/module/article_files/request/article_files.request.go b/app/module/article_files/request/article_files.request.go index 17faef3..f247149 100644 --- a/app/module/article_files/request/article_files.request.go +++ b/app/module/article_files/request/article_files.request.go @@ -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"` diff --git a/app/module/article_files/response/article_files.response.go b/app/module/article_files/response/article_files.response.go index 986a2b8..9e67583 100644 --- a/app/module/article_files/response/article_files.response.go +++ b/app/module/article_files/response/article_files.response.go @@ -3,22 +3,22 @@ package response import "time" type ArticleFilesResponse struct { - ID uint `json:"id"` - ArticleId int `json:"article_id"` - FilePath string `json:"file_path"` - FileUrl string `json:"file_url"` - FileName string `json:"file_name"` - FileThumbnail string `json:"file_thumbnail"` - FileAlt string `json:"file_alt"` - WidthPixel string `json:"width_pixel"` - HeightPixel string `json:"height_pixel"` - Size string `json:"size"` - DownloadCount int `json:"download_count"` - CreatedById int `json:"created_by_id"` - StatusId int `json:"status_id"` - IsPublish bool `json:"is_publish"` - PublishedAt time.Time `json:"published_at"` - IsActive bool `json:"is_active"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` -} \ No newline at end of file + ID uint `json:"id"` + ArticleId uint `json:"article_id"` + FilePath string `json:"file_path"` + FileUrl string `json:"file_url"` + FileName string `json:"file_name"` + FileThumbnail string `json:"file_thumbnail"` + FileAlt string `json:"file_alt"` + WidthPixel string `json:"width_pixel"` + HeightPixel string `json:"height_pixel"` + Size string `json:"size"` + DownloadCount int `json:"download_count"` + CreatedById int `json:"created_by_id"` + StatusId int `json:"status_id"` + IsPublish bool `json:"is_publish"` + PublishedAt time.Time `json:"published_at"` + IsActive bool `json:"is_active"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} diff --git a/app/module/article_files/service/article_files.service.go b/app/module/article_files/service/article_files.service.go index 861ddd3..e8f28d6 100644 --- a/app/module/article_files/service/article_files.service.go +++ b/app/module/article_files/service/article_files.service.go @@ -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"). diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index 8289c1c..ab31342 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -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": [ diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 9703312..6799ab7 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -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": [ diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index feca2c0..4aa9270 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -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