diff --git a/app/database/entity/article_categories.entity.go b/app/database/entity/article_categories.entity.go index 49ab815..c8f7e12 100644 --- a/app/database/entity/article_categories.entity.go +++ b/app/database/entity/article_categories.entity.go @@ -3,18 +3,18 @@ package entity import "time" type ArticleCategories struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - ThumbnailPath string `json:"thumbnail_path" gorm:"type:varchar"` - ThumbnailUrl string `json:"thumbnail_url" gorm:"type:varchar"` - ParentId int `json:"parent_id" 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"` - IsEnabled bool `json:"is_enabled" gorm:"type:bool"` - 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()"` + ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` + Title string `json:"title" gorm:"type:varchar"` + Description string `json:"description" gorm:"type:varchar"` + ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"` + ThumbnailUrl *string `json:"thumbnail_url" gorm:"type:varchar"` + ParentId int `json:"parent_id" gorm:"type:int4"` + CreatedById *int `json:"created_by_id" gorm:"type:int4"` + StatusId *int `json:"status_id" gorm:"type:int4;default:1"` + IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"` + PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` + IsEnabled *bool `json:"is_enabled" gorm:"type:bool;default:false"` + IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` + CreatedAt time.Time `json:"created_at" gorm:"default:now()"` + UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/database/entity/article_files.entity.go b/app/database/entity/article_files.entity.go index 81c72df..45f110a 100644 --- a/app/database/entity/article_files.entity.go +++ b/app/database/entity/article_files.entity.go @@ -16,9 +16,9 @@ type ArticleFiles struct { 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"` + IsPublish bool `json:"is_publish" gorm:"type:bool;default:false"` PublishedAt time.Time `json:"published_at" gorm:"type:timestamp"` - IsActive bool `json:"is_active" gorm:"type:bool"` + IsActive bool `json:"is_active" gorm:"type:bool;default:true"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/database/entity/articles.entity.go b/app/database/entity/articles.entity.go index 6a7cbac..44b36da 100644 --- a/app/database/entity/articles.entity.go +++ b/app/database/entity/articles.entity.go @@ -18,9 +18,9 @@ type Articles struct { 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"` + IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"` PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` - IsActive *bool `json:"is_active" gorm:"type:bool"` + IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/database/entity/ppid_datas.entity.go b/app/database/entity/ppid_datas.entity.go index 8d7e228..2076dfd 100644 --- a/app/database/entity/ppid_datas.entity.go +++ b/app/database/entity/ppid_datas.entity.go @@ -3,15 +3,15 @@ package entity import "time" type PpidDatas struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - CategoryId int `json:"category_id" 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"` + Title string `json:"title" gorm:"type:varchar"` + Description string `json:"description" gorm:"type:varchar"` + CategoryId int `json:"category_id" 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;default:false"` + PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` + IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` + CreatedAt time.Time `json:"created_at" gorm:"default:now()"` + UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` +} diff --git a/app/database/entity/user_role_accesses.entity.go b/app/database/entity/user_role_accesses.entity.go index a0632ff..26bc357 100644 --- a/app/database/entity/user_role_accesses.entity.go +++ b/app/database/entity/user_role_accesses.entity.go @@ -12,7 +12,7 @@ type UserRoleAccesses struct { IsDeleteEnabled bool `json:"is_delete_enabled" gorm:"type:bool"` IsApprovalEnabled bool `json:"is_approval_enabled" gorm:"type:bool"` IsAdminEnabled bool `json:"is_admin_enabled" gorm:"type:bool"` - IsActive bool `json:"is_active" gorm:"type:bool"` + IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/database/entity/user_roles.entity.go b/app/database/entity/user_roles.entity.go index 0a2ebe5..4583f78 100644 --- a/app/database/entity/user_roles.entity.go +++ b/app/database/entity/user_roles.entity.go @@ -8,9 +8,9 @@ type UserRoles struct { Description string `json:"description" gorm:"type:varchar"` Code string `json:"code" gorm:"type:varchar"` LevelNumber int `json:"level_number" gorm:"type:int4"` - StatusId *int `json:"status_id" gorm:"type:int4"` + StatusId *int `json:"status_id" gorm:"type:int4;default:1"` CreatedById *int `json:"created_by_id" gorm:"type:int4"` - IsActive *bool `json:"is_active" gorm:"type:bool"` + IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/database/entity/users.entity.go b/app/database/entity/users.entity.go index 1a2c67c..3d7bb11 100644 --- a/app/database/entity/users.entity.go +++ b/app/database/entity/users.entity.go @@ -18,10 +18,10 @@ type Users struct { UserRoleId int `json:"user_role_id" gorm:"type:int4"` UserLevelsId int `json:"user_levels_id" gorm:"type:int4"` KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"` - StatusId *int `json:"status_id" gorm:"type:int4"` + StatusId *int `json:"status_id" gorm:"type:int4;default:1"` CreatedById *int `json:"created_by_id" gorm:"type:int4"` ProfilePicturePath *string `json:"profile_picture_path" gorm:"type:varchar"` - IsActive *bool `json:"is_active" gorm:"type:bool"` + IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/module/article_categories/controller/article_categories.controller.go b/app/module/article_categories/controller/article_categories.controller.go index cbca66f..fe7b9e9 100644 --- a/app/module/article_categories/controller/article_categories.controller.go +++ b/app/module/article_categories/controller/article_categories.controller.go @@ -29,16 +29,16 @@ func NewArticleCategoriesController(articleCategoriesService service.ArticleCate } } -// All get all ArticleCategories +// All ArticleCategories // @Summary Get all ArticleCategories // @Description API for getting all ArticleCategories -// @Tags Task +// @Tags ArticleCategories // @Security Bearer +// @Param req query request.ArticleCategoriesQueryRequest false "query parameters" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-categories [get] func (_i *articleCategoriesController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -46,7 +46,15 @@ func (_i *articleCategoriesController) All(c *fiber.Ctx) error { return err } - var req request.ArticleCategoriesQueryRequest + reqContext := request.ArticleCategoriesQueryRequestContext{ + Title: c.Query("title"), + Description: c.Query("description"), + ParentId: c.Query("parentId"), + IsEnabled: c.Query("isEnabled"), + IsPublish: c.Query("isPublish"), + StatusId: c.Query("statusId"), + } + req := reqContext.ToParamRequest() req.Pagination = paginate articleCategoriesData, paging, err := _i.articleCategoriesService.All(req) @@ -55,23 +63,23 @@ func (_i *articleCategoriesController) All(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"ArticleCategories list successfully retrieved"}, Data: articleCategoriesData, Meta: paging, }) } -// Show get one ArticleCategories +// Show ArticleCategories // @Summary Get one ArticleCategories // @Description API for getting one ArticleCategories -// @Tags Task +// @Tags ArticleCategories // @Security Bearer // @Param id path int true "ArticleCategories 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-categories/{id} [get] func (_i *articleCategoriesController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -85,22 +93,22 @@ func (_i *articleCategoriesController) Show(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"ArticleCategories successfully retrieved"}, Data: articleCategoriesData, }) } -// Save create ArticleCategories +// Save ArticleCategories // @Summary Create ArticleCategories // @Description API for create ArticleCategories -// @Tags Task +// @Tags ArticleCategories // @Security Bearer // @Param payload body request.ArticleCategoriesCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-categories [post] func (_i *articleCategoriesController) Save(c *fiber.Ctx) error { req := new(request.ArticleCategoriesCreateRequest) @@ -114,22 +122,22 @@ func (_i *articleCategoriesController) Save(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"ArticleCategories successfully created"}, }) } -// Update update ArticleCategories +// Update ArticleCategories // @Summary update ArticleCategories // @Description API for update ArticleCategories -// @Tags Task +// @Tags ArticleCategories // @Security Bearer -// @Param payload body request.ArticleCategoriesCreateRequest true "Required payload" +// @Param payload body request.ArticleCategoriesUpdateRequest true "Required payload" // @Param id path int true "ArticleCategories 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-categories/{id} [put] func (_i *articleCategoriesController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -148,21 +156,21 @@ func (_i *articleCategoriesController) Update(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"ArticleCategories successfully updated"}, }) } -// Delete delete ArticleCategories +// Delete ArticleCategories // @Summary delete ArticleCategories // @Description API for delete ArticleCategories -// @Tags Task +// @Tags ArticleCategories // @Security Bearer // @Param id path int true "ArticleCategories 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-categories/{id} [delete] func (_i *articleCategoriesController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -176,6 +184,7 @@ func (_i *articleCategoriesController) Delete(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"ArticleCategories successfully deleted"}, }) } diff --git a/app/module/article_categories/repository/article_categories.repository.go b/app/module/article_categories/repository/article_categories.repository.go index 5fe67f2..54fd0cb 100644 --- a/app/module/article_categories/repository/article_categories.repository.go +++ b/app/module/article_categories/repository/article_categories.repository.go @@ -5,6 +5,7 @@ import ( "go-humas-be/app/database/entity" "go-humas-be/app/module/article_categories/request" "go-humas-be/utils/paginator" + "strings" ) type articleCategoriesRepository struct { @@ -31,6 +32,31 @@ func (_i *articleCategoriesRepository) GetAll(req request.ArticleCategoriesQuery var count int64 query := _i.DB.DB.Model(&entity.ArticleCategories{}) + 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.ParentId != nil { + query = query.Where("parent_id = ?", req.ParentId) + } + if req.CreatedById != nil { + query = query.Where("created_by_id = ?", req.CreatedById) + } + if req.IsEnabled != nil { + query = query.Where("is_enabled = ?", req.IsEnabled) + } + 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 diff --git a/app/module/article_categories/request/article_categories.request.go b/app/module/article_categories/request/article_categories.request.go index 4bc0733..a0a8898 100644 --- a/app/module/article_categories/request/article_categories.request.go +++ b/app/module/article_categories/request/article_categories.request.go @@ -3,6 +3,7 @@ package request import ( "go-humas-be/app/database/entity" "go-humas-be/utils/paginator" + "strconv" "time" ) @@ -11,81 +12,108 @@ type ArticleCategoriesGeneric interface { } type ArticleCategoriesQueryRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - ThumbnailPath string `json:"thumbnail_path" validate:"required"` - ThumbnailUrl string `json:"thumbnail_url" validate:"required"` - ParentId int `json:"parent_id" validate:"required"` - StatusId int `json:"status_id" validate:"required"` - IsPublish bool `json:"is_publish" validate:"required"` - PublishedAt time.Time `json:"published_at" validate:"required"` - IsEnabled bool `json:"is_enabled" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` - Pagination *paginator.Pagination `json:"pagination"` + Title *string `json:"title"` + Description *string `json:"description"` + ParentId *int `json:"parentId"` + StatusId *int `json:"statusId"` + IsPublish *bool `json:"isPublish"` + CreatedById *int `json:"createdById"` + IsEnabled *bool `json:"isEnabled"` + Pagination *paginator.Pagination `json:"pagination"` } type ArticleCategoriesCreateRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - ThumbnailPath string `json:"thumbnail_path" validate:"required"` - ThumbnailUrl string `json:"thumbnail_url" validate:"required"` - ParentId int `json:"parent_id" validate:"required"` - CreatedById int `json:"created_by_id" validate:"required"` - StatusId int `json:"status_id" validate:"required"` - IsPublish bool `json:"is_publish" validate:"required"` - PublishedAt time.Time `json:"published_at" validate:"required"` - IsEnabled bool `json:"is_enabled" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` + Title string `json:"title" validate:"required"` + Description string `json:"description" validate:"required"` + ParentId int `json:"parentId" validate:"required"` + StatusId int `json:"statusId" validate:"required"` + IsEnabled bool `json:"isEnabled" validate:"required"` } func (req ArticleCategoriesCreateRequest) ToEntity() *entity.ArticleCategories { return &entity.ArticleCategories{ - Title: req.Title, - Description: req.Description, - ThumbnailPath: req.ThumbnailPath, - ThumbnailUrl: req.ThumbnailUrl, - ParentId: req.ParentId, - CreatedById: req.CreatedById, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsEnabled: req.IsEnabled, - IsActive: req.IsActive, + Title: req.Title, + Description: req.Description, + ParentId: req.ParentId, } } type ArticleCategoriesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - ThumbnailPath string `json:"thumbnail_path" validate:"required"` - ThumbnailUrl string `json:"thumbnail_url" validate:"required"` - ParentId int `json:"parent_id" validate:"required"` - CreatedById int `json:"created_by_id" validate:"required"` - StatusId int `json:"status_id" validate:"required"` - IsPublish bool `json:"is_publish" validate:"required"` - PublishedAt time.Time `json:"published_at" validate:"required"` - IsEnabled bool `json:"is_enabled" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uint `json:"id" validate:"required"` + Title string `json:"title" validate:"required"` + Description string `json:"description" validate:"required"` + ThumbnailPath string `json:"thumbnailPath" validate:"required"` + ThumbnailUrl string `json:"thumbnailUrl" validate:"required"` + ParentId int `json:"parentId" validate:"required"` + StatusId *int `json:"statusId"` + IsPublish *bool `json:"isPublish"` + PublishedAt *time.Time `json:"publishedAt"` + IsEnabled *bool `json:"isEnabled"` } func (req ArticleCategoriesUpdateRequest) ToEntity() *entity.ArticleCategories { return &entity.ArticleCategories{ - ID: req.ID, - Title: req.Title, - Description: req.Description, - ThumbnailPath: req.ThumbnailPath, - ThumbnailUrl: req.ThumbnailUrl, - ParentId: req.ParentId, - CreatedById: req.CreatedById, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsEnabled: req.IsEnabled, - IsActive: req.IsActive, - CreatedAt: req.CreatedAt, - UpdatedAt: req.UpdatedAt, + ID: req.ID, + Title: req.Title, + Description: req.Description, + ParentId: req.ParentId, + StatusId: req.StatusId, + IsPublish: req.IsPublish, + PublishedAt: req.PublishedAt, + IsEnabled: req.IsEnabled, + UpdatedAt: time.Now(), } } + +type ArticleCategoriesQueryRequestContext struct { + Title string `json:"title"` + Description string `json:"description"` + ParentId string `json:"parentId"` + StatusId string `json:"statusId"` + CreatedById string `json:"created_by_id"` + IsPublish string `json:"isPublish"` + IsEnabled string `json:"isEnabled"` +} + +func (req ArticleCategoriesQueryRequestContext) ToParamRequest() ArticleCategoriesQueryRequest { + var request ArticleCategoriesQueryRequest + + if title := req.Title; title != "" { + request.Title = &title + } + if description := req.Description; description != "" { + request.Description = &description + } + if parentIdStr := req.ParentId; parentIdStr != "" { + parentId, err := strconv.Atoi(parentIdStr) + if err == nil { + request.ParentId = &parentId + } + } + if isEnabledStr := req.IsEnabled; isEnabledStr != "" { + isEnabled, err := strconv.ParseBool(isEnabledStr) + if err == nil { + request.IsEnabled = &isEnabled + } + } + if isPublishStr := req.IsPublish; isPublishStr != "" { + isPublish, err := strconv.ParseBool(isPublishStr) + if err == nil { + request.IsPublish = &isPublish + } + } + if createdByIdStr := req.CreatedById; createdByIdStr != "" { + createdById, err := strconv.Atoi(createdByIdStr) + if err == nil { + request.CreatedById = &createdById + } + } + if statusIdStr := req.StatusId; statusIdStr != "" { + statusId, err := strconv.Atoi(statusIdStr) + if err == nil { + request.StatusId = &statusId + } + } + + return request +} diff --git a/app/module/article_categories/response/article_categories.response.go b/app/module/article_categories/response/article_categories.response.go index 90824ba..bedb138 100644 --- a/app/module/article_categories/response/article_categories.response.go +++ b/app/module/article_categories/response/article_categories.response.go @@ -3,18 +3,18 @@ package response import "time" type ArticleCategoriesResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - Description string `json:"description"` - ThumbnailPath string `json:"thumbnail_path"` - ThumbnailUrl string `json:"thumbnail_url"` - ParentId int `json:"parent_id"` - CreatedById int `json:"created_by_id"` - StatusId int `json:"status_id"` - IsPublish bool `json:"is_publish"` - PublishedAt time.Time `json:"published_at"` - IsEnabled bool `json:"is_enabled"` - 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"` + Description string `json:"description"` + ThumbnailPath *string `json:"thumbnail_path"` + ThumbnailUrl *string `json:"thumbnail_url"` + ParentId int `json:"parent_id"` + CreatedById *int `json:"created_by_id"` + StatusId *int `json:"status_id"` + IsPublish *bool `json:"is_publish"` + PublishedAt *time.Time `json:"published_at"` + IsEnabled *bool `json:"is_enabled"` + IsActive *bool `json:"is_active"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} diff --git a/app/module/article_categories/service/article_categories.service.go b/app/module/article_categories/service/article_categories.service.go index 640b711..0477463 100644 --- a/app/module/article_categories/service/article_categories.service.go +++ b/app/module/article_categories/service/article_categories.service.go @@ -68,5 +68,12 @@ func (_i *articleCategoriesService) Update(id uint, req request.ArticleCategorie } func (_i *articleCategoriesService) 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/article_files/controller/article_files.controller.go b/app/module/article_files/controller/article_files.controller.go index 3b08978..a9f02bd 100644 --- a/app/module/article_files/controller/article_files.controller.go +++ b/app/module/article_files/controller/article_files.controller.go @@ -29,16 +29,15 @@ func NewArticleFilesController(articleFilesService service.ArticleFilesService) } } -// All get all ArticleFiles +// All ArticleFiles // @Summary Get all ArticleFiles // @Description API for getting all ArticleFiles // @Tags ArticleFiles // @Security Bearer // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-files [get] func (_i *articleFilesController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -46,7 +45,13 @@ func (_i *articleFilesController) All(c *fiber.Ctx) error { return err } - var req request.ArticleFilesQueryRequest + reqContext := request.ArticleFilesQueryRequestContext{ + ArticleId: c.Query("articleId"), + FileName: c.Query("fileName"), + StatusId: c.Query("statusId"), + IsPublish: c.Query("isPublish"), + } + req := reqContext.ToParamRequest() req.Pagination = paginate articleFilesData, paging, err := _i.articleFilesService.All(req) @@ -62,17 +67,16 @@ func (_i *articleFilesController) All(c *fiber.Ctx) error { }) } -// Show get one ArticleFiles +// Show ArticleFiles // @Summary Get one ArticleFiles // @Description API for getting one ArticleFiles // @Tags ArticleFiles // @Security Bearer // @Param id path int true "ArticleFiles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-files/{id} [get] func (_i *articleFilesController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -101,10 +105,9 @@ func (_i *articleFilesController) Show(c *fiber.Ctx) error { // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-files/{articleId} [post] func (_i *articleFilesController) Save(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("articleId"), 10, 0) @@ -131,10 +134,9 @@ func (_i *articleFilesController) Save(c *fiber.Ctx) error { // @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 -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-files/{id} [put] func (_i *articleFilesController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -165,10 +167,9 @@ func (_i *articleFilesController) Update(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "ArticleFiles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-files/{id} [delete] func (_i *articleFilesController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -194,10 +195,9 @@ func (_i *articleFilesController) Delete(c *fiber.Ctx) error { // @Security Bearer // @Param id path string true "Article File 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /article-files/viewer/{id} [get] func (_i *articleFilesController) Viewer(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) diff --git a/app/module/article_files/repository/article_files.repository.go b/app/module/article_files/repository/article_files.repository.go index 91d03b0..a011ec2 100644 --- a/app/module/article_files/repository/article_files.repository.go +++ b/app/module/article_files/repository/article_files.repository.go @@ -5,6 +5,7 @@ import ( "go-humas-be/app/database/entity" "go-humas-be/app/module/article_files/request" "go-humas-be/utils/paginator" + "strings" ) type articleFilesRepository struct { @@ -31,6 +32,21 @@ func (_i *articleFilesRepository) GetAll(req request.ArticleFilesQueryRequest) ( var count int64 query := _i.DB.DB.Model(&entity.ArticleFiles{}) + query = query.Where("is_active = ?", true) + + if req.ArticleId != nil { + query = query.Where("article_id = ?", req.ArticleId) + } + if req.FileName != nil && *req.FileName != "" { + fileName := strings.ToLower(*req.FileName) + query = query.Where("LOWER(file_name) LIKE ?", "%"+strings.ToLower(fileName)+"%") + } + 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 +82,4 @@ func (_i *articleFilesRepository) Update(id uint, articleFiles *entity.ArticleFi func (_i *articleFilesRepository) Delete(id uint) error { return _i.DB.DB.Delete(&entity.ArticleFiles{}, id).Error -} \ No newline at end of file +} diff --git a/app/module/article_files/request/article_files.request.go b/app/module/article_files/request/article_files.request.go index f247149..d7650ee 100644 --- a/app/module/article_files/request/article_files.request.go +++ b/app/module/article_files/request/article_files.request.go @@ -3,6 +3,7 @@ package request import ( "go-humas-be/app/database/entity" "go-humas-be/utils/paginator" + "strconv" "time" ) @@ -11,40 +12,25 @@ type ArticleFilesGeneric interface { } type ArticleFilesQueryRequest struct { - ArticleId int `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"` - FileThumbnail string `json:"file_thumbnail" validate:"required"` - FileAlt string `json:"file_alt" validate:"required"` - WidthPixel string `json:"width_pixel" validate:"required"` - HeightPixel string `json:"height_pixel" validate:"required"` - Size string `json:"size" validate:"required"` - DownloadCount int `json:"download_count" validate:"required"` - CreatedById int `json:"created_by_id" 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"` + ArticleId *int `json:"articleId"` + FileName *string `json:"fileName"` + StatusId *int `json:"statusId"` + IsPublish *bool `json:"isPublish"` + Pagination *paginator.Pagination `json:"pagination"` } type ArticleFilesCreateRequest struct { - 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"` - FileThumbnail string `json:"file_thumbnail" validate:"required"` - FileAlt string `json:"file_alt" validate:"required"` - WidthPixel string `json:"width_pixel" validate:"required"` - HeightPixel string `json:"height_pixel" validate:"required"` - Size string `json:"size" validate:"required"` - DownloadCount int `json:"download_count" validate:"required"` - CreatedById int `json:"created_by_id" 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"` + ArticleId uint `json:"articleId" validate:"required"` + FilePath string `json:"filePath" validate:"required"` + FileUrl string `json:"fileUrl" validate:"required"` + FileName string `json:"fileName" validate:"required"` + FileThumbnail string `json:"fileThumbnail" validate:"required"` + FileAlt string `json:"fileAlt" validate:"required"` + WidthPixel string `json:"widthPixel" validate:"required"` + HeightPixel string `json:"heightPixel" validate:"required"` + Size string `json:"size" validate:"required"` + DownloadCount int `json:"downloadCount" validate:"required"` + StatusId int `json:"statusId" validate:"required"` } func (req ArticleFilesCreateRequest) ToEntity() *entity.ArticleFiles { @@ -59,33 +45,27 @@ func (req ArticleFilesCreateRequest) ToEntity() *entity.ArticleFiles { HeightPixel: req.HeightPixel, Size: req.Size, DownloadCount: req.DownloadCount, - CreatedById: req.CreatedById, StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsActive: req.IsActive, + IsPublish: false, } } type ArticleFilesUpdateRequest struct { ID uint `json:"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"` - FileThumbnail string `json:"file_thumbnail" validate:"required"` - FileAlt string `json:"file_alt" validate:"required"` - WidthPixel string `json:"width_pixel" validate:"required"` - HeightPixel string `json:"height_pixel" validate:"required"` + ArticleId uint `json:"articleId" validate:"required"` + FilePath string `json:"filePath" validate:"required"` + FileUrl string `json:"fileUrl" validate:"required"` + FileName string `json:"fileName" validate:"required"` + FileThumbnail string `json:"fileThumbnail" validate:"required"` + FileAlt string `json:"fileAlt" validate:"required"` + WidthPixel string `json:"widthPixel" validate:"required"` + HeightPixel string `json:"heightPixel" validate:"required"` Size string `json:"size" validate:"required"` - DownloadCount int `json:"download_count" validate:"required"` - CreatedById int `json:"created_by_id" 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"` + DownloadCount int `json:"downloadCount" validate:"required"` + CreatedById int `json:"createdById" validate:"required"` + StatusId int `json:"statusId" validate:"required"` + IsPublish bool `json:"isPublish" validate:"required"` + PublishedAt time.Time `json:"publishedAt" validate:"required"` } func (req ArticleFilesUpdateRequest) ToEntity() *entity.ArticleFiles { @@ -105,8 +85,41 @@ func (req ArticleFilesUpdateRequest) ToEntity() *entity.ArticleFiles { StatusId: req.StatusId, IsPublish: req.IsPublish, PublishedAt: req.PublishedAt, - IsActive: req.IsActive, - CreatedAt: req.CreatedAt, - UpdatedAt: req.UpdatedAt, + UpdatedAt: time.Now(), } } + +type ArticleFilesQueryRequestContext struct { + ArticleId string `json:"articleId"` + FileName string `json:"fileName"` + StatusId string `json:"statusId"` + IsPublish string `json:"isPublish"` +} + +func (req ArticleFilesQueryRequestContext) ToParamRequest() ArticleFilesQueryRequest { + var request ArticleFilesQueryRequest + + if articleIdStr := req.ArticleId; articleIdStr != "" { + articleId, err := strconv.Atoi(articleIdStr) + if err == nil { + request.ArticleId = &articleId + } + } + if fileName := req.FileName; fileName != "" { + request.FileName = &fileName + } + if statusIdStr := req.StatusId; statusIdStr != "" { + statusId, err := strconv.Atoi(statusIdStr) + if err == nil { + request.StatusId = &statusId + } + } + if isPublishStr := req.IsPublish; isPublishStr != "" { + isPublish, err := strconv.ParseBool(isPublishStr) + if err == nil { + request.IsPublish = &isPublish + } + } + + return request +} diff --git a/app/module/article_files/service/article_files.service.go b/app/module/article_files/service/article_files.service.go index e8f28d6..6805a43 100644 --- a/app/module/article_files/service/article_files.service.go +++ b/app/module/article_files/service/article_files.service.go @@ -138,7 +138,13 @@ func (_i *articleFilesService) Update(id uint, req request.ArticleFilesUpdateReq } func (_i *articleFilesService) Delete(id uint) error { - return _i.Repo.Delete(id) + result, err := _i.Repo.FindOne(id) + if err != nil { + return err + } + + result.IsActive = false + return _i.Repo.Update(id, result) } func (_i *articleFilesService) Viewer(c *fiber.Ctx, id uint) (err error) { diff --git a/app/module/articles/controller/articles.controller.go b/app/module/articles/controller/articles.controller.go index 8e2a8f6..ea9a584 100644 --- a/app/module/articles/controller/articles.controller.go +++ b/app/module/articles/controller/articles.controller.go @@ -36,10 +36,9 @@ func NewArticlesController(articlesService service.ArticlesService) ArticlesCont // @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 -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /articles [get] func (_i *articlesController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -47,7 +46,15 @@ func (_i *articlesController) All(c *fiber.Ctx) error { return err } - var req request.ArticlesQueryRequest + reqContext := request.ArticlesQueryRequestContext{ + Title: c.Query("title"), + Description: c.Query("description"), + Tags: c.Query("tags"), + TypeId: c.Query("typeId"), + StatusId: c.Query("statusId"), + IsPublish: c.Query("isPublish"), + } + req := reqContext.ToParamRequest() req.Pagination = paginate articlesData, paging, err := _i.articlesService.All(req) @@ -70,10 +77,9 @@ func (_i *articlesController) All(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "Articles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /articles/{id} [get] func (_i *articlesController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -100,10 +106,9 @@ func (_i *articlesController) Show(c *fiber.Ctx) error { // @Security Bearer // @Param payload body request.ArticlesCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /articles [post] func (_i *articlesController) Save(c *fiber.Ctx) error { req := new(request.ArticlesCreateRequest) @@ -130,10 +135,9 @@ func (_i *articlesController) Save(c *fiber.Ctx) error { // @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 -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /articles/{id} [put] func (_i *articlesController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -164,10 +168,9 @@ func (_i *articlesController) Update(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "Articles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /articles/{id} [delete] func (_i *articlesController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) diff --git a/app/module/articles/repository/articles.repository.go b/app/module/articles/repository/articles.repository.go index b30502a..d26d9b7 100644 --- a/app/module/articles/repository/articles.repository.go +++ b/app/module/articles/repository/articles.repository.go @@ -45,9 +45,6 @@ func (_i *articlesRepository) GetAll(req request.ArticlesQueryRequest) (articles 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)+"%") @@ -61,6 +58,9 @@ func (_i *articlesRepository) GetAll(req request.ArticlesQueryRequest) (articles if req.StatusId != nil { query = query.Where("status_id = ?", req.StatusId) } + if req.CreatedById != nil { + query = query.Where("created_by_id = ?", req.CreatedById) + } query.Count(&count) req.Pagination.Count = count diff --git a/app/module/articles/request/articles.request.go b/app/module/articles/request/articles.request.go index 12a3220..0c49e84 100644 --- a/app/module/articles/request/articles.request.go +++ b/app/module/articles/request/articles.request.go @@ -16,26 +16,19 @@ type ArticlesQueryRequest struct { Description *string `json:"description"` TypeId *int `json:"typeId"` Tags *string `json:"tags"` + CreatedById *int `json:"createdById"` 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:"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"` + 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"` } func (req ArticlesCreateRequest) ToEntity() *entity.Articles { @@ -46,14 +39,6 @@ func (req ArticlesCreateRequest) ToEntity() *entity.Articles { HtmlDescription: req.HtmlDescription, TypeId: req.TypeId, Tags: req.Tags, - ThumbnailPath: req.ThumbnailPath, - ThumbnailUrl: req.ThumbnailUrl, - PageUrl: req.PageUrl, - CreatedById: req.CreatedById, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsActive: req.IsActive, } } @@ -85,6 +70,7 @@ type ArticlesQueryRequestContext struct { Description string `json:"description"` TypeId string `json:"typeId"` Tags string `json:"tags"` + CreatedById string `json:"createdById"` IsPublish string `json:"isPublish"` StatusId string `json:"statusId"` } @@ -119,6 +105,12 @@ func (req ArticlesQueryRequestContext) ToParamRequest() ArticlesQueryRequest { request.StatusId = &statusId } } + if createdByIdStr := req.CreatedById; createdByIdStr != "" { + createdById, err := strconv.Atoi(createdByIdStr) + if err == nil { + request.CreatedById = &createdById + } + } return request } diff --git a/app/module/ppid_datas/controller/ppid_datas.controller.go b/app/module/ppid_datas/controller/ppid_datas.controller.go index 49cb509..3a2ad53 100644 --- a/app/module/ppid_datas/controller/ppid_datas.controller.go +++ b/app/module/ppid_datas/controller/ppid_datas.controller.go @@ -29,16 +29,16 @@ func NewPpidDatasController(ppidDatasService service.PpidDatasService) PpidDatas } } -// All get all PpidDatas +// All PpidDatas // @Summary Get all PpidDatas // @Description API for getting all PpidDatas // @Tags Task // @Security Bearer +// @Param req query request.PpidDatasQueryRequestContext false "query parameters" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /ppid-datas [get] func (_i *ppidDatasController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -46,7 +46,16 @@ func (_i *ppidDatasController) All(c *fiber.Ctx) error { return err } - var req request.PpidDatasQueryRequest + reqContext := request.PpidDatasQueryRequestContext{ + Title: c.Query("title"), + Description: c.Query("description"), + CategoryId: c.Query("categoryId"), + CreatedById: c.Query("createdById"), + StatusId: c.Query("statusId"), + IsPublish: c.Query("isPublish"), + } + + req := reqContext.ToParamRequest() req.Pagination = paginate ppidDatasData, paging, err := _i.ppidDatasService.All(req) @@ -55,23 +64,23 @@ func (_i *ppidDatasController) All(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"PpidDatas list successfully retrieved"}, Data: ppidDatasData, Meta: paging, }) } -// Show get one PpidDatas +// Show PpidDatas // @Summary Get one PpidDatas // @Description API for getting one PpidDatas // @Tags Task // @Security Bearer // @Param id path int true "PpidDatas 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /ppid-datas/{id} [get] func (_i *ppidDatasController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -85,22 +94,22 @@ func (_i *ppidDatasController) Show(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"PpidDatas successfully retrieved"}, Data: ppidDatasData, }) } -// Save create PpidDatas +// Save PpidDatas // @Summary Create PpidDatas // @Description API for create PpidDatas // @Tags Task // @Security Bearer -// @Body request.PpidDatasCreateRequest +// @Param payload body request.PpidDatasCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /ppid-datas [post] func (_i *ppidDatasController) Save(c *fiber.Ctx) error { req := new(request.PpidDatasCreateRequest) @@ -114,22 +123,22 @@ func (_i *ppidDatasController) Save(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"PpidDatas successfully created"}, }) } -// Update update PpidDatas +// Update PpidDatas // @Summary update PpidDatas // @Description API for update PpidDatas // @Tags Task // @Security Bearer -// @Body request.PpidDatasUpdateRequest +// @Param payload body request.PpidDatasCreateRequest true "Required payload" // @Param id path int true "PpidDatas 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /ppid-datas/{id} [put] func (_i *ppidDatasController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -148,21 +157,21 @@ func (_i *ppidDatasController) Update(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"PpidDatas successfully updated"}, }) } -// Delete delete PpidDatas +// Delete PpidDatas // @Summary delete PpidDatas // @Description API for delete PpidDatas // @Tags Task // @Security Bearer // @Param id path int true "PpidDatas 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /ppid-datas/{id} [delete] func (_i *ppidDatasController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -176,6 +185,7 @@ func (_i *ppidDatasController) Delete(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"PpidDatas successfully deleted"}, }) } diff --git a/app/module/ppid_datas/request/ppid_datas.request.go b/app/module/ppid_datas/request/ppid_datas.request.go index 180a70c..6a5a41a 100644 --- a/app/module/ppid_datas/request/ppid_datas.request.go +++ b/app/module/ppid_datas/request/ppid_datas.request.go @@ -3,6 +3,7 @@ package request import ( "go-humas-be/app/database/entity" "go-humas-be/utils/paginator" + "strconv" "time" ) @@ -11,26 +12,21 @@ type PpidDatasGeneric interface { } type PpidDatasQueryRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - CategoryId int `json:"category_id" validate:"required"` - CreatedById int `json:"created_by_id" 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"` + Description *string `json:"description"` + CategoryId *int `json:"categoryId"` + CreatedById *int `json:"createdById"` + StatusId *int `json:"statusId"` + IsPublish *bool `json:"isPublish"` Pagination *paginator.Pagination `json:"pagination"` } type PpidDatasCreateRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - CategoryId int `json:"category_id" validate:"required"` - CreatedById int `json:"created_by_id" 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"` + Description string `json:"description" validate:"required"` + CategoryId int `json:"categoryId" validate:"required"` + CreatedById int `json:"createdById" validate:"required"` + StatusId int `json:"statusId" validate:"required"` } func (req PpidDatasCreateRequest) ToEntity() *entity.PpidDatas { @@ -40,24 +36,18 @@ func (req PpidDatasCreateRequest) ToEntity() *entity.PpidDatas { CategoryId: req.CategoryId, CreatedById: req.CreatedById, StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsActive: req.IsActive, } } type PpidDatasUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - CategoryId int `json:"category_id" validate:"required"` - CreatedById int `json:"created_by_id" 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"` + ID uint `json:"id" validate:"required"` + Title string `json:"title" validate:"required"` + Description string `json:"description" validate:"required"` + CategoryId int `json:"category_id" validate:"required"` + CreatedById int `json:"created_by_id" validate:"required"` + StatusId int `json:"status_id" validate:"required"` + IsPublish *bool `json:"is_publish" validate:"required"` + PublishedAt *time.Time `json:"published_at" validate:"required"` } func (req PpidDatasUpdateRequest) ToEntity() *entity.PpidDatas { @@ -70,8 +60,52 @@ func (req PpidDatasUpdateRequest) ToEntity() *entity.PpidDatas { StatusId: req.StatusId, IsPublish: req.IsPublish, PublishedAt: req.PublishedAt, - IsActive: req.IsActive, - CreatedAt: req.CreatedAt, - UpdatedAt: req.UpdatedAt, + UpdatedAt: time.Now(), } } + +type PpidDatasQueryRequestContext struct { + Title string `json:"title"` + Description string `json:"description"` + CategoryId string `json:"categoryId"` + CreatedById string `json:"createdById"` + StatusId string `json:"statusId"` + IsPublish string `json:"isPublish"` +} + +func (req PpidDatasQueryRequestContext) ToParamRequest() PpidDatasQueryRequest { + var request PpidDatasQueryRequest + + if title := req.Title; title != "" { + request.Title = &title + } + if description := req.Description; description != "" { + request.Description = &description + } + if categoryIdStr := req.CategoryId; categoryIdStr != "" { + categoryId, err := strconv.Atoi(categoryIdStr) + if err == nil { + request.CategoryId = &categoryId + } + } + 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 + } + } + if createdByIdStr := req.CreatedById; createdByIdStr != "" { + createdById, err := strconv.Atoi(createdByIdStr) + if err == nil { + request.CreatedById = &createdById + } + } + + return request +} diff --git a/app/module/user_levels/controller/user_levels.controller.go b/app/module/user_levels/controller/user_levels.controller.go index b5e0e52..58f6aca 100644 --- a/app/module/user_levels/controller/user_levels.controller.go +++ b/app/module/user_levels/controller/user_levels.controller.go @@ -36,10 +36,9 @@ func NewUserLevelsController(userLevelsService service.UserLevelsService) UserLe // @Security Bearer // @Param req query request.UserLevelsQueryRequest false "query parameters" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-levels [get] func (_i *userLevelsController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -76,10 +75,9 @@ func (_i *userLevelsController) All(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "UserLevels 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-levels/{id} [get] func (_i *userLevelsController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -105,10 +103,9 @@ func (_i *userLevelsController) Show(c *fiber.Ctx) error { // @Security Bearer // @Param payload body request.UserLevelsCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-levels [post] func (_i *userLevelsController) Save(c *fiber.Ctx) error { req := new(request.UserLevelsCreateRequest) @@ -135,10 +132,9 @@ func (_i *userLevelsController) Save(c *fiber.Ctx) error { // @Param payload body request.UserLevelsUpdateRequest true "Required payload" // @Param id path int true "UserLevels 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-levels/{id} [put] func (_i *userLevelsController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) diff --git a/app/module/user_levels/request/user_levels.request.go b/app/module/user_levels/request/user_levels.request.go index a5eb0a1..9502738 100644 --- a/app/module/user_levels/request/user_levels.request.go +++ b/app/module/user_levels/request/user_levels.request.go @@ -25,7 +25,7 @@ type UserLevelsCreateRequest struct { LevelNumber int `json:"levelNumber" validate:"required"` ParentLevelId int `json:"parentLevelId" validate:"required"` ProvinceId int `json:"provinceId" validate:"required"` - IsActive *bool `json:"is_active"` + IsActive *bool `json:"isActive"` } func (req UserLevelsCreateRequest) ToEntity() *entity.UserLevels { diff --git a/app/module/user_role_accesses/controller/user_role_accesses.controller.go b/app/module/user_role_accesses/controller/user_role_accesses.controller.go index 50eb59b..dd9d9e9 100644 --- a/app/module/user_role_accesses/controller/user_role_accesses.controller.go +++ b/app/module/user_role_accesses/controller/user_role_accesses.controller.go @@ -29,16 +29,16 @@ func NewUserRoleAccessesController(userRoleAccessesService service.UserRoleAcces } } -// All get all UserRoleAccesses +// All UserRoleAccesses // @Summary Get all UserRoleAccesses // @Description API for getting all UserRoleAccesses -// @Tags Task +// @Tags UserRoleAccesses // @Security Bearer +// @Param req query request.UserRoleAccessesQueryRequest false "query parameters" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-role-accesses [get] func (_i *userRoleAccessesController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -46,7 +46,11 @@ func (_i *userRoleAccessesController) All(c *fiber.Ctx) error { return err } - var req request.UserRoleAccessesQueryRequest + reqContext := request.UserRoleAccessesQueryRequestContext{ + MenuId: c.Query("menuId"), + UserRoleId: c.Query("userRoleId"), + } + req := reqContext.ToParamRequest() req.Pagination = paginate userRoleAccessesData, paging, err := _i.userRoleAccessesService.All(req) @@ -55,23 +59,23 @@ func (_i *userRoleAccessesController) All(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"UserRoleAccesses list successfully retrieved"}, Data: userRoleAccessesData, Meta: paging, }) } -// Show get one UserRoleAccesses +// Show UserRoleAccesses // @Summary Get one UserRoleAccesses // @Description API for getting one UserRoleAccesses -// @Tags Task +// @Tags UserRoleAccesses // @Security Bearer // @Param id path int true "UserRoleAccesses 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-role-accesses/{id} [get] func (_i *userRoleAccessesController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -85,22 +89,22 @@ func (_i *userRoleAccessesController) Show(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"UserRoleAccesses successfully retrieved"}, Data: userRoleAccessesData, }) } -// Save create UserRoleAccesses +// Save UserRoleAccesses // @Summary Create UserRoleAccesses // @Description API for create UserRoleAccesses -// @Tags Task +// @Tags UserRoleAccesses // @Security Bearer -// @Body request.UserRoleAccessesCreateRequest +// @Param payload body request.UserRoleAccessesCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-role-accesses [post] func (_i *userRoleAccessesController) Save(c *fiber.Ctx) error { req := new(request.UserRoleAccessesCreateRequest) @@ -114,22 +118,23 @@ func (_i *userRoleAccessesController) Save(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"UserRoleAccesses successfully created"}, }) } -// Update update UserRoleAccesses +// Update UserRoleAccesses // @Summary update UserRoleAccesses // @Description API for update UserRoleAccesses -// @Tags Task +// @Tags UserRoleAccesses // @Security Bearer -// @Body request.UserRoleAccessesUpdateRequest +// @Param payload body request.UserRoleAccessesUpdateRequest true "Required payload" // @Param id path int true "UserRoleAccesses 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 +// @Success 200 {object} response.Response +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-role-accesses/{id} [put] func (_i *userRoleAccessesController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -148,21 +153,21 @@ func (_i *userRoleAccessesController) Update(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"UserRoleAccesses successfully updated"}, }) } -// Delete delete UserRoleAccesses +// Delete UserRoleAccesses // @Summary delete UserRoleAccesses // @Description API for delete UserRoleAccesses -// @Tags Task +// @Tags UserRoleAccesses // @Security Bearer // @Param id path int true "UserRoleAccesses 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-role-accesses/{id} [delete] func (_i *userRoleAccessesController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -176,6 +181,7 @@ func (_i *userRoleAccessesController) Delete(c *fiber.Ctx) error { } return utilRes.Resp(c, utilRes.Response{ + Success: true, Messages: utilRes.Messages{"UserRoleAccesses successfully deleted"}, }) } diff --git a/app/module/user_role_accesses/mapper/user_role_accesses.mapper.go b/app/module/user_role_accesses/mapper/user_role_accesses.mapper.go index 2e829ae..df81c3e 100644 --- a/app/module/user_role_accesses/mapper/user_role_accesses.mapper.go +++ b/app/module/user_role_accesses/mapper/user_role_accesses.mapper.go @@ -8,19 +8,19 @@ import ( func UserRoleAccessesResponseMapper(userRoleAccessesReq *entity.UserRoleAccesses) (userRoleAccessesRes *res.UserRoleAccessesResponse) { if userRoleAccessesReq != nil { userRoleAccessesRes = &res.UserRoleAccessesResponse{ - ID: userRoleAccessesReq.ID, - UserRoleId: userRoleAccessesReq.UserRoleId, - MenuId: userRoleAccessesReq.MenuId, - IsViewEnabled: userRoleAccessesReq.IsViewEnabled, - IsInsertEnabled: userRoleAccessesReq.IsInsertEnabled, - IsUpdateEnabled: userRoleAccessesReq.IsUpdateEnabled, - IsDeleteEnabled: userRoleAccessesReq.IsDeleteEnabled, - IsApprovalEnabled: userRoleAccessesReq.IsApprovalEnabled, + ID: userRoleAccessesReq.ID, + UserRoleId: userRoleAccessesReq.UserRoleId, + MenuId: userRoleAccessesReq.MenuId, + IsViewEnabled: userRoleAccessesReq.IsViewEnabled, + IsInsertEnabled: userRoleAccessesReq.IsInsertEnabled, + IsUpdateEnabled: userRoleAccessesReq.IsUpdateEnabled, + IsDeleteEnabled: userRoleAccessesReq.IsDeleteEnabled, + IsApprovalEnabled: userRoleAccessesReq.IsApprovalEnabled, IsAdminEnabled: userRoleAccessesReq.IsAdminEnabled, - IsActive: userRoleAccessesReq.IsActive, - CreatedAt: userRoleAccessesReq.CreatedAt, - UpdatedAt: userRoleAccessesReq.UpdatedAt, + IsActive: userRoleAccessesReq.IsActive, + CreatedAt: userRoleAccessesReq.CreatedAt, + UpdatedAt: userRoleAccessesReq.UpdatedAt, } } return userRoleAccessesRes -} \ No newline at end of file +} diff --git a/app/module/user_role_accesses/repository/user_role_accesses.repository.go b/app/module/user_role_accesses/repository/user_role_accesses.repository.go index e6e768b..e2a22fd 100644 --- a/app/module/user_role_accesses/repository/user_role_accesses.repository.go +++ b/app/module/user_role_accesses/repository/user_role_accesses.repository.go @@ -31,6 +31,14 @@ func (_i *userRoleAccessesRepository) GetAll(req request.UserRoleAccessesQueryRe var count int64 query := _i.DB.DB.Model(&entity.UserRoleAccesses{}) + query = query.Where("is_active = ?", true) + + if req.UserRoleId != nil { + query = query.Where("user_role_id = ?", req.UserRoleId) + } + if req.MenuId != nil { + query = query.Where("menu_id = ?", req.MenuId) + } query.Count(&count) req.Pagination.Count = count @@ -66,4 +74,4 @@ func (_i *userRoleAccessesRepository) Update(id uint, userRoleAccesses *entity.U func (_i *userRoleAccessesRepository) Delete(id uint) error { return _i.DB.DB.Delete(&entity.UserRoleAccesses{}, id).Error -} \ No newline at end of file +} diff --git a/app/module/user_role_accesses/request/user_role_accesses.request.go b/app/module/user_role_accesses/request/user_role_accesses.request.go index 20fa2f1..f4d7ac5 100644 --- a/app/module/user_role_accesses/request/user_role_accesses.request.go +++ b/app/module/user_role_accesses/request/user_role_accesses.request.go @@ -3,6 +3,7 @@ package request import ( "go-humas-be/app/database/entity" "go-humas-be/utils/paginator" + "strconv" "time" ) @@ -11,73 +12,84 @@ type UserRoleAccessesGeneric interface { } type UserRoleAccessesQueryRequest struct { - UserRoleId int `json:"user_role_id" validate:"required"` - MenuId int `json:"menu_id" validate:"required"` - IsViewEnabled bool `json:"is_view_enabled" validate:"required"` - IsInsertEnabled bool `json:"is_insert_enabled" validate:"required"` - IsUpdateEnabled bool `json:"is_update_enabled" validate:"required"` - IsDeleteEnabled bool `json:"is_delete_enabled" validate:"required"` - IsApprovalEnabled bool `json:"is_approval_enabled" validate:"required"` - IsAdminEnabled bool `json:"is_admin_enabled" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` - Pagination *paginator.Pagination `json:"pagination"` + UserRoleId *int `json:"userRoleId" validate:"required"` + MenuId *int `json:"menuId" validate:"required"` + IsActive *bool `json:"isActive" validate:"required"` + Pagination *paginator.Pagination `json:"pagination"` } - type UserRoleAccessesCreateRequest struct { - UserRoleId int `json:"user_role_id" validate:"required"` - MenuId int `json:"menu_id" validate:"required"` - IsViewEnabled bool `json:"is_view_enabled" validate:"required"` - IsInsertEnabled bool `json:"is_insert_enabled" validate:"required"` - IsUpdateEnabled bool `json:"is_update_enabled" validate:"required"` - IsDeleteEnabled bool `json:"is_delete_enabled" validate:"required"` - IsApprovalEnabled bool `json:"is_approval_enabled" validate:"required"` - IsAdminEnabled bool `json:"is_admin_enabled" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` + UserRoleId int `json:"userRoleId" validate:"required"` + MenuId int `json:"menuId" validate:"required"` + IsViewEnabled bool `json:"isViewEnabled" validate:"required"` + IsInsertEnabled bool `json:"isInsertEnabled" validate:"required"` + IsUpdateEnabled bool `json:"isUpdateEnabled" validate:"required"` + IsDeleteEnabled bool `json:"isDeleteEnabled" validate:"required"` + IsApprovalEnabled bool `json:"isApprovalEnabled" validate:"required"` + IsAdminEnabled bool `json:"isAdminEnabled" validate:"required"` } func (req UserRoleAccessesCreateRequest) ToEntity() *entity.UserRoleAccesses { return &entity.UserRoleAccesses{ - UserRoleId: req.UserRoleId, - MenuId: req.MenuId, - IsViewEnabled: req.IsViewEnabled, - IsInsertEnabled: req.IsInsertEnabled, - IsUpdateEnabled: req.IsUpdateEnabled, - IsDeleteEnabled: req.IsDeleteEnabled, - IsApprovalEnabled: req.IsApprovalEnabled, + UserRoleId: req.UserRoleId, + MenuId: req.MenuId, + IsViewEnabled: req.IsViewEnabled, + IsInsertEnabled: req.IsInsertEnabled, + IsUpdateEnabled: req.IsUpdateEnabled, + IsDeleteEnabled: req.IsDeleteEnabled, + IsApprovalEnabled: req.IsApprovalEnabled, IsAdminEnabled: req.IsAdminEnabled, - IsActive: req.IsActive, } } type UserRoleAccessesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - UserRoleId int `json:"user_role_id" validate:"required"` - MenuId int `json:"menu_id" validate:"required"` - IsViewEnabled bool `json:"is_view_enabled" validate:"required"` - IsInsertEnabled bool `json:"is_insert_enabled" validate:"required"` - IsUpdateEnabled bool `json:"is_update_enabled" validate:"required"` - IsDeleteEnabled bool `json:"is_delete_enabled" validate:"required"` - IsApprovalEnabled bool `json:"is_approval_enabled" validate:"required"` - IsAdminEnabled bool `json:"is_admin_enabled" validate:"required"` - IsActive bool `json:"is_active" validate:"required"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uint `json:"id" validate:"required"` + UserRoleId int `json:"user_role_id" validate:"required"` + MenuId int `json:"menu_id" validate:"required"` + IsViewEnabled bool `json:"is_view_enabled" validate:"required"` + IsInsertEnabled bool `json:"is_insert_enabled" validate:"required"` + IsUpdateEnabled bool `json:"is_update_enabled" validate:"required"` + IsDeleteEnabled bool `json:"is_delete_enabled" validate:"required"` + IsApprovalEnabled bool `json:"is_approval_enabled" validate:"required"` + IsAdminEnabled bool `json:"is_admin_enabled" validate:"required"` } func (req UserRoleAccessesUpdateRequest) ToEntity() *entity.UserRoleAccesses { return &entity.UserRoleAccesses{ - ID: req.ID, - UserRoleId: req.UserRoleId, - MenuId: req.MenuId, - IsViewEnabled: req.IsViewEnabled, - IsInsertEnabled: req.IsInsertEnabled, - IsUpdateEnabled: req.IsUpdateEnabled, - IsDeleteEnabled: req.IsDeleteEnabled, - IsApprovalEnabled: req.IsApprovalEnabled, + ID: req.ID, + UserRoleId: req.UserRoleId, + MenuId: req.MenuId, + IsViewEnabled: req.IsViewEnabled, + IsInsertEnabled: req.IsInsertEnabled, + IsUpdateEnabled: req.IsUpdateEnabled, + IsDeleteEnabled: req.IsDeleteEnabled, + IsApprovalEnabled: req.IsApprovalEnabled, IsAdminEnabled: req.IsAdminEnabled, - IsActive: req.IsActive, - CreatedAt: req.CreatedAt, - UpdatedAt: req.UpdatedAt, + UpdatedAt: time.Now(), } -} \ No newline at end of file +} + +type UserRoleAccessesQueryRequestContext struct { + UserRoleId string `json:"userRoleId"` + MenuId string `json:"menuId"` +} + +func (req UserRoleAccessesQueryRequestContext) ToParamRequest() UserRoleAccessesQueryRequest { + var request UserRoleAccessesQueryRequest + + if userRoleIdStr := req.UserRoleId; userRoleIdStr != "" { + userRoleId, err := strconv.Atoi(userRoleIdStr) + if err == nil { + request.UserRoleId = &userRoleId + } + } + + if menuIdStr := req.MenuId; menuIdStr != "" { + menuId, err := strconv.Atoi(menuIdStr) + if err == nil { + request.MenuId = &menuId + } + } + + return request +} diff --git a/app/module/user_role_accesses/response/user_role_accesses.response.go b/app/module/user_role_accesses/response/user_role_accesses.response.go index bb333d4..8dc53a3 100644 --- a/app/module/user_role_accesses/response/user_role_accesses.response.go +++ b/app/module/user_role_accesses/response/user_role_accesses.response.go @@ -3,16 +3,16 @@ package response import "time" type UserRoleAccessesResponse struct { - ID uint `json:"id"` - UserRoleId int `json:"user_role_id"` - MenuId int `json:"menu_id"` - IsViewEnabled bool `json:"is_view_enabled"` - IsInsertEnabled bool `json:"is_insert_enabled"` - IsUpdateEnabled bool `json:"is_update_enabled"` - IsDeleteEnabled bool `json:"is_delete_enabled"` - IsApprovalEnabled bool `json:"is_approval_enabled"` - IsAdminEnabled bool `json:"is_admin_enabled"` - 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"` + UserRoleId int `json:"user_role_id"` + MenuId int `json:"menu_id"` + IsViewEnabled bool `json:"is_view_enabled"` + IsInsertEnabled bool `json:"is_insert_enabled"` + IsUpdateEnabled bool `json:"is_update_enabled"` + IsDeleteEnabled bool `json:"is_delete_enabled"` + IsApprovalEnabled bool `json:"is_approval_enabled"` + IsAdminEnabled bool `json:"is_admin_enabled"` + IsActive *bool `json:"is_active"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} diff --git a/app/module/user_role_accesses/service/user_role_accesses.service.go b/app/module/user_role_accesses/service/user_role_accesses.service.go index c643062..c103c3f 100644 --- a/app/module/user_role_accesses/service/user_role_accesses.service.go +++ b/app/module/user_role_accesses/service/user_role_accesses.service.go @@ -68,5 +68,12 @@ func (_i *userRoleAccessesService) Update(id uint, req request.UserRoleAccessesU } func (_i *userRoleAccessesService) 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_roles/controller/user_roles.controller.go b/app/module/user_roles/controller/user_roles.controller.go index 2288056..311398b 100644 --- a/app/module/user_roles/controller/user_roles.controller.go +++ b/app/module/user_roles/controller/user_roles.controller.go @@ -38,10 +38,9 @@ func NewUserRolesController(userRolesService service.UserRolesService, log zerol // @Security Bearer // @Param req query request.UserRolesQueryRequest false "query parameters" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-roles [get] func (_i *userRolesController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -79,10 +78,9 @@ func (_i *userRolesController) All(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "UserRoles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-roles/{id} [get] func (_i *userRolesController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -109,10 +107,9 @@ func (_i *userRolesController) Show(c *fiber.Ctx) error { // @Security Bearer // @Param payload body request.UserRolesCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-roles [post] func (_i *userRolesController) Save(c *fiber.Ctx) error { req := new(request.UserRolesCreateRequest) @@ -139,10 +136,9 @@ func (_i *userRolesController) Save(c *fiber.Ctx) error { // @Param payload body request.UserRolesUpdateRequest true "Required payload" // @Param id path int true "UserRoles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-roles/{id} [put] func (_i *userRolesController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -173,10 +169,9 @@ func (_i *userRolesController) Update(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "UserRoles 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /user-roles/{id} [delete] func (_i *userRolesController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) diff --git a/app/module/user_roles/request/user_roles.request.go b/app/module/user_roles/request/user_roles.request.go index 4370fd0..ef91924 100644 --- a/app/module/user_roles/request/user_roles.request.go +++ b/app/module/user_roles/request/user_roles.request.go @@ -25,9 +25,6 @@ type UserRolesCreateRequest struct { Description string `json:"description" validate:"required"` Code string `json:"code" validate:"required"` LevelNumber int `json:"level_number" validate:"required"` - StatusId *int `json:"status_id"` - CreatedById *int `json:"created_by_id"` - IsActive *bool `json:"is_active"` } func (req UserRolesCreateRequest) ToEntity() *entity.UserRoles { @@ -36,9 +33,6 @@ func (req UserRolesCreateRequest) ToEntity() *entity.UserRoles { Description: req.Description, Code: req.Code, LevelNumber: req.LevelNumber, - StatusId: req.StatusId, - CreatedById: req.CreatedById, - IsActive: req.IsActive, } } diff --git a/app/module/user_roles/service/user_roles.service.go b/app/module/user_roles/service/user_roles.service.go index 59e88b7..b10b8f1 100644 --- a/app/module/user_roles/service/user_roles.service.go +++ b/app/module/user_roles/service/user_roles.service.go @@ -59,8 +59,12 @@ func (_i *userRolesService) Show(id uint) (userRoles *response.UserRolesResponse func (_i *userRolesService) Save(req request.UserRolesCreateRequest) (err error) { _i.Log.Info().Interface("data", req).Msg("") + newReq := req.ToEntity() - return _i.Repo.Create(req.ToEntity()) + statusId := 1 + newReq.StatusId = &statusId + + return _i.Repo.Create(newReq) } func (_i *userRolesService) Update(id uint, req request.UserRolesUpdateRequest) (err error) { diff --git a/app/module/users/controller/users.controller.go b/app/module/users/controller/users.controller.go index 6d537ab..9a6b678 100644 --- a/app/module/users/controller/users.controller.go +++ b/app/module/users/controller/users.controller.go @@ -36,10 +36,9 @@ func NewUsersController(usersService service.UsersService) UsersController { // @Security Bearer // @Param req query request.UsersQueryRequest false "query parameters" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /users [get] func (_i *usersController) All(c *fiber.Ctx) error { paginate, err := paginator.Paginate(c) @@ -80,10 +79,9 @@ func (_i *usersController) All(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "Users 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /users/{id} [get] func (_i *usersController) Show(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -110,10 +108,9 @@ func (_i *usersController) Show(c *fiber.Ctx) error { // @Security Bearer // @Param payload body request.UsersCreateRequest true "Required payload" // @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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /users [post] func (_i *usersController) Save(c *fiber.Ctx) error { req := new(request.UsersCreateRequest) @@ -140,10 +137,9 @@ func (_i *usersController) Save(c *fiber.Ctx) error { // @Param payload body request.UsersUpdateRequest true "Required payload" // @Param id path int true "Users 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /users/{id} [put] func (_i *usersController) Update(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -174,10 +170,9 @@ func (_i *usersController) Update(c *fiber.Ctx) error { // @Security Bearer // @Param id path int true "Users 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 +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError // @Router /users/{id} [delete] func (_i *usersController) Delete(c *fiber.Ctx) error { id, err := strconv.ParseUint(c.Params("id"), 10, 0) diff --git a/app/module/users/request/users.request.go b/app/module/users/request/users.request.go index 0fa33a2..3db362d 100644 --- a/app/module/users/request/users.request.go +++ b/app/module/users/request/users.request.go @@ -23,85 +23,73 @@ type UsersQueryRequest struct { } type UsersCreateRequest struct { - Username string `json:"username" validate:"required,lowercase"` - Email string `json:"email" validate:"required,email"` - Fullname string `json:"fullname" validate:"required"` - Address string `json:"address" validate:"required"` - PhoneNumber string `json:"phoneNumber" validate:"required"` - WorkType string `json:"workType" validate:"required"` - GenderType string `json:"genderType" validate:"required"` - IdentityType string `json:"identityType" validate:"required"` - IdentityNumber string `json:"identityNumber" validate:"required"` - DateOfBirth string `json:"dateOfBirth" validate:"required"` - LastEducation string `json:"lastEducation" validate:"required"` - UserRoleId int `json:"userRoleId" validate:"required"` - UserLevelsId int `json:"userLevelsId" validate:"required"` - KeycloakId *string `json:"keycloakId"` - StatusId *int `json:"statusId"` - CreatedById *int `json:"createdById"` - ProfilePicturePath *string `json:"profilePicturePath"` - IsActive *bool `json:"isActive"` + Username string `json:"username" validate:"required,lowercase"` + Email string `json:"email" validate:"required,email"` + Fullname string `json:"fullname" validate:"required"` + Address string `json:"address" validate:"required"` + PhoneNumber string `json:"phoneNumber" validate:"required"` + WorkType string `json:"workType" validate:"required"` + GenderType string `json:"genderType" validate:"required"` + IdentityType string `json:"identityType" validate:"required"` + IdentityNumber string `json:"identityNumber" validate:"required"` + DateOfBirth string `json:"dateOfBirth" validate:"required"` + LastEducation string `json:"lastEducation" validate:"required"` + UserRoleId int `json:"userRoleId" validate:"required"` + UserLevelsId int `json:"userLevelsId" validate:"required"` } func (req UsersCreateRequest) ToEntity() *entity.Users { return &entity.Users{ - Username: req.Username, - Email: req.Email, - Fullname: req.Fullname, - Address: req.Address, - PhoneNumber: req.PhoneNumber, - WorkType: req.WorkType, - GenderType: req.GenderType, - IdentityType: req.IdentityType, - IdentityNumber: req.IdentityNumber, - DateOfBirth: req.DateOfBirth, - LastEducation: req.LastEducation, - KeycloakId: req.KeycloakId, - UserRoleId: req.UserRoleId, - StatusId: req.StatusId, - UserLevelsId: req.UserLevelsId, - CreatedById: req.CreatedById, - ProfilePicturePath: req.ProfilePicturePath, - IsActive: req.IsActive, + Username: req.Username, + Email: req.Email, + Fullname: req.Fullname, + Address: req.Address, + PhoneNumber: req.PhoneNumber, + WorkType: req.WorkType, + GenderType: req.GenderType, + IdentityType: req.IdentityType, + IdentityNumber: req.IdentityNumber, + DateOfBirth: req.DateOfBirth, + LastEducation: req.LastEducation, + UserRoleId: req.UserRoleId, + UserLevelsId: req.UserLevelsId, } } type UsersUpdateRequest struct { - Username string `json:"username" validate:"required,lowercase"` - Email string `json:"email" validate:"required,email"` - Fullname string `json:"fullname" validate:"required"` - Address string `json:"address" validate:"required"` - PhoneNumber string `json:"phoneNumber" validate:"required"` - WorkType string `json:"workType" validate:"required"` - GenderType string `json:"genderType" validate:"required"` - IdentityType string `json:"identityType" validate:"required"` - IdentityNumber string `json:"identityNumber" validate:"required"` - DateOfBirth string `json:"dateOfBirth" validate:"required"` - LastEducation string `json:"lastEducation" validate:"required"` - UserRoleId int `json:"userRoleId" validate:"required"` - UserLevelsId int `json:"userLevelsId" validate:"required"` - ProfilePicturePath *string `json:"profile_picture_path"` - StatusId *int `json:"status_id"` + Username string `json:"username" validate:"required,lowercase"` + Email string `json:"email" validate:"required,email"` + Fullname string `json:"fullname" validate:"required"` + Address string `json:"address" validate:"required"` + PhoneNumber string `json:"phoneNumber" validate:"required"` + WorkType string `json:"workType" validate:"required"` + GenderType string `json:"genderType" validate:"required"` + IdentityType string `json:"identityType" validate:"required"` + IdentityNumber string `json:"identityNumber" validate:"required"` + DateOfBirth string `json:"dateOfBirth" validate:"required"` + LastEducation string `json:"lastEducation" validate:"required"` + UserRoleId int `json:"userRoleId" validate:"required"` + UserLevelsId int `json:"userLevelsId" validate:"required"` + StatusId *int `json:"status_id"` } func (req UsersUpdateRequest) ToEntity() *entity.Users { return &entity.Users{ - Username: req.Username, - Email: req.Email, - Fullname: req.Fullname, - Address: req.Address, - PhoneNumber: req.PhoneNumber, - WorkType: req.WorkType, - GenderType: req.GenderType, - IdentityType: req.IdentityType, - IdentityNumber: req.IdentityNumber, - DateOfBirth: req.DateOfBirth, - LastEducation: req.LastEducation, - UserRoleId: req.UserRoleId, - StatusId: req.StatusId, - UserLevelsId: req.UserLevelsId, - ProfilePicturePath: req.ProfilePicturePath, - UpdatedAt: time.Now(), + Username: req.Username, + Email: req.Email, + Fullname: req.Fullname, + Address: req.Address, + PhoneNumber: req.PhoneNumber, + WorkType: req.WorkType, + GenderType: req.GenderType, + IdentityType: req.IdentityType, + IdentityNumber: req.IdentityNumber, + DateOfBirth: req.DateOfBirth, + LastEducation: req.LastEducation, + UserRoleId: req.UserRoleId, + StatusId: req.StatusId, + UserLevelsId: req.UserLevelsId, + UpdatedAt: time.Now(), } } diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index ab31342..0d1a00d 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -24,9 +24,46 @@ const docTemplate = `{ ], "description": "API for getting all ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "Get all ArticleCategories", + "parameters": [ + { + "type": "integer", + "name": "createdById", + "in": "query" + }, + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "boolean", + "name": "isEnabled", + "in": "query" + }, + { + "type": "boolean", + "name": "isPublish", + "in": "query" + }, + { + "type": "integer", + "name": "parentId", + "in": "query" + }, + { + "type": "integer", + "name": "statusId", + "in": "query" + }, + { + "type": "string", + "name": "title", + "in": "query" + } + ], "responses": { "200": { "description": "OK", @@ -34,28 +71,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -68,7 +99,7 @@ const docTemplate = `{ ], "description": "API for create ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "Create ArticleCategories", "parameters": [ @@ -89,28 +120,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -125,7 +150,7 @@ const docTemplate = `{ ], "description": "API for getting one ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "Get one ArticleCategories", "parameters": [ @@ -144,28 +169,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -178,7 +197,7 @@ const docTemplate = `{ ], "description": "API for update ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "update ArticleCategories", "parameters": [ @@ -188,7 +207,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.ArticleCategoriesCreateRequest" + "$ref": "#/definitions/request.ArticleCategoriesUpdateRequest" } }, { @@ -206,28 +225,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -240,7 +253,7 @@ const docTemplate = `{ ], "description": "API for delete ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "delete ArticleCategories", "parameters": [ @@ -259,28 +272,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -546,7 +553,7 @@ const docTemplate = `{ ], "description": "API for getting all ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "Get all ArticleFiles", "responses": { @@ -556,28 +563,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -592,7 +593,7 @@ const docTemplate = `{ ], "description": "API for create ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "Create ArticleFiles", "parameters": [ @@ -611,28 +612,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -650,7 +645,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Task" + "ArticleFiles" ], "summary": "Upload ArticleFiles", "parameters": [ @@ -676,28 +671,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -712,7 +701,7 @@ const docTemplate = `{ ], "description": "API for getting one ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "Get one ArticleFiles", "parameters": [ @@ -731,28 +720,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -765,7 +748,7 @@ const docTemplate = `{ ], "description": "API for update ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "update ArticleFiles", "parameters": [ @@ -793,28 +776,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -827,7 +804,7 @@ const docTemplate = `{ ], "description": "API for delete ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "delete ArticleFiles", "parameters": [ @@ -846,28 +823,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -886,6 +857,11 @@ const docTemplate = `{ ], "summary": "Get all Articles", "parameters": [ + { + "type": "integer", + "name": "createdById", + "in": "query" + }, { "type": "string", "name": "description", @@ -924,28 +900,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -979,28 +949,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -1034,28 +998,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -1096,28 +1054,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -1149,28 +1101,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4004,28 +3950,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4059,28 +3999,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4114,28 +4048,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4176,28 +4104,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4265,9 +4187,29 @@ const docTemplate = `{ ], "description": "API for getting all UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "Get all UserRoleAccesses", + "parameters": [ + { + "type": "boolean", + "name": "isActive", + "in": "query", + "required": true + }, + { + "type": "integer", + "name": "menuId", + "in": "query", + "required": true + }, + { + "type": "integer", + "name": "userRoleId", + "in": "query", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -4275,28 +4217,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4309,9 +4245,20 @@ const docTemplate = `{ ], "description": "API for create UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "Create UserRoleAccesses", + "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UserRoleAccessesCreateRequest" + } + } + ], "responses": { "200": { "description": "OK", @@ -4319,28 +4266,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4355,7 +4296,7 @@ const docTemplate = `{ ], "description": "API for getting one UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "Get one UserRoleAccesses", "parameters": [ @@ -4374,28 +4315,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4408,10 +4343,19 @@ const docTemplate = `{ ], "description": "API for update UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "update UserRoleAccesses", "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UserRoleAccessesUpdateRequest" + } + }, { "type": "integer", "description": "UserRoleAccesses ID", @@ -4427,28 +4371,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4461,7 +4399,7 @@ const docTemplate = `{ ], "description": "API for delete UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "delete UserRoleAccesses", "parameters": [ @@ -4480,28 +4418,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4553,28 +4485,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4608,28 +4534,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4663,28 +4583,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4725,28 +4639,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4778,28 +4686,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4861,28 +4763,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4916,28 +4812,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4971,28 +4861,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -5033,28 +4917,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -5086,28 +4964,22 @@ const docTemplate = `{ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -5141,47 +5013,66 @@ const docTemplate = `{ "request.ArticleCategoriesCreateRequest": { "type": "object", "required": [ - "created_by_id", "description", - "is_active", - "is_enabled", - "is_publish", - "parent_id", - "published_at", - "status_id", - "thumbnail_path", - "thumbnail_url", + "isEnabled", + "parentId", + "statusId", "title" ], "properties": { - "created_by_id": { - "type": "integer" - }, "description": { "type": "string" }, - "is_active": { + "isEnabled": { "type": "boolean" }, - "is_enabled": { - "type": "boolean" - }, - "is_publish": { - "type": "boolean" - }, - "parent_id": { + "parentId": { "type": "integer" }, - "published_at": { - "type": "string" - }, - "status_id": { + "statusId": { "type": "integer" }, - "thumbnail_path": { + "title": { + "type": "string" + } + } + }, + "request.ArticleCategoriesUpdateRequest": { + "type": "object", + "required": [ + "description", + "id", + "parentId", + "thumbnailPath", + "thumbnailUrl", + "title" + ], + "properties": { + "description": { "type": "string" }, - "thumbnail_url": { + "id": { + "type": "integer" + }, + "isEnabled": { + "type": "boolean" + }, + "isPublish": { + "type": "boolean" + }, + "parentId": { + "type": "integer" + }, + "publishedAt": { + "type": "string" + }, + "statusId": { + "type": "integer" + }, + "thumbnailPath": { + "type": "string" + }, + "thumbnailUrl": { "type": "string" }, "title": { @@ -5192,76 +5083,66 @@ 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", + "articleId", + "createdById", + "downloadCount", + "fileAlt", + "fileName", + "filePath", + "fileThumbnail", + "fileUrl", + "heightPixel", "id", - "is_active", - "is_publish", - "published_at", + "isPublish", + "publishedAt", "size", - "status_id", - "width_pixel" + "statusId", + "widthPixel" ], "properties": { - "article_id": { + "articleId": { "type": "integer" }, - "created_at": { - "type": "string" - }, - "created_by_id": { + "createdById": { "type": "integer" }, - "download_count": { + "downloadCount": { "type": "integer" }, - "file_alt": { + "fileAlt": { "type": "string" }, - "file_name": { + "fileName": { "type": "string" }, - "file_path": { + "filePath": { "type": "string" }, - "file_thumbnail": { + "fileThumbnail": { "type": "string" }, - "file_url": { + "fileUrl": { "type": "string" }, - "height_pixel": { + "heightPixel": { "type": "string" }, "id": { "type": "integer" }, - "is_active": { + "isPublish": { "type": "boolean" }, - "is_publish": { - "type": "boolean" - }, - "published_at": { + "publishedAt": { "type": "string" }, "size": { "type": "string" }, - "status_id": { + "statusId": { "type": "integer" }, - "updated_at": { - "type": "string" - }, - "width_pixel": { + "widthPixel": { "type": "string" } } @@ -5277,42 +5158,18 @@ const docTemplate = `{ "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" }, @@ -5402,7 +5259,7 @@ const docTemplate = `{ "aliasName": { "type": "string" }, - "is_active": { + "isActive": { "type": "boolean" }, "levelNumber": { @@ -5446,6 +5303,88 @@ const docTemplate = `{ } } }, + "request.UserRoleAccessesCreateRequest": { + "type": "object", + "required": [ + "isAdminEnabled", + "isApprovalEnabled", + "isDeleteEnabled", + "isInsertEnabled", + "isUpdateEnabled", + "isViewEnabled", + "menuId", + "userRoleId" + ], + "properties": { + "isAdminEnabled": { + "type": "boolean" + }, + "isApprovalEnabled": { + "type": "boolean" + }, + "isDeleteEnabled": { + "type": "boolean" + }, + "isInsertEnabled": { + "type": "boolean" + }, + "isUpdateEnabled": { + "type": "boolean" + }, + "isViewEnabled": { + "type": "boolean" + }, + "menuId": { + "type": "integer" + }, + "userRoleId": { + "type": "integer" + } + } + }, + "request.UserRoleAccessesUpdateRequest": { + "type": "object", + "required": [ + "id", + "is_admin_enabled", + "is_approval_enabled", + "is_delete_enabled", + "is_insert_enabled", + "is_update_enabled", + "is_view_enabled", + "menu_id", + "user_role_id" + ], + "properties": { + "id": { + "type": "integer" + }, + "is_admin_enabled": { + "type": "boolean" + }, + "is_approval_enabled": { + "type": "boolean" + }, + "is_delete_enabled": { + "type": "boolean" + }, + "is_insert_enabled": { + "type": "boolean" + }, + "is_update_enabled": { + "type": "boolean" + }, + "is_view_enabled": { + "type": "boolean" + }, + "menu_id": { + "type": "integer" + }, + "user_role_id": { + "type": "integer" + } + } + }, "request.UserRolesCreateRequest": { "type": "object", "required": [ @@ -5458,23 +5397,14 @@ const docTemplate = `{ "code": { "type": "string" }, - "created_by_id": { - "type": "integer" - }, "description": { "type": "string" }, - "is_active": { - "type": "boolean" - }, "level_number": { "type": "integer" }, "name": { "type": "string" - }, - "status_id": { - "type": "integer" } } }, @@ -5525,9 +5455,6 @@ const docTemplate = `{ "address": { "type": "string" }, - "createdById": { - "type": "integer" - }, "dateOfBirth": { "type": "string" }, @@ -5546,24 +5473,12 @@ const docTemplate = `{ "identityType": { "type": "string" }, - "isActive": { - "type": "boolean" - }, - "keycloakId": { - "type": "string" - }, "lastEducation": { "type": "string" }, "phoneNumber": { "type": "string" }, - "profilePicturePath": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, "userLevelsId": { "type": "integer" }, @@ -5623,9 +5538,6 @@ const docTemplate = `{ "phoneNumber": { "type": "string" }, - "profile_picture_path": { - "type": "string" - }, "status_id": { "type": "integer" }, @@ -5643,11 +5555,46 @@ const docTemplate = `{ } } }, + "response.BadRequestError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 400 + }, + "message": { + "type": "string", + "example": "bad request" + }, + "success": { + "type": "boolean", + "example": false + } + } + }, + "response.InternalServerError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 500 + }, + "message": { + "type": "string", + "example": "internal server error" + }, + "success": { + "type": "boolean", + "example": false + } + } + }, "response.Response": { "type": "object", "properties": { "code": { - "type": "integer" + "type": "integer", + "example": 200 }, "data": {}, "messages": { @@ -5656,7 +5603,25 @@ const docTemplate = `{ }, "meta": {}, "success": { - "type": "boolean" + "type": "boolean", + "example": true + } + } + }, + "response.UnauthorizedError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 401 + }, + "message": { + "type": "string", + "example": "unauthorized access" + }, + "success": { + "type": "boolean", + "example": false } } } diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 6799ab7..a54b012 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -13,9 +13,46 @@ ], "description": "API for getting all ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "Get all ArticleCategories", + "parameters": [ + { + "type": "integer", + "name": "createdById", + "in": "query" + }, + { + "type": "string", + "name": "description", + "in": "query" + }, + { + "type": "boolean", + "name": "isEnabled", + "in": "query" + }, + { + "type": "boolean", + "name": "isPublish", + "in": "query" + }, + { + "type": "integer", + "name": "parentId", + "in": "query" + }, + { + "type": "integer", + "name": "statusId", + "in": "query" + }, + { + "type": "string", + "name": "title", + "in": "query" + } + ], "responses": { "200": { "description": "OK", @@ -23,28 +60,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -57,7 +88,7 @@ ], "description": "API for create ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "Create ArticleCategories", "parameters": [ @@ -78,28 +109,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -114,7 +139,7 @@ ], "description": "API for getting one ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "Get one ArticleCategories", "parameters": [ @@ -133,28 +158,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -167,7 +186,7 @@ ], "description": "API for update ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "update ArticleCategories", "parameters": [ @@ -177,7 +196,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.ArticleCategoriesCreateRequest" + "$ref": "#/definitions/request.ArticleCategoriesUpdateRequest" } }, { @@ -195,28 +214,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -229,7 +242,7 @@ ], "description": "API for delete ArticleCategories", "tags": [ - "Task" + "ArticleCategories" ], "summary": "delete ArticleCategories", "parameters": [ @@ -248,28 +261,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -535,7 +542,7 @@ ], "description": "API for getting all ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "Get all ArticleFiles", "responses": { @@ -545,28 +552,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -581,7 +582,7 @@ ], "description": "API for create ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "Create ArticleFiles", "parameters": [ @@ -600,28 +601,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -639,7 +634,7 @@ "application/json" ], "tags": [ - "Task" + "ArticleFiles" ], "summary": "Upload ArticleFiles", "parameters": [ @@ -665,28 +660,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -701,7 +690,7 @@ ], "description": "API for getting one ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "Get one ArticleFiles", "parameters": [ @@ -720,28 +709,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -754,7 +737,7 @@ ], "description": "API for update ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "update ArticleFiles", "parameters": [ @@ -782,28 +765,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -816,7 +793,7 @@ ], "description": "API for delete ArticleFiles", "tags": [ - "Task" + "ArticleFiles" ], "summary": "delete ArticleFiles", "parameters": [ @@ -835,28 +812,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -875,6 +846,11 @@ ], "summary": "Get all Articles", "parameters": [ + { + "type": "integer", + "name": "createdById", + "in": "query" + }, { "type": "string", "name": "description", @@ -913,28 +889,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -968,28 +938,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -1023,28 +987,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -1085,28 +1043,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -1138,28 +1090,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -3993,28 +3939,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4048,28 +3988,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4103,28 +4037,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4165,28 +4093,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4254,9 +4176,29 @@ ], "description": "API for getting all UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "Get all UserRoleAccesses", + "parameters": [ + { + "type": "boolean", + "name": "isActive", + "in": "query", + "required": true + }, + { + "type": "integer", + "name": "menuId", + "in": "query", + "required": true + }, + { + "type": "integer", + "name": "userRoleId", + "in": "query", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -4264,28 +4206,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4298,9 +4234,20 @@ ], "description": "API for create UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "Create UserRoleAccesses", + "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UserRoleAccessesCreateRequest" + } + } + ], "responses": { "200": { "description": "OK", @@ -4308,28 +4255,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4344,7 +4285,7 @@ ], "description": "API for getting one UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "Get one UserRoleAccesses", "parameters": [ @@ -4363,28 +4304,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4397,10 +4332,19 @@ ], "description": "API for update UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "update UserRoleAccesses", "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UserRoleAccessesUpdateRequest" + } + }, { "type": "integer", "description": "UserRoleAccesses ID", @@ -4416,28 +4360,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4450,7 +4388,7 @@ ], "description": "API for delete UserRoleAccesses", "tags": [ - "Task" + "UserRoleAccesses" ], "summary": "delete UserRoleAccesses", "parameters": [ @@ -4469,28 +4407,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4542,28 +4474,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4597,28 +4523,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4652,28 +4572,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4714,28 +4628,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4767,28 +4675,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4850,28 +4752,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4905,28 +4801,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -4960,28 +4850,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -5022,28 +4906,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -5075,28 +4953,22 @@ "$ref": "#/definitions/response.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, "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" + "$ref": "#/definitions/response.UnauthorizedError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.Response" + "$ref": "#/definitions/response.InternalServerError" } } } @@ -5130,47 +5002,66 @@ "request.ArticleCategoriesCreateRequest": { "type": "object", "required": [ - "created_by_id", "description", - "is_active", - "is_enabled", - "is_publish", - "parent_id", - "published_at", - "status_id", - "thumbnail_path", - "thumbnail_url", + "isEnabled", + "parentId", + "statusId", "title" ], "properties": { - "created_by_id": { - "type": "integer" - }, "description": { "type": "string" }, - "is_active": { + "isEnabled": { "type": "boolean" }, - "is_enabled": { - "type": "boolean" - }, - "is_publish": { - "type": "boolean" - }, - "parent_id": { + "parentId": { "type": "integer" }, - "published_at": { - "type": "string" - }, - "status_id": { + "statusId": { "type": "integer" }, - "thumbnail_path": { + "title": { + "type": "string" + } + } + }, + "request.ArticleCategoriesUpdateRequest": { + "type": "object", + "required": [ + "description", + "id", + "parentId", + "thumbnailPath", + "thumbnailUrl", + "title" + ], + "properties": { + "description": { "type": "string" }, - "thumbnail_url": { + "id": { + "type": "integer" + }, + "isEnabled": { + "type": "boolean" + }, + "isPublish": { + "type": "boolean" + }, + "parentId": { + "type": "integer" + }, + "publishedAt": { + "type": "string" + }, + "statusId": { + "type": "integer" + }, + "thumbnailPath": { + "type": "string" + }, + "thumbnailUrl": { "type": "string" }, "title": { @@ -5181,76 +5072,66 @@ "request.ArticleFilesUpdateRequest": { "type": "object", "required": [ - "article_id", - "created_by_id", - "download_count", - "file_alt", - "file_name", - "file_path", - "file_thumbnail", - "file_url", - "height_pixel", + "articleId", + "createdById", + "downloadCount", + "fileAlt", + "fileName", + "filePath", + "fileThumbnail", + "fileUrl", + "heightPixel", "id", - "is_active", - "is_publish", - "published_at", + "isPublish", + "publishedAt", "size", - "status_id", - "width_pixel" + "statusId", + "widthPixel" ], "properties": { - "article_id": { + "articleId": { "type": "integer" }, - "created_at": { - "type": "string" - }, - "created_by_id": { + "createdById": { "type": "integer" }, - "download_count": { + "downloadCount": { "type": "integer" }, - "file_alt": { + "fileAlt": { "type": "string" }, - "file_name": { + "fileName": { "type": "string" }, - "file_path": { + "filePath": { "type": "string" }, - "file_thumbnail": { + "fileThumbnail": { "type": "string" }, - "file_url": { + "fileUrl": { "type": "string" }, - "height_pixel": { + "heightPixel": { "type": "string" }, "id": { "type": "integer" }, - "is_active": { + "isPublish": { "type": "boolean" }, - "is_publish": { - "type": "boolean" - }, - "published_at": { + "publishedAt": { "type": "string" }, "size": { "type": "string" }, - "status_id": { + "statusId": { "type": "integer" }, - "updated_at": { - "type": "string" - }, - "width_pixel": { + "widthPixel": { "type": "string" } } @@ -5266,42 +5147,18 @@ "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" }, @@ -5391,7 +5248,7 @@ "aliasName": { "type": "string" }, - "is_active": { + "isActive": { "type": "boolean" }, "levelNumber": { @@ -5435,6 +5292,88 @@ } } }, + "request.UserRoleAccessesCreateRequest": { + "type": "object", + "required": [ + "isAdminEnabled", + "isApprovalEnabled", + "isDeleteEnabled", + "isInsertEnabled", + "isUpdateEnabled", + "isViewEnabled", + "menuId", + "userRoleId" + ], + "properties": { + "isAdminEnabled": { + "type": "boolean" + }, + "isApprovalEnabled": { + "type": "boolean" + }, + "isDeleteEnabled": { + "type": "boolean" + }, + "isInsertEnabled": { + "type": "boolean" + }, + "isUpdateEnabled": { + "type": "boolean" + }, + "isViewEnabled": { + "type": "boolean" + }, + "menuId": { + "type": "integer" + }, + "userRoleId": { + "type": "integer" + } + } + }, + "request.UserRoleAccessesUpdateRequest": { + "type": "object", + "required": [ + "id", + "is_admin_enabled", + "is_approval_enabled", + "is_delete_enabled", + "is_insert_enabled", + "is_update_enabled", + "is_view_enabled", + "menu_id", + "user_role_id" + ], + "properties": { + "id": { + "type": "integer" + }, + "is_admin_enabled": { + "type": "boolean" + }, + "is_approval_enabled": { + "type": "boolean" + }, + "is_delete_enabled": { + "type": "boolean" + }, + "is_insert_enabled": { + "type": "boolean" + }, + "is_update_enabled": { + "type": "boolean" + }, + "is_view_enabled": { + "type": "boolean" + }, + "menu_id": { + "type": "integer" + }, + "user_role_id": { + "type": "integer" + } + } + }, "request.UserRolesCreateRequest": { "type": "object", "required": [ @@ -5447,23 +5386,14 @@ "code": { "type": "string" }, - "created_by_id": { - "type": "integer" - }, "description": { "type": "string" }, - "is_active": { - "type": "boolean" - }, "level_number": { "type": "integer" }, "name": { "type": "string" - }, - "status_id": { - "type": "integer" } } }, @@ -5514,9 +5444,6 @@ "address": { "type": "string" }, - "createdById": { - "type": "integer" - }, "dateOfBirth": { "type": "string" }, @@ -5535,24 +5462,12 @@ "identityType": { "type": "string" }, - "isActive": { - "type": "boolean" - }, - "keycloakId": { - "type": "string" - }, "lastEducation": { "type": "string" }, "phoneNumber": { "type": "string" }, - "profilePicturePath": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, "userLevelsId": { "type": "integer" }, @@ -5612,9 +5527,6 @@ "phoneNumber": { "type": "string" }, - "profile_picture_path": { - "type": "string" - }, "status_id": { "type": "integer" }, @@ -5632,11 +5544,46 @@ } } }, + "response.BadRequestError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 400 + }, + "message": { + "type": "string", + "example": "bad request" + }, + "success": { + "type": "boolean", + "example": false + } + } + }, + "response.InternalServerError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 500 + }, + "message": { + "type": "string", + "example": "internal server error" + }, + "success": { + "type": "boolean", + "example": false + } + } + }, "response.Response": { "type": "object", "properties": { "code": { - "type": "integer" + "type": "integer", + "example": 200 }, "data": {}, "messages": { @@ -5645,7 +5592,25 @@ }, "meta": {}, "success": { - "type": "boolean" + "type": "boolean", + "example": true + } + } + }, + "response.UnauthorizedError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 401 + }, + "message": { + "type": "string", + "example": "unauthorized access" + }, + "success": { + "type": "boolean", + "example": false } } } diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 4aa9270..0687485 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -16,123 +16,112 @@ definitions: type: object request.ArticleCategoriesCreateRequest: properties: - created_by_id: - type: integer description: type: string - is_active: + isEnabled: type: boolean - is_enabled: - type: boolean - is_publish: - type: boolean - parent_id: + parentId: type: integer - published_at: - type: string - status_id: + statusId: type: integer - thumbnail_path: + title: type: string - thumbnail_url: + required: + - description + - isEnabled + - parentId + - statusId + - title + type: object + request.ArticleCategoriesUpdateRequest: + properties: + description: + type: string + id: + type: integer + isEnabled: + type: boolean + isPublish: + type: boolean + parentId: + type: integer + publishedAt: + type: string + statusId: + type: integer + thumbnailPath: + type: string + thumbnailUrl: type: string title: type: string required: - - created_by_id - description - - is_active - - is_enabled - - is_publish - - parent_id - - published_at - - status_id - - thumbnail_path - - thumbnail_url + - id + - parentId + - thumbnailPath + - thumbnailUrl - title type: object request.ArticleFilesUpdateRequest: properties: - article_id: + articleId: type: integer - created_at: - type: string - created_by_id: + createdById: type: integer - download_count: + downloadCount: type: integer - file_alt: + fileAlt: type: string - file_name: + fileName: type: string - file_path: + filePath: type: string - file_thumbnail: + fileThumbnail: type: string - file_url: + fileUrl: type: string - height_pixel: + heightPixel: type: string id: type: integer - is_active: + isPublish: type: boolean - is_publish: - type: boolean - published_at: + publishedAt: type: string size: type: string - status_id: + statusId: type: integer - updated_at: - type: string - width_pixel: + widthPixel: type: string required: - - article_id - - created_by_id - - download_count - - file_alt - - file_name - - file_path - - file_thumbnail - - file_url - - height_pixel + - articleId + - createdById + - downloadCount + - fileAlt + - fileName + - filePath + - fileThumbnail + - fileUrl + - heightPixel - id - - is_active - - is_publish - - published_at + - isPublish + - publishedAt - size - - status_id - - width_pixel + - statusId + - widthPixel 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: @@ -196,7 +185,7 @@ definitions: properties: aliasName: type: string - is_active: + isActive: type: boolean levelNumber: type: integer @@ -232,22 +221,75 @@ definitions: - parentLevelId - provinceId type: object + request.UserRoleAccessesCreateRequest: + properties: + isAdminEnabled: + type: boolean + isApprovalEnabled: + type: boolean + isDeleteEnabled: + type: boolean + isInsertEnabled: + type: boolean + isUpdateEnabled: + type: boolean + isViewEnabled: + type: boolean + menuId: + type: integer + userRoleId: + type: integer + required: + - isAdminEnabled + - isApprovalEnabled + - isDeleteEnabled + - isInsertEnabled + - isUpdateEnabled + - isViewEnabled + - menuId + - userRoleId + type: object + request.UserRoleAccessesUpdateRequest: + properties: + id: + type: integer + is_admin_enabled: + type: boolean + is_approval_enabled: + type: boolean + is_delete_enabled: + type: boolean + is_insert_enabled: + type: boolean + is_update_enabled: + type: boolean + is_view_enabled: + type: boolean + menu_id: + type: integer + user_role_id: + type: integer + required: + - id + - is_admin_enabled + - is_approval_enabled + - is_delete_enabled + - is_insert_enabled + - is_update_enabled + - is_view_enabled + - menu_id + - user_role_id + type: object request.UserRolesCreateRequest: properties: code: type: string - created_by_id: - type: integer description: type: string - is_active: - type: boolean level_number: type: integer name: type: string - status_id: - type: integer required: - code - description @@ -276,8 +318,6 @@ definitions: properties: address: type: string - createdById: - type: integer dateOfBirth: type: string email: @@ -290,18 +330,10 @@ definitions: type: string identityType: type: string - isActive: - type: boolean - keycloakId: - type: string lastEducation: type: string phoneNumber: type: string - profilePicturePath: - type: string - statusId: - type: integer userLevelsId: type: integer userRoleId: @@ -345,8 +377,6 @@ definitions: type: string phoneNumber: type: string - profile_picture_path: - type: string status_id: type: integer userLevelsId: @@ -372,9 +402,34 @@ definitions: - username - workType type: object + response.BadRequestError: + properties: + code: + example: 400 + type: integer + message: + example: bad request + type: string + success: + example: false + type: boolean + type: object + response.InternalServerError: + properties: + code: + example: 500 + type: integer + message: + example: internal server error + type: string + success: + example: false + type: boolean + type: object response.Response: properties: code: + example: 200 type: integer data: {} messages: @@ -382,6 +437,19 @@ definitions: type: array meta: {} success: + example: true + type: boolean + type: object + response.UnauthorizedError: + properties: + code: + example: 401 + type: integer + message: + example: unauthorized access + type: string + success: + example: false type: boolean type: object info: @@ -390,32 +458,50 @@ paths: /article-categories: get: description: API for getting all ArticleCategories + parameters: + - in: query + name: createdById + type: integer + - in: query + name: description + type: string + - in: query + name: isEnabled + type: boolean + - in: query + name: isPublish + type: boolean + - in: query + name: parentId + type: integer + - in: query + name: statusId + type: integer + - in: query + name: title + 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.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all ArticleCategories tags: - - Task + - ArticleCategories post: description: API for create ArticleCategories parameters: @@ -430,27 +516,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create ArticleCategories tags: - - Task + - ArticleCategories /article-categories/{id}: delete: description: API for delete ArticleCategories @@ -465,27 +547,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: delete ArticleCategories tags: - - Task + - ArticleCategories get: description: API for getting one ArticleCategories parameters: @@ -499,27 +577,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one ArticleCategories tags: - - Task + - ArticleCategories put: description: API for update ArticleCategories parameters: @@ -528,7 +602,7 @@ paths: name: payload required: true schema: - $ref: '#/definitions/request.ArticleCategoriesCreateRequest' + $ref: '#/definitions/request.ArticleCategoriesUpdateRequest' - description: ArticleCategories ID in: path name: id @@ -539,27 +613,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update ArticleCategories tags: - - Task + - ArticleCategories /article-category-details: get: description: API for getting all ArticleCategoryDetails @@ -728,27 +798,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all ArticleFiles tags: - - Task + - ArticleFiles /article-files/{articleId}: post: description: API for create ArticleFiles @@ -770,27 +836,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Upload ArticleFiles tags: - - Task + - ArticleFiles /article-files/{id}: delete: description: API for delete ArticleFiles @@ -805,27 +867,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: delete ArticleFiles tags: - - Task + - ArticleFiles get: description: API for getting one ArticleFiles parameters: @@ -839,27 +897,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one ArticleFiles tags: - - Task + - ArticleFiles put: description: API for update ArticleFiles parameters: @@ -879,27 +933,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update ArticleFiles tags: - - Task + - ArticleFiles /article-files/viewer/{id}: get: description: API for create ArticleFiles @@ -914,31 +964,30 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create ArticleFiles tags: - - Task + - ArticleFiles /articles: get: description: API for getting all Articles parameters: + - in: query + name: createdById + type: integer - in: query name: description type: string @@ -962,22 +1011,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all Articles @@ -997,22 +1042,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create Articles @@ -1032,22 +1073,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: delete Articles @@ -1066,22 +1103,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one Articles @@ -1106,22 +1139,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update Articles @@ -2925,22 +2954,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all UserLevels @@ -2960,22 +2985,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create UserLevels @@ -3029,22 +3050,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one UserLevels @@ -3069,22 +3086,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update UserLevels @@ -3093,60 +3106,72 @@ paths: /user-role-accesses: get: description: API for getting all UserRoleAccesses + parameters: + - in: query + name: isActive + required: true + type: boolean + - in: query + name: menuId + required: true + type: integer + - in: query + name: userRoleId + required: true + type: integer 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.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all UserRoleAccesses tags: - - Task + - UserRoleAccesses post: description: API for create UserRoleAccesses + parameters: + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.UserRoleAccessesCreateRequest' 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.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create UserRoleAccesses tags: - - Task + - UserRoleAccesses /user-role-accesses/{id}: delete: description: API for delete UserRoleAccesses @@ -3161,27 +3186,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: delete UserRoleAccesses tags: - - Task + - UserRoleAccesses get: description: API for getting one UserRoleAccesses parameters: @@ -3195,30 +3216,32 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one UserRoleAccesses tags: - - Task + - UserRoleAccesses put: description: API for update UserRoleAccesses parameters: + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.UserRoleAccessesUpdateRequest' - description: UserRoleAccesses ID in: path name: id @@ -3229,27 +3252,23 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update UserRoleAccesses tags: - - Task + - UserRoleAccesses /user-roles: get: description: API for getting all UserRoles @@ -3274,22 +3293,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all UserRoles @@ -3309,22 +3324,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create UserRoles @@ -3344,22 +3355,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: delete UserRoles @@ -3378,22 +3385,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one UserRoles @@ -3418,22 +3421,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update UserRoles @@ -3469,22 +3468,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get all Users @@ -3504,22 +3499,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Create Users @@ -3539,22 +3530,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: delete Users @@ -3573,22 +3560,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: Get one Users @@ -3613,22 +3596,18 @@ paths: description: OK schema: $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' "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' + $ref: '#/definitions/response.UnauthorizedError' "500": description: Internal Server Error schema: - $ref: '#/definitions/response.Response' + $ref: '#/definitions/response.InternalServerError' security: - Bearer: [] summary: update Users diff --git a/utils/response/error.response.go b/utils/response/error.response.go new file mode 100644 index 0000000..7c831bb --- /dev/null +++ b/utils/response/error.response.go @@ -0,0 +1,19 @@ +package response + +type BadRequestError struct { + Success bool `json:"success" example:"false"` + Code int `json:"code" example:"400"` + Message string `json:"message" example:"bad request"` +} + +type UnauthorizedError struct { + Success bool `json:"success" example:"false"` + Code int `json:"code" example:"401"` + Message string `json:"message" example:"unauthorized access"` +} + +type InternalServerError struct { + Success bool `json:"success" example:"false"` + Code int `json:"code" example:"500"` + Message string `json:"message" example:"internal server error"` +} diff --git a/utils/response/index.response.go b/utils/response/index.response.go index 7455403..82e9e91 100644 --- a/utils/response/index.response.go +++ b/utils/response/index.response.go @@ -25,8 +25,8 @@ func (e *Error) Error() string { // A struct to return normal response type Response struct { - Success bool `json:"success"` - Code int `json:"code"` + Success bool `json:"success" example:"true"` + Code int `json:"code" example:"200"` Messages Messages `json:"messages"` Data any `json:"data,omitempty"` Meta any `json:"meta,omitempty"` @@ -89,3 +89,14 @@ func removeTopStruct(fields map[string]string) map[string]string { return res } + +func Unauthorized() *Response { + return &Response{ + Success: false, + Code: 401, + Data: nil, + Messages: Messages{ + "Unauthorized", + }, + } +}