feat: update article categories
This commit is contained in:
parent
a458aad9d0
commit
d61198ef22
|
|
@ -47,6 +47,7 @@ func (_i *ArticleCategoriesRouter) RegisterArticleCategoriesRoutes() {
|
|||
router.Get("/", articleCategoriesController.All)
|
||||
router.Get("/:id", articleCategoriesController.Show)
|
||||
router.Get("/old/:id", articleCategoriesController.ShowByOldId)
|
||||
router.Get("/slug/:slug", articleCategoriesController.ShowBySlug)
|
||||
router.Post("/", articleCategoriesController.Save)
|
||||
router.Put("/:id", articleCategoriesController.Update)
|
||||
router.Post("/thumbnail/:id", articleCategoriesController.SaveThumbnail)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ type ArticleCategoriesController interface {
|
|||
All(c *fiber.Ctx) error
|
||||
Show(c *fiber.Ctx) error
|
||||
ShowByOldId(c *fiber.Ctx) error
|
||||
ShowBySlug(c *fiber.Ctx) error
|
||||
Save(c *fiber.Ctx) error
|
||||
SaveThumbnail(c *fiber.Ctx) error
|
||||
Update(c *fiber.Ctx) error
|
||||
|
|
@ -134,6 +135,32 @@ func (_i *articleCategoriesController) ShowByOldId(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
// ShowBySlug ArticleCategories
|
||||
// @Summary Get one ArticleCategories
|
||||
// @Description API for getting one ArticleCategories
|
||||
// @Tags Article Categories
|
||||
// @Security Bearer
|
||||
// @Param slug path string true "ArticleCategories Slug"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /article-categories/slug/{slug} [get]
|
||||
func (_i *articleCategoriesController) ShowBySlug(c *fiber.Ctx) error {
|
||||
slug := c.Params("slug")
|
||||
|
||||
articleCategoriesData, err := _i.articleCategoriesService.ShowBySlug(slug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"ArticleCategories successfully retrieved"},
|
||||
Data: articleCategoriesData,
|
||||
})
|
||||
}
|
||||
|
||||
// Save ArticleCategories
|
||||
// @Summary Create ArticleCategories
|
||||
// @Description API for create ArticleCategories
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ type ArticleCategoriesService interface {
|
|||
All(req request.ArticleCategoriesQueryRequest, authToken string) (articleCategories []*response.ArticleCategoriesResponse, paging paginator.Pagination, err error)
|
||||
Show(id uint) (articleCategories *response.ArticleCategoriesResponse, err error)
|
||||
ShowByOldId(id uint) (articleCategories *response.ArticleCategoriesResponse, err error)
|
||||
ShowBySlug(slug string) (articleCategories *response.ArticleCategoriesResponse, err error)
|
||||
Save(req request.ArticleCategoriesCreateRequest, authToken string) (articleCategories *entity.ArticleCategories, err error)
|
||||
SaveThumbnail(c *fiber.Ctx) (err error)
|
||||
Update(id uint, req request.ArticleCategoriesUpdateRequest) (err error)
|
||||
|
|
@ -98,6 +99,15 @@ func (_i *articleCategoriesService) ShowByOldId(id uint) (articleCategories *res
|
|||
return mapper.ArticleCategoriesResponseMapper(result, host), nil
|
||||
}
|
||||
|
||||
func (_i *articleCategoriesService) ShowBySlug(slug string) (articleCategories *response.ArticleCategoriesResponse, err error) {
|
||||
result, err := _i.Repo.FindOneBySlug(slug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
host := _i.Cfg.App.Domain
|
||||
return mapper.ArticleCategoriesResponseMapper(result, host), nil
|
||||
}
|
||||
|
||||
func (_i *articleCategoriesService) Save(req request.ArticleCategoriesCreateRequest, authToken string) (articleCategories *entity.ArticleCategories, err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
newReq := req.ToEntity()
|
||||
|
|
|
|||
|
|
@ -872,6 +872,55 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/article-categories/slug/{slug}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting one ArticleCategories",
|
||||
"tags": [
|
||||
"Article Categories"
|
||||
],
|
||||
"summary": "Get one ArticleCategories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "ArticleCategories Slug",
|
||||
"name": "slug",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/article-categories/thumbnail/viewer/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
|
|||
|
|
@ -861,6 +861,55 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/article-categories/slug/{slug}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting one ArticleCategories",
|
||||
"tags": [
|
||||
"Article Categories"
|
||||
],
|
||||
"summary": "Get one ArticleCategories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "ArticleCategories Slug",
|
||||
"name": "slug",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/article-categories/thumbnail/viewer/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
|
|||
|
|
@ -1463,6 +1463,37 @@ paths:
|
|||
summary: Get one ArticleCategories
|
||||
tags:
|
||||
- Article Categories
|
||||
/article-categories/slug/{slug}:
|
||||
get:
|
||||
description: API for getting one ArticleCategories
|
||||
parameters:
|
||||
- description: ArticleCategories Slug
|
||||
in: path
|
||||
name: slug
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.BadRequestError'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.UnauthorizedError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.InternalServerError'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get one ArticleCategories
|
||||
tags:
|
||||
- Article Categories
|
||||
/article-categories/thumbnail/{id}:
|
||||
post:
|
||||
description: API for Upload ArticleCategories Thumbnail
|
||||
|
|
|
|||
Loading…
Reference in New Issue