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