feat: update master menu and master module

This commit is contained in:
hanif salafi 2024-04-30 01:09:11 +07:00
parent e031997fcd
commit 7436273b64
19 changed files with 1191 additions and 589 deletions

View File

@ -9,9 +9,9 @@ type MasterMenus struct {
ModuleId int `json:"module_id" gorm:"type:int4"`
ParentMenuId int `json:"parent_menu_id" gorm:"type:int4"`
Icon string `json:"icon" gorm:"type:varchar"`
Position int `json:"position" gorm:"type:int4"`
Position *int `json:"position" gorm:"type:int4"`
StatusId int `json:"status_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()"`
}

View File

@ -8,7 +8,7 @@ type MasterModules struct {
Description string `json:"description" gorm:"type:varchar"`
PathUrl string `json:"path_url" gorm:"type:varchar"`
StatusId int `json:"status_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()"`
}

View File

@ -32,7 +32,7 @@ func NewArticleCategoryDetailsController(articleCategoryDetailsService service.A
// All get all ArticleCategoryDetails
// @Summary Get all ArticleCategoryDetails
// @Description API for getting all ArticleCategoryDetails
// @Tags Task
// @Tags Untags
// @Security Bearer
// @Success 200 {object} response.Response
// @Failure 401 {object} response.Response
@ -64,7 +64,7 @@ func (_i *articleCategoryDetailsController) All(c *fiber.Ctx) error {
// Show get one ArticleCategoryDetails
// @Summary Get one ArticleCategoryDetails
// @Description API for getting one ArticleCategoryDetails
// @Tags Task
// @Tags Untags
// @Security Bearer
// @Param id path int true "ArticleCategoryDetails ID"
// @Success 200 {object} response.Response
@ -93,7 +93,7 @@ func (_i *articleCategoryDetailsController) Show(c *fiber.Ctx) error {
// Save create ArticleCategoryDetails
// @Summary Create ArticleCategoryDetails
// @Description API for create ArticleCategoryDetails
// @Tags Task
// @Tags Untags
// @Security Bearer
// @Body request.ArticleCategoryDetailsCreateRequest
// @Success 200 {object} response.Response
@ -121,7 +121,7 @@ func (_i *articleCategoryDetailsController) Save(c *fiber.Ctx) error {
// Update update ArticleCategoryDetails
// @Summary update ArticleCategoryDetails
// @Description API for update ArticleCategoryDetails
// @Tags Task
// @Tags Untags
// @Security Bearer
// @Body request.ArticleCategoryDetailsUpdateRequest
// @Param id path int true "ArticleCategoryDetails ID"
@ -155,7 +155,7 @@ func (_i *articleCategoryDetailsController) Update(c *fiber.Ctx) error {
// Delete delete ArticleCategoryDetails
// @Summary delete ArticleCategoryDetails
// @Description API for delete ArticleCategoryDetails
// @Tags Task
// @Tags Untags
// @Security Bearer
// @Param id path int true "ArticleCategoryDetails ID"
// @Success 200 {object} response.Response

View File

@ -29,16 +29,17 @@ func NewMasterMenusController(masterMenusService service.MasterMenusService) Mas
}
}
// All get all MasterMenus
// All MasterMenus
// @Summary Get all MasterMenus
// @Description API for getting all MasterMenus
// @Tags Task
// @Tags MasterMenus
// @Security Bearer
// @Param req query request.MasterMenusQueryRequest false "query parameters"
// @Param req query paginator.Pagination false "pagination 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 /master-menus [get]
func (_i *masterMenusController) All(c *fiber.Ctx) error {
paginate, err := paginator.Paginate(c)
@ -46,7 +47,14 @@ func (_i *masterMenusController) All(c *fiber.Ctx) error {
return err
}
var req request.MasterMenusQueryRequest
reqContext := request.MasterMenusQueryRequestContext{
Name: c.Query("name"),
Description: c.Query("description"),
ParentMenuId: c.Query("parentMenuId"),
ModuleId: c.Query("moduleId"),
StatusId: c.Query("statusId"),
}
req := reqContext.ToParamRequest()
req.Pagination = paginate
masterMenusData, paging, err := _i.masterMenusService.All(req)
@ -55,6 +63,7 @@ func (_i *masterMenusController) All(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterMenus list successfully retrieved"},
Data: masterMenusData,
Meta: paging,
@ -64,14 +73,13 @@ func (_i *masterMenusController) All(c *fiber.Ctx) error {
// Show get one MasterMenus
// @Summary Get one MasterMenus
// @Description API for getting one MasterMenus
// @Tags Task
// @Tags MasterMenus
// @Security Bearer
// @Param id path int true "MasterMenus 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 /master-menus/{id} [get]
func (_i *masterMenusController) Show(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
@ -85,6 +93,7 @@ func (_i *masterMenusController) Show(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterMenus successfully retrieved"},
Data: masterMenusData,
})
@ -93,14 +102,13 @@ func (_i *masterMenusController) Show(c *fiber.Ctx) error {
// Save create MasterMenus
// @Summary Create MasterMenus
// @Description API for create MasterMenus
// @Tags Task
// @Tags MasterMenus
// @Security Bearer
// @Body request.MasterMenusCreateRequest
// @Param payload body request.MasterMenusCreateRequest 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 /master-menus [post]
func (_i *masterMenusController) Save(c *fiber.Ctx) error {
req := new(request.MasterMenusCreateRequest)
@ -114,14 +122,15 @@ func (_i *masterMenusController) Save(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterMenus successfully created"},
})
}
// Update update MasterMenus
// @Summary update MasterMenus
// Update MasterMenus
// @Summary Update MasterMenus
// @Description API for update MasterMenus
// @Tags Task
// @Tags MasterMenus
// @Security Bearer
// @Body request.MasterMenusUpdateRequest
// @Param id path int true "MasterMenus ID"
@ -148,21 +157,21 @@ func (_i *masterMenusController) Update(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterMenus successfully updated"},
})
}
// Delete delete MasterMenus
// @Summary delete MasterMenus
// Delete MasterMenus
// @Summary Delete MasterMenus
// @Description API for delete MasterMenus
// @Tags Task
// @Tags MasterMenus
// @Security Bearer
// @Param id path int true "MasterMenus 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 /master-menus/{id} [delete]
func (_i *masterMenusController) Delete(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
@ -176,6 +185,7 @@ func (_i *masterMenusController) Delete(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterMenus successfully deleted"},
})
}

View File

@ -8,18 +8,18 @@ import (
func MasterMenusResponseMapper(masterMenusReq *entity.MasterMenus) (masterMenusRes *res.MasterMenusResponse) {
if masterMenusReq != nil {
masterMenusRes = &res.MasterMenusResponse{
ID: masterMenusReq.ID,
Name: masterMenusReq.Name,
Description: masterMenusReq.Description,
ModuleId: masterMenusReq.ModuleId,
ParentMenuId: masterMenusReq.ParentMenuId,
Icon: masterMenusReq.Icon,
Position: masterMenusReq.Position,
StatusId: masterMenusReq.StatusId,
IsActive: masterMenusReq.IsActive,
ID: masterMenusReq.ID,
Name: masterMenusReq.Name,
Description: masterMenusReq.Description,
ModuleId: masterMenusReq.ModuleId,
ParentMenuId: masterMenusReq.ParentMenuId,
Icon: masterMenusReq.Icon,
Position: masterMenusReq.Position,
StatusId: masterMenusReq.StatusId,
IsActive: masterMenusReq.IsActive,
CreatedAt: masterMenusReq.CreatedAt,
UpdatedAt: masterMenusReq.UpdatedAt,
}
}
return masterMenusRes
}
}

View File

@ -1,10 +1,12 @@
package repository
import (
"fmt"
"go-humas-be/app/database"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/master_menus/request"
"go-humas-be/utils/paginator"
"strings"
)
type masterMenusRepository struct {
@ -31,8 +33,35 @@ func (_i *masterMenusRepository) GetAll(req request.MasterMenusQueryRequest) (ma
var count int64
query := _i.DB.DB.Model(&entity.MasterMenus{})
query = query.Where("is_active = ?", true)
if req.Name != nil && *req.Name != "" {
name := strings.ToLower(*req.Name)
query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(name)+"%")
}
if req.Description != nil && *req.Description != "" {
description := strings.ToLower(*req.Description)
query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%")
}
if req.ModuleId != nil {
query = query.Where("module_id = ?", req.ModuleId)
}
if req.ParentMenuId != nil {
query = query.Where("parent_menu_id = ?", req.ParentMenuId)
}
if req.StatusId != nil {
query = query.Where("status_id = ?", req.StatusId)
}
query.Count(&count)
if req.Pagination.SortBy != "" {
direction := "ASC"
if req.Pagination.Sort == "desc" {
direction = "DESC"
}
query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction))
}
req.Pagination.Count = count
req.Pagination = paginator.Paging(req.Pagination)
@ -66,4 +95,4 @@ func (_i *masterMenusRepository) Update(id uint, masterMenus *entity.MasterMenus
func (_i *masterMenusRepository) Delete(id uint) error {
return _i.DB.DB.Delete(&entity.MasterMenus{}, id).Error
}
}

View File

@ -3,6 +3,7 @@ package request
import (
"go-humas-be/app/database/entity"
"go-humas-be/utils/paginator"
"strconv"
"time"
)
@ -11,68 +12,97 @@ type MasterMenusGeneric interface {
}
type MasterMenusQueryRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
ModuleId int `json:"module_id" validate:"required"`
ParentMenuId int `json:"parent_menu_id" validate:"required"`
Icon string `json:"icon" validate:"required"`
Position int `json:"position" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
IsActive bool `json:"is_active" validate:"required"`
Pagination *paginator.Pagination `json:"pagination"`
Name *string `json:"name"`
Description *string `json:"description"`
ModuleId *int `json:"moduleId"`
ParentMenuId *int `json:"parentMenuId"`
StatusId *int `json:"statusId"`
Pagination *paginator.Pagination `json:"pagination"`
}
type MasterMenusCreateRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
ModuleId int `json:"module_id" validate:"required"`
ParentMenuId int `json:"parent_menu_id" validate:"required"`
Icon string `json:"icon" validate:"required"`
Position int `json:"position" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
IsActive bool `json:"is_active" validate:"required"`
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
ModuleId int `json:"moduleId" validate:"required"`
ParentMenuId int `json:"parentMenuId" validate:"required"`
Icon string `json:"icon" validate:"required"`
StatusId int `json:"statusId" validate:"required"`
Position *int `json:"position"`
}
func (req MasterMenusCreateRequest) ToEntity() *entity.MasterMenus {
return &entity.MasterMenus{
Name: req.Name,
Description: req.Description,
ModuleId: req.ModuleId,
ParentMenuId: req.ParentMenuId,
Icon: req.Icon,
Position: req.Position,
StatusId: req.StatusId,
IsActive: req.IsActive,
Name: req.Name,
Description: req.Description,
ModuleId: req.ModuleId,
ParentMenuId: req.ParentMenuId,
Icon: req.Icon,
Position: req.Position,
StatusId: req.StatusId,
}
}
type MasterMenusUpdateRequest struct {
ID uint `json:"id" validate:"required"`
Name string `json:"name" validate:"required"`
ID uint `json:"id" validate:"required"`
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
ModuleId int `json:"module_id" validate:"required"`
ParentMenuId int `json:"parent_menu_id" validate:"required"`
Icon string `json:"icon" validate:"required"`
Position int `json:"position" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
IsActive bool `json:"is_active" validate:"required"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ModuleId int `json:"moduleId" validate:"required"`
ParentMenuId int `json:"parentMenuId" validate:"required"`
Icon string `json:"icon" validate:"required"`
StatusId int `json:"statusId" validate:"required"`
Position *int `json:"position"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (req MasterMenusUpdateRequest) ToEntity() *entity.MasterMenus {
return &entity.MasterMenus{
ID: req.ID,
Name: req.Name,
Description: req.Description,
ModuleId: req.ModuleId,
ParentMenuId: req.ParentMenuId,
Icon: req.Icon,
Position: req.Position,
StatusId: req.StatusId,
IsActive: req.IsActive,
CreatedAt: req.CreatedAt,
UpdatedAt: req.UpdatedAt,
ID: req.ID,
Name: req.Name,
Description: req.Description,
ModuleId: req.ModuleId,
ParentMenuId: req.ParentMenuId,
Icon: req.Icon,
Position: req.Position,
StatusId: req.StatusId,
UpdatedAt: time.Now(),
}
}
}
type MasterMenusQueryRequestContext struct {
Name string `json:"name"`
Description string `json:"description"`
ModuleId string `json:"moduleId"`
ParentMenuId string `json:"parentMenuId"`
StatusId string `json:"statusId"`
}
func (req MasterMenusQueryRequestContext) ToParamRequest() MasterMenusQueryRequest {
var request MasterMenusQueryRequest
if name := req.Name; name != "" {
request.Name = &name
}
if description := req.Description; description != "" {
request.Description = &description
}
if moduleIdStr := req.ModuleId; moduleIdStr != "" {
moduleId, err := strconv.Atoi(moduleIdStr)
if err == nil {
request.ModuleId = &moduleId
}
}
if parentMenuIdStr := req.ParentMenuId; parentMenuIdStr != "" {
parentMenuId, err := strconv.Atoi(parentMenuIdStr)
if err == nil {
request.ParentMenuId = &parentMenuId
}
}
if statusIdStr := req.StatusId; statusIdStr != "" {
statusId, err := strconv.Atoi(statusIdStr)
if err == nil {
request.StatusId = &statusId
}
}
return request
}

View File

@ -3,15 +3,15 @@ package response
import "time"
type MasterMenusResponse struct {
ID uint `json:"id"`
Name string `json:"name"`
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ModuleId int `json:"module_id"`
ParentMenuId int `json:"parent_menu_id"`
Icon string `json:"icon"`
Position int `json:"position"`
StatusId int `json:"status_id"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ModuleId int `json:"module_id"`
ParentMenuId int `json:"parent_menu_id"`
Icon string `json:"icon"`
Position *int `json:"position"`
StatusId int `json:"status_id"`
IsActive *bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@ -68,5 +68,12 @@ func (_i *masterMenusService) Update(id uint, req request.MasterMenusUpdateReque
}
func (_i *masterMenusService) 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)
}

View File

@ -29,16 +29,17 @@ func NewMasterModulesController(masterModulesService service.MasterModulesServic
}
}
// All get all MasterModules
// All MasterModules
// @Summary Get all MasterModules
// @Description API for getting all MasterModules
// @Tags Task
// @Tags MasterModules
// @Security Bearer
// @Param req query request.MasterModulesQueryRequest false "query parameters"
// @Param req query paginator.Pagination false "pagination 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 /master-modules [get]
func (_i *masterModulesController) All(c *fiber.Ctx) error {
paginate, err := paginator.Paginate(c)
@ -46,7 +47,12 @@ func (_i *masterModulesController) All(c *fiber.Ctx) error {
return err
}
var req request.MasterModulesQueryRequest
reqContext := request.MasterModulesQueryRequestContext{
Name: c.Query("name"),
Description: c.Query("description"),
StatusId: c.Query("statusId"),
}
req := reqContext.ToParamRequest()
req.Pagination = paginate
masterModulesData, paging, err := _i.masterModulesService.All(req)
@ -55,23 +61,23 @@ func (_i *masterModulesController) All(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterModules list successfully retrieved"},
Data: masterModulesData,
Meta: paging,
})
}
// Show get one MasterModules
// Show MasterModules
// @Summary Get one MasterModules
// @Description API for getting one MasterModules
// @Tags Task
// @Tags MasterModules
// @Security Bearer
// @Param id path int true "MasterModules 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 /master-modules/{id} [get]
func (_i *masterModulesController) Show(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
@ -85,22 +91,22 @@ func (_i *masterModulesController) Show(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterModules successfully retrieved"},
Data: masterModulesData,
})
}
// Save create MasterModules
// Save MasterModules
// @Summary Create MasterModules
// @Description API for create MasterModules
// @Tags Task
// @Tags MasterModules
// @Security Bearer
// @Body request.MasterModulesCreateRequest
// @Param payload body request.MasterModulesCreateRequest 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 /master-modules [post]
func (_i *masterModulesController) Save(c *fiber.Ctx) error {
req := new(request.MasterModulesCreateRequest)
@ -114,22 +120,22 @@ func (_i *masterModulesController) Save(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterModules successfully created"},
})
}
// Update update MasterModules
// @Summary update MasterModules
// Update MasterModules
// @Summary Update MasterModules
// @Description API for update MasterModules
// @Tags Task
// @Tags MasterModules
// @Security Bearer
// @Body request.MasterModulesUpdateRequest
// @Param id path int true "MasterModules ID"
// @Param payload body request.MasterModulesUpdateRequest 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 /master-modules/{id} [put]
func (_i *masterModulesController) Update(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
@ -148,21 +154,21 @@ func (_i *masterModulesController) Update(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterModules successfully updated"},
})
}
// Delete delete MasterModules
// @Summary delete MasterModules
// Delete MasterModules
// @Summary Delete MasterModules
// @Description API for delete MasterModules
// @Tags Task
// @Tags MasterModules
// @Security Bearer
// @Param id path int true "MasterModules 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 /master-modules/{id} [delete]
func (_i *masterModulesController) Delete(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
@ -176,6 +182,7 @@ func (_i *masterModulesController) Delete(c *fiber.Ctx) error {
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"MasterModules successfully deleted"},
})
}

View File

@ -1,14 +0,0 @@
package entity
import "time"
type MasterModules struct {
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
Name string `json:"name" gorm:"type:varchar"`
Description string `json:"description" gorm:"type:varchar"`
PathUrl string `json:"path_url" gorm:"type:varchar"`
StatusId int `json:"status_id" gorm:"type:int4"`
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()"`
}

View File

@ -8,15 +8,15 @@ import (
func MasterModulesResponseMapper(masterModulesReq *entity.MasterModules) (masterModulesRes *res.MasterModulesResponse) {
if masterModulesReq != nil {
masterModulesRes = &res.MasterModulesResponse{
ID: masterModulesReq.ID,
Name: masterModulesReq.Name,
Description: masterModulesReq.Description,
PathUrl: masterModulesReq.PathUrl,
ID: masterModulesReq.ID,
Name: masterModulesReq.Name,
Description: masterModulesReq.Description,
PathUrl: masterModulesReq.PathUrl,
StatusId: masterModulesReq.StatusId,
IsActive: masterModulesReq.IsActive,
CreatedAt: masterModulesReq.CreatedAt,
UpdatedAt: masterModulesReq.UpdatedAt,
CreatedAt: masterModulesReq.CreatedAt,
UpdatedAt: masterModulesReq.UpdatedAt,
}
}
return masterModulesRes
}
}

View File

@ -1,10 +1,12 @@
package repository
import (
"fmt"
"go-humas-be/app/database"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/master_modules/request"
"go-humas-be/utils/paginator"
"strings"
)
type masterModulesRepository struct {
@ -31,8 +33,29 @@ func (_i *masterModulesRepository) GetAll(req request.MasterModulesQueryRequest)
var count int64
query := _i.DB.DB.Model(&entity.MasterModules{})
query = query.Where("is_active = ?", true)
if req.Name != nil && *req.Name != "" {
name := strings.ToLower(*req.Name)
query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(name)+"%")
}
if req.Description != nil && *req.Description != "" {
description := strings.ToLower(*req.Description)
query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%")
}
if req.StatusId != nil {
query = query.Where("status_id = ?", req.StatusId)
}
query.Count(&count)
if req.Pagination.SortBy != "" {
direction := "ASC"
if req.Pagination.Sort == "desc" {
direction = "DESC"
}
query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction))
}
req.Pagination.Count = count
req.Pagination = paginator.Paging(req.Pagination)
@ -66,4 +89,4 @@ func (_i *masterModulesRepository) Update(id uint, masterModules *entity.MasterM
func (_i *masterModulesRepository) Delete(id uint) error {
return _i.DB.DB.Delete(&entity.MasterModules{}, id).Error
}
}

View File

@ -3,6 +3,7 @@ package request
import (
"go-humas-be/app/database/entity"
"go-humas-be/utils/paginator"
"strconv"
"time"
)
@ -11,53 +12,68 @@ type MasterModulesGeneric interface {
}
type MasterModulesQueryRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
PathUrl string `json:"path_url" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
IsActive bool `json:"is_active" validate:"required"`
Name *string `json:"name"`
Description *string `json:"description"`
StatusId *int `json:"statusId"`
Pagination *paginator.Pagination `json:"pagination"`
}
type MasterModulesCreateRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
PathUrl string `json:"path_url" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
IsActive bool `json:"is_active" validate:"required"`
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
PathUrl string `json:"pathUrl" validate:"required"`
StatusId int `json:"statusId" validate:"required"`
}
func (req MasterModulesCreateRequest) ToEntity() *entity.MasterModules {
return &entity.MasterModules{
Name: req.Name,
Description: req.Description,
PathUrl: req.PathUrl,
Name: req.Name,
Description: req.Description,
PathUrl: req.PathUrl,
StatusId: req.StatusId,
IsActive: req.IsActive,
}
}
type MasterModulesUpdateRequest struct {
ID uint `json:"id" validate:"required"`
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
PathUrl string `json:"path_url" validate:"required"`
StatusId int `json:"status_id" 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"`
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"`
PathUrl string `json:"pathUrl" validate:"required"`
StatusId int `json:"statusId" validate:"required"`
}
func (req MasterModulesUpdateRequest) ToEntity() *entity.MasterModules {
return &entity.MasterModules{
ID: req.ID,
Name: req.Name,
Description: req.Description,
PathUrl: req.PathUrl,
ID: req.ID,
Name: req.Name,
Description: req.Description,
PathUrl: req.PathUrl,
StatusId: req.StatusId,
IsActive: req.IsActive,
CreatedAt: req.CreatedAt,
UpdatedAt: req.UpdatedAt,
UpdatedAt: time.Now(),
}
}
}
type MasterModulesQueryRequestContext struct {
Name string `json:"name"`
Description string `json:"description"`
StatusId string `json:"statusId"`
}
func (req MasterModulesQueryRequestContext) ToParamRequest() MasterModulesQueryRequest {
var request MasterModulesQueryRequest
if name := req.Name; name != "" {
request.Name = &name
}
if description := req.Description; description != "" {
request.Description = &description
}
if statusIdStr := req.StatusId; statusIdStr != "" {
statusId, err := strconv.Atoi(statusIdStr)
if err == nil {
request.StatusId = &statusId
}
}
return request
}

View File

@ -3,12 +3,12 @@ package response
import "time"
type MasterModulesResponse struct {
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
PathUrl string `json:"path_url"`
StatusId int `json:"status_id"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
PathUrl string `json:"path_url"`
StatusId int `json:"status_id"`
IsActive *bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@ -68,5 +68,12 @@ func (_i *masterModulesService) Update(id uint, req request.MasterModulesUpdateR
}
func (_i *masterModulesService) 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)
}

View File

@ -2303,9 +2303,76 @@ const docTemplate = `{
],
"description": "API for getting all MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "Get all MasterMenus",
"parameters": [
{
"type": "string",
"name": "description",
"in": "query"
},
{
"type": "integer",
"name": "moduleId",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"name": "parentMenuId",
"in": "query"
},
{
"type": "integer",
"name": "statusId",
"in": "query"
},
{
"type": "integer",
"name": "count",
"in": "query"
},
{
"type": "integer",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"name": "nextPage",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "previousPage",
"in": "query"
},
{
"type": "string",
"name": "sort",
"in": "query"
},
{
"type": "string",
"name": "sortBy",
"in": "query"
},
{
"type": "integer",
"name": "totalPage",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@ -2313,28 +2380,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"
}
}
}
@ -2347,9 +2408,20 @@ const docTemplate = `{
],
"description": "API for create MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "Create MasterMenus",
"parameters": [
{
"description": "Required payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.MasterMenusCreateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
@ -2357,28 +2429,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"
}
}
}
@ -2393,7 +2459,7 @@ const docTemplate = `{
],
"description": "API for getting one MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "Get one MasterMenus",
"parameters": [
@ -2412,28 +2478,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"
}
}
}
@ -2446,9 +2506,9 @@ const docTemplate = `{
],
"description": "API for update MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "update MasterMenus",
"summary": "Update MasterMenus",
"parameters": [
{
"type": "integer",
@ -2499,9 +2559,9 @@ const docTemplate = `{
],
"description": "API for delete MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "delete MasterMenus",
"summary": "Delete MasterMenus",
"parameters": [
{
"type": "integer",
@ -2518,28 +2578,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"
}
}
}
@ -2554,9 +2608,66 @@ const docTemplate = `{
],
"description": "API for getting all MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "Get all MasterModules",
"parameters": [
{
"type": "string",
"name": "description",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"name": "statusId",
"in": "query"
},
{
"type": "integer",
"name": "count",
"in": "query"
},
{
"type": "integer",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"name": "nextPage",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "previousPage",
"in": "query"
},
{
"type": "string",
"name": "sort",
"in": "query"
},
{
"type": "string",
"name": "sortBy",
"in": "query"
},
{
"type": "integer",
"name": "totalPage",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@ -2564,28 +2675,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"
}
}
}
@ -2598,9 +2703,20 @@ const docTemplate = `{
],
"description": "API for create MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "Create MasterModules",
"parameters": [
{
"description": "Required payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.MasterModulesCreateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
@ -2608,28 +2724,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"
}
}
}
@ -2644,7 +2754,7 @@ const docTemplate = `{
],
"description": "API for getting one MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "Get one MasterModules",
"parameters": [
@ -2663,28 +2773,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"
}
}
}
@ -2697,9 +2801,9 @@ const docTemplate = `{
],
"description": "API for update MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "update MasterModules",
"summary": "Update MasterModules",
"parameters": [
{
"type": "integer",
@ -2707,6 +2811,15 @@ const docTemplate = `{
"name": "id",
"in": "path",
"required": true
},
{
"description": "Required payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.MasterModulesUpdateRequest"
}
}
],
"responses": {
@ -2716,28 +2829,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"
}
}
}
@ -2750,9 +2857,9 @@ const docTemplate = `{
],
"description": "API for delete MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "delete MasterModules",
"summary": "Delete MasterModules",
"parameters": [
{
"type": "integer",
@ -2769,28 +2876,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"
}
}
}
@ -5778,6 +5879,90 @@ const docTemplate = `{
}
}
},
"request.MasterMenusCreateRequest": {
"type": "object",
"required": [
"description",
"icon",
"moduleId",
"name",
"parentMenuId",
"statusId"
],
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
"moduleId": {
"type": "integer"
},
"name": {
"type": "string"
},
"parentMenuId": {
"type": "integer"
},
"position": {
"type": "integer"
},
"statusId": {
"type": "integer"
}
}
},
"request.MasterModulesCreateRequest": {
"type": "object",
"required": [
"description",
"name",
"pathUrl",
"statusId"
],
"properties": {
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"pathUrl": {
"type": "string"
},
"statusId": {
"type": "integer"
}
}
},
"request.MasterModulesUpdateRequest": {
"type": "object",
"required": [
"description",
"id",
"name",
"pathUrl",
"statusId"
],
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"pathUrl": {
"type": "string"
},
"statusId": {
"type": "integer"
}
}
},
"request.PpidDataCategoriesCreateRequest": {
"type": "object",
"required": [

View File

@ -2292,9 +2292,76 @@
],
"description": "API for getting all MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "Get all MasterMenus",
"parameters": [
{
"type": "string",
"name": "description",
"in": "query"
},
{
"type": "integer",
"name": "moduleId",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"name": "parentMenuId",
"in": "query"
},
{
"type": "integer",
"name": "statusId",
"in": "query"
},
{
"type": "integer",
"name": "count",
"in": "query"
},
{
"type": "integer",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"name": "nextPage",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "previousPage",
"in": "query"
},
{
"type": "string",
"name": "sort",
"in": "query"
},
{
"type": "string",
"name": "sortBy",
"in": "query"
},
{
"type": "integer",
"name": "totalPage",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@ -2302,28 +2369,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"
}
}
}
@ -2336,9 +2397,20 @@
],
"description": "API for create MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "Create MasterMenus",
"parameters": [
{
"description": "Required payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.MasterMenusCreateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
@ -2346,28 +2418,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"
}
}
}
@ -2382,7 +2448,7 @@
],
"description": "API for getting one MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "Get one MasterMenus",
"parameters": [
@ -2401,28 +2467,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"
}
}
}
@ -2435,9 +2495,9 @@
],
"description": "API for update MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "update MasterMenus",
"summary": "Update MasterMenus",
"parameters": [
{
"type": "integer",
@ -2488,9 +2548,9 @@
],
"description": "API for delete MasterMenus",
"tags": [
"Task"
"MasterMenus"
],
"summary": "delete MasterMenus",
"summary": "Delete MasterMenus",
"parameters": [
{
"type": "integer",
@ -2507,28 +2567,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"
}
}
}
@ -2543,9 +2597,66 @@
],
"description": "API for getting all MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "Get all MasterModules",
"parameters": [
{
"type": "string",
"name": "description",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"name": "statusId",
"in": "query"
},
{
"type": "integer",
"name": "count",
"in": "query"
},
{
"type": "integer",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"name": "nextPage",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "previousPage",
"in": "query"
},
{
"type": "string",
"name": "sort",
"in": "query"
},
{
"type": "string",
"name": "sortBy",
"in": "query"
},
{
"type": "integer",
"name": "totalPage",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@ -2553,28 +2664,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"
}
}
}
@ -2587,9 +2692,20 @@
],
"description": "API for create MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "Create MasterModules",
"parameters": [
{
"description": "Required payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.MasterModulesCreateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
@ -2597,28 +2713,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"
}
}
}
@ -2633,7 +2743,7 @@
],
"description": "API for getting one MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "Get one MasterModules",
"parameters": [
@ -2652,28 +2762,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"
}
}
}
@ -2686,9 +2790,9 @@
],
"description": "API for update MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "update MasterModules",
"summary": "Update MasterModules",
"parameters": [
{
"type": "integer",
@ -2696,6 +2800,15 @@
"name": "id",
"in": "path",
"required": true
},
{
"description": "Required payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.MasterModulesUpdateRequest"
}
}
],
"responses": {
@ -2705,28 +2818,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"
}
}
}
@ -2739,9 +2846,9 @@
],
"description": "API for delete MasterModules",
"tags": [
"Task"
"MasterModules"
],
"summary": "delete MasterModules",
"summary": "Delete MasterModules",
"parameters": [
{
"type": "integer",
@ -2758,28 +2865,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"
}
}
}
@ -5767,6 +5868,90 @@
}
}
},
"request.MasterMenusCreateRequest": {
"type": "object",
"required": [
"description",
"icon",
"moduleId",
"name",
"parentMenuId",
"statusId"
],
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
"moduleId": {
"type": "integer"
},
"name": {
"type": "string"
},
"parentMenuId": {
"type": "integer"
},
"position": {
"type": "integer"
},
"statusId": {
"type": "integer"
}
}
},
"request.MasterModulesCreateRequest": {
"type": "object",
"required": [
"description",
"name",
"pathUrl",
"statusId"
],
"properties": {
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"pathUrl": {
"type": "string"
},
"statusId": {
"type": "integer"
}
}
},
"request.MasterModulesUpdateRequest": {
"type": "object",
"required": [
"description",
"id",
"name",
"pathUrl",
"statusId"
],
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"pathUrl": {
"type": "string"
},
"statusId": {
"type": "integer"
}
}
},
"request.PpidDataCategoriesCreateRequest": {
"type": "object",
"required": [

View File

@ -185,6 +185,65 @@ definitions:
- id
- prov_id
type: object
request.MasterMenusCreateRequest:
properties:
description:
type: string
icon:
type: string
moduleId:
type: integer
name:
type: string
parentMenuId:
type: integer
position:
type: integer
statusId:
type: integer
required:
- description
- icon
- moduleId
- name
- parentMenuId
- statusId
type: object
request.MasterModulesCreateRequest:
properties:
description:
type: string
name:
type: string
pathUrl:
type: string
statusId:
type: integer
required:
- description
- name
- pathUrl
- statusId
type: object
request.MasterModulesUpdateRequest:
properties:
description:
type: string
id:
type: integer
name:
type: string
pathUrl:
type: string
statusId:
type: integer
required:
- description
- id
- name
- pathUrl
- statusId
type: object
request.PpidDataCategoriesCreateRequest:
properties:
description:
@ -1984,60 +2043,99 @@ paths:
/master-menus:
get:
description: API for getting all MasterMenus
parameters:
- in: query
name: description
type: string
- in: query
name: moduleId
type: integer
- in: query
name: name
type: string
- in: query
name: parentMenuId
type: integer
- in: query
name: statusId
type: integer
- in: query
name: count
type: integer
- in: query
name: limit
type: integer
- in: query
name: nextPage
type: integer
- in: query
name: page
type: integer
- in: query
name: previousPage
type: integer
- in: query
name: sort
type: string
- in: query
name: sortBy
type: string
- in: query
name: totalPage
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 MasterMenus
tags:
- Task
- MasterMenus
post:
description: API for create MasterMenus
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.MasterMenusCreateRequest'
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 MasterMenus
tags:
- Task
- MasterMenus
/master-menus/{id}:
delete:
description: API for delete MasterMenus
@ -2052,27 +2150,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 MasterMenus
summary: Delete MasterMenus
tags:
- Task
- MasterMenus
get:
description: API for getting one MasterMenus
parameters:
@ -2086,27 +2180,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 MasterMenus
tags:
- Task
- MasterMenus
put:
description: API for update MasterMenus
parameters:
@ -2138,66 +2228,99 @@ paths:
$ref: '#/definitions/response.Response'
security:
- Bearer: []
summary: update MasterMenus
summary: Update MasterMenus
tags:
- Task
- MasterMenus
/master-modules:
get:
description: API for getting all MasterModules
parameters:
- in: query
name: description
type: string
- in: query
name: name
type: string
- in: query
name: statusId
type: integer
- in: query
name: count
type: integer
- in: query
name: limit
type: integer
- in: query
name: nextPage
type: integer
- in: query
name: page
type: integer
- in: query
name: previousPage
type: integer
- in: query
name: sort
type: string
- in: query
name: sortBy
type: string
- in: query
name: totalPage
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 MasterModules
tags:
- Task
- MasterModules
post:
description: API for create MasterModules
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.MasterModulesCreateRequest'
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 MasterModules
tags:
- Task
- MasterModules
/master-modules/{id}:
delete:
description: API for delete MasterModules
@ -2212,27 +2335,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 MasterModules
summary: Delete MasterModules
tags:
- Task
- MasterModules
get:
description: API for getting one MasterModules
parameters:
@ -2246,27 +2365,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 MasterModules
tags:
- Task
- MasterModules
put:
description: API for update MasterModules
parameters:
@ -2275,32 +2390,34 @@ paths:
name: id
required: true
type: integer
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.MasterModulesUpdateRequest'
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: update MasterModules
summary: Update MasterModules
tags:
- Task
- MasterModules
/master-statuses:
get:
description: API for getting all MasterStatuses