From 9fd0caa93a9237dff5df7f6d5abc0c3e4152e671 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Sun, 31 Mar 2024 22:19:45 +0700 Subject: [PATCH] feat: update articles and swagger --- app/database/entity/articles.entity.go | 42 ++--- .../controller/articles.controller.go | 30 ++-- .../repository/articles.repository.go | 38 ++++- .../articles/request/articles.request.go | 144 +++++++++-------- .../articles/response/articles.response.go | 42 ++--- .../articles/service/articles.service.go | 9 +- .../controller/user_levels.controller.go | 1 + .../response/user_levels.response.go | 20 +-- .../users/controller/users.controller.go | 1 + docs/swagger/docs.go | 151 +++++++++++++++++- docs/swagger/swagger.json | 151 +++++++++++++++++- docs/swagger/swagger.yaml | 104 +++++++++++- 12 files changed, 578 insertions(+), 155 deletions(-) diff --git a/app/database/entity/articles.entity.go b/app/database/entity/articles.entity.go index a48222b..6a7cbac 100644 --- a/app/database/entity/articles.entity.go +++ b/app/database/entity/articles.entity.go @@ -3,24 +3,24 @@ package entity import "time" type Articles struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Slug string `json:"slug" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - HtmlDescription string `json:"html_description" gorm:"type:varchar"` - TypeId int `json:"type_id" gorm:"type:int4"` - Tags string `json:"tags" gorm:"type:varchar"` - ThumbnailPath string `json:"thumbnail_path" gorm:"type:varchar"` - ThumbnailUrl string `json:"thumbnail_url" gorm:"type:varchar"` - PageUrl string `json:"page_url" gorm:"type:varchar"` - CreatedById int `json:"created_by_id" gorm:"type:int4"` - ShareCount int `json:"share_count" gorm:"type:int4"` - ViewCount int `json:"view_count" gorm:"type:int4"` - DownloadCount int `json:"download_count" 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"` + Title string `json:"title" gorm:"type:varchar"` + Slug string `json:"slug" gorm:"type:varchar"` + Description string `json:"description" gorm:"type:varchar"` + HtmlDescription string `json:"html_description" gorm:"type:varchar"` + TypeId int `json:"type_id" gorm:"type:int4"` + Tags string `json:"tags" gorm:"type:varchar"` + ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"` + ThumbnailUrl *string `json:"thumbnail_url" gorm:"type:varchar"` + PageUrl *string `json:"page_url" gorm:"type:varchar"` + CreatedById *int `json:"created_by_id" gorm:"type:int4"` + ShareCount *int `json:"share_count" gorm:"type:int4"` + ViewCount *int `json:"view_count" gorm:"type:int4"` + DownloadCount *int `json:"download_count" 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/articles/controller/articles.controller.go b/app/module/articles/controller/articles.controller.go index ea0d36c..8e2a8f6 100644 --- a/app/module/articles/controller/articles.controller.go +++ b/app/module/articles/controller/articles.controller.go @@ -29,11 +29,12 @@ func NewArticlesController(articlesService service.ArticlesService) ArticlesCont } } -// All get all Articles +// All Articles // @Summary Get all Articles // @Description API for getting all Articles -// @Tags Task +// @Tags Articles // @Security Bearer +// @Param req query request.ArticlesQueryRequest false "query parameters" // @Success 200 {object} response.Response // @Failure 401 {object} response.Response // @Failure 404 {object} response.Response @@ -55,16 +56,17 @@ func (_i *articlesController) All(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"Articles list successfully retrieved"}, Data: articlesData, Meta: paging, }) } -// Show get one Articles +// Show Articles // @Summary Get one Articles // @Description API for getting one Articles -// @Tags Task +// @Tags Articles // @Security Bearer // @Param id path int true "Articles ID" // @Success 200 {object} response.Response @@ -85,17 +87,18 @@ func (_i *articlesController) Show(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"Articles successfully retrieved"}, Data: articlesData, }) } -// Save create Articles +// Save Articles // @Summary Create Articles // @Description API for create Articles -// @Tags Task +// @Tags Articles // @Security Bearer -// @Body request.ArticlesCreateRequest +// @Param payload body request.ArticlesCreateRequest true "Required payload" // @Success 200 {object} response.Response // @Failure 401 {object} response.Response // @Failure 404 {object} response.Response @@ -114,16 +117,17 @@ func (_i *articlesController) Save(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"Articles successfully created"}, }) } -// Update update Articles +// Update Articles // @Summary update Articles // @Description API for update Articles -// @Tags Task +// @Tags Articles // @Security Bearer -// @Body request.ArticlesUpdateRequest +// @Param payload body request.ArticlesUpdateRequest true "Required payload" // @Param id path int true "Articles ID" // @Success 200 {object} response.Response // @Failure 401 {object} response.Response @@ -148,14 +152,15 @@ func (_i *articlesController) Update(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"Articles successfully updated"}, }) } -// Delete delete Articles +// Delete Articles // @Summary delete Articles // @Description API for delete Articles -// @Tags Task +// @Tags Articles // @Security Bearer // @Param id path int true "Articles ID" // @Success 200 {object} response.Response @@ -176,6 +181,7 @@ func (_i *articlesController) Delete(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"Articles successfully deleted"}, }) } diff --git a/app/module/articles/repository/articles.repository.go b/app/module/articles/repository/articles.repository.go index c3ec31a..b30502a 100644 --- a/app/module/articles/repository/articles.repository.go +++ b/app/module/articles/repository/articles.repository.go @@ -1,14 +1,17 @@ package repository import ( + "github.com/rs/zerolog" "go-humas-be/app/database" "go-humas-be/app/database/entity" "go-humas-be/app/module/articles/request" "go-humas-be/utils/paginator" + "strings" ) type articlesRepository struct { - DB *database.Database + DB *database.Database + Log zerolog.Logger } // ArticlesRepository define interface of IArticlesRepository @@ -20,9 +23,10 @@ type ArticlesRepository interface { Delete(id uint) (err error) } -func NewArticlesRepository(db *database.Database) ArticlesRepository { +func NewArticlesRepository(db *database.Database, log zerolog.Logger) ArticlesRepository { return &articlesRepository{ - DB: db, + DB: db, + Log: log, } } @@ -31,6 +35,32 @@ func (_i *articlesRepository) GetAll(req request.ArticlesQueryRequest) (articles var count int64 query := _i.DB.DB.Model(&entity.Articles{}) + query = query.Where("is_active = ?", true) + + if req.Title != nil && *req.Title != "" { + title := strings.ToLower(*req.Title) + query = query.Where("LOWER(title) LIKE ?", "%"+strings.ToLower(title)+"%") + } + if req.Description != nil && *req.Description != "" { + description := strings.ToLower(*req.Description) + query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%") + } + if req.TypeId != nil { + query = query.Where("type_id = ?", req.TypeId) + } + if req.Tags != nil && *req.Tags != "" { + tags := strings.ToLower(*req.Tags) + query = query.Where("LOWER(tags) LIKE ?", "%"+strings.ToLower(tags)+"%") + } + if req.TypeId != nil { + query = query.Where("type_id = ?", req.TypeId) + } + if req.IsPublish != nil { + query = query.Where("is_publish = ?", req.IsPublish) + } + if req.StatusId != nil { + query = query.Where("status_id = ?", req.StatusId) + } query.Count(&count) req.Pagination.Count = count @@ -66,4 +96,4 @@ func (_i *articlesRepository) Update(id uint, articles *entity.Articles) (err er func (_i *articlesRepository) Delete(id uint) error { return _i.DB.DB.Delete(&entity.Articles{}, id).Error -} \ No newline at end of file +} diff --git a/app/module/articles/request/articles.request.go b/app/module/articles/request/articles.request.go index 50a671a..12a3220 100644 --- a/app/module/articles/request/articles.request.go +++ b/app/module/articles/request/articles.request.go @@ -3,6 +3,7 @@ package request import ( "go-humas-be/app/database/entity" "go-humas-be/utils/paginator" + "strconv" "time" ) @@ -11,44 +12,30 @@ type ArticlesGeneric interface { } type ArticlesQueryRequest struct { - Title string `json:"title" validate:"required"` - Slug string `json:"slug" validate:"required"` - Description string `json:"description" validate:"required"` - HtmlDescription string `json:"html_description" validate:"required"` - TypeId int `json:"type_id" validate:"required"` - Tags string `json:"tags" validate:"required"` - ThumbnailPath string `json:"thumbnail_path" validate:"required"` - ThumbnailUrl string `json:"thumbnail_url" validate:"required"` - PageUrl string `json:"page_url" validate:"required"` - CreatedById int `json:"created_by_id" validate:"required"` - ShareCount int `json:"share_count" validate:"required"` - ViewCount int `json:"view_count" validate:"required"` - DownloadCount int `json:"download_count" validate:"required"` - StatusId int `json:"status_id" validate:"required"` - IsPublish bool `json:"is_publish" validate:"required"` - PublishedAt time.Time `json:"published_at" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` - Pagination *paginator.Pagination `json:"pagination"` + Title *string `json:"title"` + Description *string `json:"description"` + TypeId *int `json:"typeId"` + Tags *string `json:"tags"` + StatusId *int `json:"statusId"` + IsPublish *bool `json:"isPublish"` + Pagination *paginator.Pagination `json:"pagination"` } type ArticlesCreateRequest struct { - Title string `json:"title" validate:"required"` - Slug string `json:"slug" validate:"required"` - Description string `json:"description" validate:"required"` - HtmlDescription string `json:"html_description" validate:"required"` - TypeId int `json:"type_id" validate:"required"` - Tags string `json:"tags" validate:"required"` - ThumbnailPath string `json:"thumbnail_path" validate:"required"` - ThumbnailUrl string `json:"thumbnail_url" validate:"required"` - PageUrl string `json:"page_url" validate:"required"` - CreatedById int `json:"created_by_id" validate:"required"` - ShareCount int `json:"share_count" validate:"required"` - ViewCount int `json:"view_count" validate:"required"` - DownloadCount int `json:"download_count" validate:"required"` - StatusId int `json:"status_id" validate:"required"` - IsPublish bool `json:"is_publish" validate:"required"` - PublishedAt time.Time `json:"published_at" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` + Title string `json:"title" validate:"required"` + Slug string `json:"slug" validate:"required"` + Description string `json:"description" validate:"required"` + HtmlDescription string `json:"htmlDescription" validate:"required"` + TypeId int `json:"typeId" validate:"required"` + Tags string `json:"tags" validate:"required"` + ThumbnailPath *string `json:"thumbnailPath"` + ThumbnailUrl *string `json:"thumbnailUrl"` + PageUrl *string `json:"pageUrl"` + CreatedById *int `json:"createdById"` + StatusId *int `json:"status_id"` + IsPublish *bool `json:"is_publish"` + PublishedAt *time.Time `json:"published_at"` + IsActive *bool `json:"is_active"` } func (req ArticlesCreateRequest) ToEntity() *entity.Articles { @@ -63,9 +50,6 @@ func (req ArticlesCreateRequest) ToEntity() *entity.Articles { ThumbnailUrl: req.ThumbnailUrl, PageUrl: req.PageUrl, CreatedById: req.CreatedById, - ShareCount: req.ShareCount, - ViewCount: req.ViewCount, - DownloadCount: req.DownloadCount, StatusId: req.StatusId, IsPublish: req.IsPublish, PublishedAt: req.PublishedAt, @@ -74,49 +58,67 @@ func (req ArticlesCreateRequest) ToEntity() *entity.Articles { } type ArticlesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Title string `json:"title" validate:"required"` - Slug string `json:"slug" validate:"required"` - Description string `json:"description" validate:"required"` - HtmlDescription string `json:"html_description" validate:"required"` - TypeId int `json:"type_id" validate:"required"` - Tags string `json:"tags" validate:"required"` - ThumbnailPath string `json:"thumbnail_path" validate:"required"` - ThumbnailUrl string `json:"thumbnail_url" validate:"required"` - PageUrl string `json:"page_url" validate:"required"` - CreatedById int `json:"created_by_id" validate:"required"` - ShareCount int `json:"share_count" validate:"required"` - ViewCount int `json:"view_count" validate:"required"` - DownloadCount int `json:"download_count" validate:"required"` - StatusId int `json:"status_id" validate:"required"` - IsPublish bool `json:"is_publish" validate:"required"` - PublishedAt time.Time `json:"published_at" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + Title string `json:"title" validate:"required"` + Slug string `json:"slug" validate:"required"` + Description string `json:"description" validate:"required"` + HtmlDescription string `json:"htmlDescription" validate:"required"` + TypeId int `json:"typeId" validate:"required"` + Tags string `json:"tags" validate:"required"` + StatusId *int `json:"statusId"` } func (req ArticlesUpdateRequest) ToEntity() *entity.Articles { return &entity.Articles{ - ID: req.ID, Title: req.Title, Slug: req.Slug, Description: req.Description, HtmlDescription: req.HtmlDescription, TypeId: req.TypeId, Tags: req.Tags, - ThumbnailPath: req.ThumbnailPath, - ThumbnailUrl: req.ThumbnailUrl, - PageUrl: req.PageUrl, - CreatedById: req.CreatedById, - ShareCount: req.ShareCount, - ViewCount: req.ViewCount, - DownloadCount: req.DownloadCount, StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsActive: req.IsActive, - CreatedAt: req.CreatedAt, - UpdatedAt: req.UpdatedAt, + UpdatedAt: time.Now(), } } + +type ArticlesQueryRequestContext struct { + Title string `json:"title"` + Description string `json:"description"` + TypeId string `json:"typeId"` + Tags string `json:"tags"` + IsPublish string `json:"isPublish"` + StatusId string `json:"statusId"` +} + +func (req ArticlesQueryRequestContext) ToParamRequest() ArticlesQueryRequest { + var request ArticlesQueryRequest + + if title := req.Title; title != "" { + request.Title = &title + } + if description := req.Description; description != "" { + request.Description = &description + } + if typeIdStr := req.TypeId; typeIdStr != "" { + typeId, err := strconv.Atoi(typeIdStr) + if err == nil { + request.TypeId = &typeId + } + } + if tags := req.Tags; tags != "" { + request.Tags = &tags + } + if isPublishStr := req.IsPublish; isPublishStr != "" { + isPublish, err := strconv.ParseBool(isPublishStr) + if err == nil { + request.IsPublish = &isPublish + } + } + if statusIdStr := req.StatusId; statusIdStr != "" { + statusId, err := strconv.Atoi(statusIdStr) + if err == nil { + request.StatusId = &statusId + } + } + + return request +} diff --git a/app/module/articles/response/articles.response.go b/app/module/articles/response/articles.response.go index 1bf09bb..addcc4d 100644 --- a/app/module/articles/response/articles.response.go +++ b/app/module/articles/response/articles.response.go @@ -3,24 +3,24 @@ package response import "time" type ArticlesResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - Slug string `json:"slug"` - Description string `json:"description"` - HtmlDescription string `json:"html_description"` - TypeId int `json:"type_id"` - Tags string `json:"tags"` - ThumbnailPath string `json:"thumbnail_path"` - ThumbnailUrl string `json:"thumbnail_url"` - PageUrl string `json:"page_url"` - CreatedById int `json:"created_by_id"` - ShareCount int `json:"share_count"` - ViewCount int `json:"view_count"` - DownloadCount int `json:"download_count"` - 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"` + Title string `json:"title"` + Slug string `json:"slug"` + Description string `json:"description"` + HtmlDescription string `json:"html_description"` + TypeId int `json:"type_id"` + Tags string `json:"tags"` + ThumbnailPath *string `json:"thumbnail_path"` + ThumbnailUrl *string `json:"thumbnail_url"` + PageUrl *string `json:"page_url"` + CreatedById *int `json:"created_by_id"` + ShareCount *int `json:"share_count"` + ViewCount *int `json:"view_count"` + DownloadCount *int `json:"download_count"` + 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/articles/service/articles.service.go b/app/module/articles/service/articles.service.go index 5010fc7..0d683f2 100644 --- a/app/module/articles/service/articles.service.go +++ b/app/module/articles/service/articles.service.go @@ -68,5 +68,12 @@ func (_i *articlesService) Update(id uint, req request.ArticlesUpdateRequest) (e } func (_i *articlesService) Delete(id uint) error { - return _i.Repo.Delete(id) + result, err := _i.Repo.FindOne(id) + if err != nil { + return err + } + + isActive := false + result.IsActive = &isActive + return _i.Repo.Update(id, result) } diff --git a/app/module/user_levels/controller/user_levels.controller.go b/app/module/user_levels/controller/user_levels.controller.go index 5e5a733..b5e0e52 100644 --- a/app/module/user_levels/controller/user_levels.controller.go +++ b/app/module/user_levels/controller/user_levels.controller.go @@ -186,6 +186,7 @@ func (_i *userLevelsController) Delete(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"UserLevels successfully deleted"}, }) } diff --git a/app/module/user_levels/response/user_levels.response.go b/app/module/user_levels/response/user_levels.response.go index 62f1250..55d78d7 100644 --- a/app/module/user_levels/response/user_levels.response.go +++ b/app/module/user_levels/response/user_levels.response.go @@ -3,13 +3,13 @@ package response import "time" type UserLevelsResponse struct { - ID uint `json:"id"` - Name string `json:"name"` - AliasName string `json:"alias_name"` - LevelNumber int `json:"level_number"` - ParentLevelId int `json:"parent_level_id"` - ProvinceId int `json:"province_id"` - 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"` + Name string `json:"name"` + AliasName string `json:"alias_name"` + LevelNumber int `json:"level_number"` + ParentLevelId int `json:"parent_level_id"` + ProvinceId int `json:"province_id"` + IsActive *bool `json:"is_active"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} diff --git a/app/module/users/controller/users.controller.go b/app/module/users/controller/users.controller.go index ee58940..6d537ab 100644 --- a/app/module/users/controller/users.controller.go +++ b/app/module/users/controller/users.controller.go @@ -191,6 +191,7 @@ func (_i *usersController) Delete(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"Users successfully deleted"}, }) } diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index a77067e..8289c1c 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -910,9 +910,41 @@ const docTemplate = `{ ], "description": "API for getting all Articles", "tags": [ - "Task" + "Articles" ], "summary": "Get all Articles", + "parameters": [ + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "boolean", + "name": "isPublish", + "in": "query" + }, + { + "type": "integer", + "name": "statusId", + "in": "query" + }, + { + "type": "string", + "name": "tags", + "in": "query" + }, + { + "type": "string", + "name": "title", + "in": "query" + }, + { + "type": "integer", + "name": "typeId", + "in": "query" + } + ], "responses": { "200": { "description": "OK", @@ -954,9 +986,20 @@ const docTemplate = `{ ], "description": "API for create Articles", "tags": [ - "Task" + "Articles" ], "summary": "Create Articles", + "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ArticlesCreateRequest" + } + } + ], "responses": { "200": { "description": "OK", @@ -1000,7 +1043,7 @@ const docTemplate = `{ ], "description": "API for getting one Articles", "tags": [ - "Task" + "Articles" ], "summary": "Get one Articles", "parameters": [ @@ -1053,10 +1096,19 @@ const docTemplate = `{ ], "description": "API for update Articles", "tags": [ - "Task" + "Articles" ], "summary": "update Articles", "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ArticlesUpdateRequest" + } + }, { "type": "integer", "description": "Articles ID", @@ -1106,7 +1158,7 @@ const docTemplate = `{ ], "description": "API for delete Articles", "tags": [ - "Task" + "Articles" ], "summary": "delete Articles", "parameters": [ @@ -5165,6 +5217,95 @@ const docTemplate = `{ } } }, + "request.ArticlesCreateRequest": { + "type": "object", + "required": [ + "description", + "htmlDescription", + "slug", + "tags", + "title", + "typeId" + ], + "properties": { + "createdById": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "htmlDescription": { + "type": "string" + }, + "is_active": { + "type": "boolean" + }, + "is_publish": { + "type": "boolean" + }, + "pageUrl": { + "type": "string" + }, + "published_at": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "status_id": { + "type": "integer" + }, + "tags": { + "type": "string" + }, + "thumbnailPath": { + "type": "string" + }, + "thumbnailUrl": { + "type": "string" + }, + "title": { + "type": "string" + }, + "typeId": { + "type": "integer" + } + } + }, + "request.ArticlesUpdateRequest": { + "type": "object", + "required": [ + "description", + "htmlDescription", + "slug", + "tags", + "title", + "typeId" + ], + "properties": { + "description": { + "type": "string" + }, + "htmlDescription": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "statusId": { + "type": "integer" + }, + "tags": { + "type": "string" + }, + "title": { + "type": "string" + }, + "typeId": { + "type": "integer" + } + } + }, "request.CitiesCreateRequest": { "type": "object", "required": [ diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 1a759ee..9703312 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -899,9 +899,41 @@ ], "description": "API for getting all Articles", "tags": [ - "Task" + "Articles" ], "summary": "Get all Articles", + "parameters": [ + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "boolean", + "name": "isPublish", + "in": "query" + }, + { + "type": "integer", + "name": "statusId", + "in": "query" + }, + { + "type": "string", + "name": "tags", + "in": "query" + }, + { + "type": "string", + "name": "title", + "in": "query" + }, + { + "type": "integer", + "name": "typeId", + "in": "query" + } + ], "responses": { "200": { "description": "OK", @@ -943,9 +975,20 @@ ], "description": "API for create Articles", "tags": [ - "Task" + "Articles" ], "summary": "Create Articles", + "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ArticlesCreateRequest" + } + } + ], "responses": { "200": { "description": "OK", @@ -989,7 +1032,7 @@ ], "description": "API for getting one Articles", "tags": [ - "Task" + "Articles" ], "summary": "Get one Articles", "parameters": [ @@ -1042,10 +1085,19 @@ ], "description": "API for update Articles", "tags": [ - "Task" + "Articles" ], "summary": "update Articles", "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ArticlesUpdateRequest" + } + }, { "type": "integer", "description": "Articles ID", @@ -1095,7 +1147,7 @@ ], "description": "API for delete Articles", "tags": [ - "Task" + "Articles" ], "summary": "delete Articles", "parameters": [ @@ -5154,6 +5206,95 @@ } } }, + "request.ArticlesCreateRequest": { + "type": "object", + "required": [ + "description", + "htmlDescription", + "slug", + "tags", + "title", + "typeId" + ], + "properties": { + "createdById": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "htmlDescription": { + "type": "string" + }, + "is_active": { + "type": "boolean" + }, + "is_publish": { + "type": "boolean" + }, + "pageUrl": { + "type": "string" + }, + "published_at": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "status_id": { + "type": "integer" + }, + "tags": { + "type": "string" + }, + "thumbnailPath": { + "type": "string" + }, + "thumbnailUrl": { + "type": "string" + }, + "title": { + "type": "string" + }, + "typeId": { + "type": "integer" + } + } + }, + "request.ArticlesUpdateRequest": { + "type": "object", + "required": [ + "description", + "htmlDescription", + "slug", + "tags", + "title", + "typeId" + ], + "properties": { + "description": { + "type": "string" + }, + "htmlDescription": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "statusId": { + "type": "integer" + }, + "tags": { + "type": "string" + }, + "title": { + "type": "string" + }, + "typeId": { + "type": "integer" + } + } + }, "request.CitiesCreateRequest": { "type": "object", "required": [ diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index ba9af02..feca2c0 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -51,6 +51,68 @@ definitions: - thumbnail_url - title type: object + request.ArticlesCreateRequest: + properties: + createdById: + type: integer + description: + type: string + htmlDescription: + type: string + is_active: + type: boolean + is_publish: + type: boolean + pageUrl: + type: string + published_at: + type: string + slug: + type: string + status_id: + type: integer + tags: + type: string + thumbnailPath: + type: string + thumbnailUrl: + type: string + title: + type: string + typeId: + type: integer + required: + - description + - htmlDescription + - slug + - tags + - title + - typeId + type: object + request.ArticlesUpdateRequest: + properties: + description: + type: string + htmlDescription: + type: string + slug: + type: string + statusId: + type: integer + tags: + type: string + title: + type: string + typeId: + type: integer + required: + - description + - htmlDescription + - slug + - tags + - title + - typeId + type: object request.CitiesCreateRequest: properties: city_name: @@ -837,6 +899,25 @@ paths: /articles: get: description: API for getting all Articles + parameters: + - in: query + name: description + type: string + - in: query + name: isPublish + type: boolean + - in: query + name: statusId + type: integer + - in: query + name: tags + type: string + - in: query + name: title + type: string + - in: query + name: typeId + type: integer responses: "200": description: OK @@ -862,9 +943,16 @@ paths: - Bearer: [] summary: Get all Articles tags: - - Task + - Articles post: description: API for create Articles + parameters: + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.ArticlesCreateRequest' responses: "200": description: OK @@ -890,7 +978,7 @@ paths: - Bearer: [] summary: Create Articles tags: - - Task + - Articles /articles/{id}: delete: description: API for delete Articles @@ -925,7 +1013,7 @@ paths: - Bearer: [] summary: delete Articles tags: - - Task + - Articles get: description: API for getting one Articles parameters: @@ -959,10 +1047,16 @@ paths: - Bearer: [] summary: Get one Articles tags: - - Task + - Articles put: description: API for update Articles parameters: + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.ArticlesUpdateRequest' - description: Articles ID in: path name: id @@ -993,7 +1087,7 @@ paths: - Bearer: [] summary: update Articles tags: - - Task + - Articles /cities: get: description: API for getting all Cities