add: custom static page module
This commit is contained in:
parent
c738cce923
commit
69bb911dcd
|
|
@ -0,0 +1,14 @@
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type CustomStaticPages struct {
|
||||||
|
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
||||||
|
Title string `json:"title" gorm:"type:varchar"`
|
||||||
|
Description string `json:"description" gorm:"type:varchar"`
|
||||||
|
Slug string `json:"slug" gorm:"type:varchar"`
|
||||||
|
HtmlBody string `json:"html_body" gorm:"type:text"`
|
||||||
|
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()"`
|
||||||
|
}
|
||||||
|
|
@ -7,16 +7,16 @@ type Users struct {
|
||||||
Username string `json:"username" gorm:"type:varchar"`
|
Username string `json:"username" gorm:"type:varchar"`
|
||||||
Email string `json:"email" gorm:"type:varchar"`
|
Email string `json:"email" gorm:"type:varchar"`
|
||||||
Fullname string `json:"fullname" gorm:"type:varchar"`
|
Fullname string `json:"fullname" gorm:"type:varchar"`
|
||||||
Address string `json:"address" gorm:"type:varchar"`
|
Address *string `json:"address" gorm:"type:varchar"`
|
||||||
PhoneNumber string `json:"phone_number" gorm:"type:varchar"`
|
PhoneNumber *string `json:"phone_number" gorm:"type:varchar"`
|
||||||
WorkType string `json:"work_type" gorm:"type:varchar"`
|
WorkType *string `json:"work_type" gorm:"type:varchar"`
|
||||||
GenderType string `json:"gender_type" gorm:"type:varchar"`
|
GenderType *string `json:"gender_type" gorm:"type:varchar"`
|
||||||
IdentityType string `json:"identity_type" gorm:"type:varchar"`
|
IdentityType *string `json:"identity_type" gorm:"type:varchar"`
|
||||||
IdentityGroup string `json:"identity_group" gorm:"type:varchar"`
|
IdentityGroup *string `json:"identity_group" gorm:"type:varchar"`
|
||||||
IdentityGroupNumber string `json:"identity_group_number" gorm:"type:varchar"`
|
IdentityGroupNumber *string `json:"identity_group_number" gorm:"type:varchar"`
|
||||||
IdentityNumber string `json:"identity_number" gorm:"type:varchar"`
|
IdentityNumber *string `json:"identity_number" gorm:"type:varchar"`
|
||||||
DateOfBirth string `json:"date_of_birth" gorm:"type:varchar"`
|
DateOfBirth *string `json:"date_of_birth" gorm:"type:varchar"`
|
||||||
LastEducation string `json:"last_education" gorm:"type:varchar"`
|
LastEducation *string `json:"last_education" gorm:"type:varchar"`
|
||||||
UserRoleId uint `json:"user_role_id" gorm:"type:int4"`
|
UserRoleId uint `json:"user_role_id" gorm:"type:int4"`
|
||||||
UserLevelId uint `json:"user_level_id" gorm:"type:int4"`
|
UserLevelId uint `json:"user_level_id" gorm:"type:int4"`
|
||||||
KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"`
|
KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"`
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ func Models() []interface{} {
|
||||||
entity.ArticleCategoryDetails{},
|
entity.ArticleCategoryDetails{},
|
||||||
entity.ArticleFiles{},
|
entity.ArticleFiles{},
|
||||||
entity.Cities{},
|
entity.Cities{},
|
||||||
|
entity.CustomStaticPages{},
|
||||||
entity.Districts{},
|
entity.Districts{},
|
||||||
entity.Magazines{},
|
entity.Magazines{},
|
||||||
entity.MagazineFiles{},
|
entity.MagazineFiles{},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Controller struct {
|
||||||
|
CustomStaticPages CustomStaticPagesController
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewController(CustomStaticPagesService service.CustomStaticPagesService, log zerolog.Logger) *Controller {
|
||||||
|
return &Controller{
|
||||||
|
CustomStaticPages: NewCustomStaticPagesController(CustomStaticPagesService, log),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/request"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/service"
|
||||||
|
"go-humas-be/utils/paginator"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
utilRes "go-humas-be/utils/response"
|
||||||
|
utilVal "go-humas-be/utils/validator"
|
||||||
|
)
|
||||||
|
|
||||||
|
type customStaticPagesController struct {
|
||||||
|
customStaticPagesService service.CustomStaticPagesService
|
||||||
|
Log zerolog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomStaticPagesController interface {
|
||||||
|
All(c *fiber.Ctx) error
|
||||||
|
Show(c *fiber.Ctx) error
|
||||||
|
ShowBySlug(c *fiber.Ctx) error
|
||||||
|
Save(c *fiber.Ctx) error
|
||||||
|
Update(c *fiber.Ctx) error
|
||||||
|
Delete(c *fiber.Ctx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCustomStaticPagesController(customStaticPagesService service.CustomStaticPagesService, log zerolog.Logger) CustomStaticPagesController {
|
||||||
|
return &customStaticPagesController{
|
||||||
|
customStaticPagesService: customStaticPagesService,
|
||||||
|
Log: log,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// All get all CustomStaticPages
|
||||||
|
// @Summary Get all CustomStaticPages
|
||||||
|
// @Description API for getting all CustomStaticPages
|
||||||
|
// @Tags CustomStaticPages
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param req query request.CustomStaticPagesQueryRequest false "query parameters"
|
||||||
|
// @Param req query paginator.Pagination false "pagination parameters"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /custom-static-pages [get]
|
||||||
|
func (_i *customStaticPagesController) All(c *fiber.Ctx) error {
|
||||||
|
paginate, err := paginator.Paginate(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
reqContext := request.CustomStaticPagesQueryRequestContext{
|
||||||
|
Title: c.Query("title"),
|
||||||
|
Description: c.Query("description"),
|
||||||
|
Slug: c.Query("slug"),
|
||||||
|
HtmlBody: c.Query("htmlBody"),
|
||||||
|
}
|
||||||
|
req := reqContext.ToParamRequest()
|
||||||
|
req.Pagination = paginate
|
||||||
|
|
||||||
|
customStaticPagesData, paging, err := _i.customStaticPagesService.All(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"CustomStaticPages list successfully retrieved"},
|
||||||
|
Data: customStaticPagesData,
|
||||||
|
Meta: paging,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show get one CustomStaticPages
|
||||||
|
// @Summary Get one CustomStaticPages
|
||||||
|
// @Description API for getting one CustomStaticPages
|
||||||
|
// @Tags CustomStaticPages
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param id path int true "CustomStaticPages ID"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /custom-static-pages/{id} [get]
|
||||||
|
func (_i *customStaticPagesController) Show(c *fiber.Ctx) error {
|
||||||
|
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
customStaticPagesData, err := _i.customStaticPagesService.Show(uint(id))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"CustomStaticPages successfully retrieved"},
|
||||||
|
Data: customStaticPagesData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShowBySlug get one CustomStaticPages
|
||||||
|
// @Summary Get one CustomStaticPages
|
||||||
|
// @Description API for getting one CustomStaticPages
|
||||||
|
// @Tags CustomStaticPages
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param slug path string true "CustomStaticPages Slug"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /custom-static-pages/slug/{slug} [get]
|
||||||
|
func (_i *customStaticPagesController) ShowBySlug(c *fiber.Ctx) error {
|
||||||
|
slug := c.Params("slug")
|
||||||
|
|
||||||
|
customStaticPagesData, err := _i.customStaticPagesService.ShowBySlug(slug)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"CustomStaticPages successfully retrieved"},
|
||||||
|
Data: customStaticPagesData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save create CustomStaticPages
|
||||||
|
// @Summary Create CustomStaticPages
|
||||||
|
// @Description API for create CustomStaticPages
|
||||||
|
// @Tags CustomStaticPages
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param payload body request.CustomStaticPagesCreateRequest true "Required payload"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /custom-static-pages [post]
|
||||||
|
func (_i *customStaticPagesController) Save(c *fiber.Ctx) error {
|
||||||
|
req := new(request.CustomStaticPagesCreateRequest)
|
||||||
|
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
authToken := c.Get("Authorization")
|
||||||
|
dataResult, err := _i.customStaticPagesService.Save(*req, authToken)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"CustomStaticPages successfully created"},
|
||||||
|
Data: dataResult,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update CustomStaticPages
|
||||||
|
// @Summary update CustomStaticPages
|
||||||
|
// @Description API for update CustomStaticPages
|
||||||
|
// @Tags CustomStaticPages
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param payload body request.CustomStaticPagesUpdateRequest true "Required payload"
|
||||||
|
// @Param id path int true "CustomStaticPages ID"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /custom-static-pages/{id} [put]
|
||||||
|
func (_i *customStaticPagesController) Update(c *fiber.Ctx) error {
|
||||||
|
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
req := new(request.CustomStaticPagesUpdateRequest)
|
||||||
|
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = _i.customStaticPagesService.Update(uint(id), *req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"CustomStaticPages successfully updated"},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete delete CustomStaticPages
|
||||||
|
// @Summary delete CustomStaticPages
|
||||||
|
// @Description API for delete CustomStaticPages
|
||||||
|
// @Tags CustomStaticPages
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param id path int true "CustomStaticPages ID"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /custom-static-pages/{id} [delete]
|
||||||
|
func (_i *customStaticPagesController) Delete(c *fiber.Ctx) error {
|
||||||
|
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = _i.customStaticPagesService.Delete(uint(id))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"CustomStaticPages successfully deleted"},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package custom_static_pages
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/controller"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/repository"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/service"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// struct of CustomStaticPagesRouter
|
||||||
|
type CustomStaticPagesRouter struct {
|
||||||
|
App fiber.Router
|
||||||
|
Controller *controller.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// register bulky of CustomStaticPages module
|
||||||
|
var NewCustomStaticPagesModule = fx.Options(
|
||||||
|
// register repository of CustomStaticPages module
|
||||||
|
fx.Provide(repository.NewCustomStaticPagesRepository),
|
||||||
|
|
||||||
|
// register service of CustomStaticPages module
|
||||||
|
fx.Provide(service.NewCustomStaticPagesService),
|
||||||
|
|
||||||
|
// register controller of CustomStaticPages module
|
||||||
|
fx.Provide(controller.NewController),
|
||||||
|
|
||||||
|
// register router of CustomStaticPages module
|
||||||
|
fx.Provide(NewCustomStaticPagesRouter),
|
||||||
|
)
|
||||||
|
|
||||||
|
// init CustomStaticPagesRouter
|
||||||
|
func NewCustomStaticPagesRouter(fiber *fiber.App, controller *controller.Controller) *CustomStaticPagesRouter {
|
||||||
|
return &CustomStaticPagesRouter{
|
||||||
|
App: fiber,
|
||||||
|
Controller: controller,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// register routes of CustomStaticPages module
|
||||||
|
func (_i *CustomStaticPagesRouter) RegisterCustomStaticPagesRoutes() {
|
||||||
|
// define controllers
|
||||||
|
customStaticPagesController := _i.Controller.CustomStaticPages
|
||||||
|
|
||||||
|
// define routes
|
||||||
|
_i.App.Route("/custom-static-pages", func(router fiber.Router) {
|
||||||
|
router.Get("/", customStaticPagesController.All)
|
||||||
|
router.Get("/:id", customStaticPagesController.Show)
|
||||||
|
router.Get("/slug/:slug", customStaticPagesController.ShowBySlug)
|
||||||
|
router.Post("/", customStaticPagesController.Save)
|
||||||
|
router.Put("/:id", customStaticPagesController.Update)
|
||||||
|
router.Delete("/:id", customStaticPagesController.Delete)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package mapper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go-humas-be/app/database/entity"
|
||||||
|
res "go-humas-be/app/module/custom_static_pages/response"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CustomStaticPagesResponseMapper(customStaticPagesReq *entity.CustomStaticPages) (customStaticPagesRes *res.CustomStaticPagesResponse) {
|
||||||
|
if customStaticPagesReq != nil {
|
||||||
|
customStaticPagesRes = &res.CustomStaticPagesResponse{
|
||||||
|
ID: customStaticPagesReq.ID,
|
||||||
|
Title: customStaticPagesReq.Title,
|
||||||
|
Description: customStaticPagesReq.Description,
|
||||||
|
Slug: customStaticPagesReq.Slug,
|
||||||
|
HtmlBody: customStaticPagesReq.HtmlBody,
|
||||||
|
IsActive: customStaticPagesReq.IsActive,
|
||||||
|
CreatedAt: customStaticPagesReq.CreatedAt,
|
||||||
|
UpdatedAt: customStaticPagesReq.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return customStaticPagesRes
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"go-humas-be/app/database"
|
||||||
|
"go-humas-be/app/database/entity"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/request"
|
||||||
|
"go-humas-be/utils/paginator"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type customStaticPagesRepository struct {
|
||||||
|
DB *database.Database
|
||||||
|
Log zerolog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomStaticPagesRepository define interface of ICustomStaticPagesRepository
|
||||||
|
type CustomStaticPagesRepository interface {
|
||||||
|
GetAll(req request.CustomStaticPagesQueryRequest) (customStaticPagess []*entity.CustomStaticPages, paging paginator.Pagination, err error)
|
||||||
|
FindOne(id uint) (customStaticPages *entity.CustomStaticPages, err error)
|
||||||
|
FindOneBySlug(slug string) (customStaticPages *entity.CustomStaticPages, err error)
|
||||||
|
Create(customStaticPages *entity.CustomStaticPages) (customStaticPagesReturn *entity.CustomStaticPages, err error)
|
||||||
|
Update(id uint, customStaticPages *entity.CustomStaticPages) (err error)
|
||||||
|
Delete(id uint) (err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCustomStaticPagesRepository(db *database.Database, logger zerolog.Logger) CustomStaticPagesRepository {
|
||||||
|
return &customStaticPagesRepository{
|
||||||
|
DB: db,
|
||||||
|
Log: logger,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// implement interface of ICustomStaticPagesRepository
|
||||||
|
func (_i *customStaticPagesRepository) GetAll(req request.CustomStaticPagesQueryRequest) (customStaticPagess []*entity.CustomStaticPages, paging paginator.Pagination, err error) {
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
query := _i.DB.DB.Model(&entity.CustomStaticPages{})
|
||||||
|
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.Slug != nil && *req.Slug != "" {
|
||||||
|
slug := strings.ToLower(*req.Slug)
|
||||||
|
query = query.Where("LOWER(slug) LIKE ?", "%"+strings.ToLower(slug)+"%")
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
|
||||||
|
err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&customStaticPagess).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
paging = *req.Pagination
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesRepository) FindOne(id uint) (customStaticPages *entity.CustomStaticPages, err error) {
|
||||||
|
if err := _i.DB.DB.First(&customStaticPages, id).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return customStaticPages, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesRepository) FindOneBySlug(slug string) (customStaticPages *entity.CustomStaticPages, err error) {
|
||||||
|
if err := _i.DB.DB.Where("slug = ?", slug).First(&customStaticPages).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return customStaticPages, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesRepository) Create(customStaticPages *entity.CustomStaticPages) (customStaticPagesReturn *entity.CustomStaticPages, err error) {
|
||||||
|
result := _i.DB.DB.Create(customStaticPages)
|
||||||
|
return customStaticPages, result.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesRepository) Update(id uint, customStaticPages *entity.CustomStaticPages) (err error) {
|
||||||
|
return _i.DB.DB.Model(&entity.CustomStaticPages{}).
|
||||||
|
Where(&entity.CustomStaticPages{ID: id}).
|
||||||
|
Updates(customStaticPages).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesRepository) Delete(id uint) error {
|
||||||
|
return _i.DB.DB.Delete(&entity.CustomStaticPages{}, id).Error
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package request
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go-humas-be/app/database/entity"
|
||||||
|
"go-humas-be/utils/paginator"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CustomStaticPagesGeneric interface {
|
||||||
|
ToEntity()
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomStaticPagesQueryRequest struct {
|
||||||
|
Title *string `json:"title"`
|
||||||
|
Description *string `json:"description"`
|
||||||
|
Slug *string `json:"slug"`
|
||||||
|
HtmlBody *string `json:"htmlBody"`
|
||||||
|
Pagination *paginator.Pagination `json:"pagination"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomStaticPagesCreateRequest struct {
|
||||||
|
Title string `json:"title" validate:"required"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Slug string `json:"slug" validate:"required"`
|
||||||
|
HtmlBody string `json:"htmlBody" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req CustomStaticPagesCreateRequest) ToEntity() *entity.CustomStaticPages {
|
||||||
|
return &entity.CustomStaticPages{
|
||||||
|
Title: req.Title,
|
||||||
|
Description: req.Description,
|
||||||
|
Slug: req.Slug,
|
||||||
|
HtmlBody: req.HtmlBody,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomStaticPagesUpdateRequest struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
Title string `json:"title" validate:"required"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Slug string `json:"slug" validate:"required"`
|
||||||
|
HtmlBody string `json:"htmlBody" validate:"required"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req CustomStaticPagesUpdateRequest) ToEntity() *entity.CustomStaticPages {
|
||||||
|
return &entity.CustomStaticPages{
|
||||||
|
ID: req.ID,
|
||||||
|
Title: req.Title,
|
||||||
|
Description: req.Description,
|
||||||
|
Slug: req.Slug,
|
||||||
|
HtmlBody: req.HtmlBody,
|
||||||
|
UpdatedAt: req.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomStaticPagesQueryRequestContext struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
HtmlBody string `json:"htmlBody"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req CustomStaticPagesQueryRequestContext) ToParamRequest() CustomStaticPagesQueryRequest {
|
||||||
|
var request CustomStaticPagesQueryRequest
|
||||||
|
|
||||||
|
if title := req.Title; title != "" {
|
||||||
|
request.Title = &title
|
||||||
|
}
|
||||||
|
if description := req.Description; description != "" {
|
||||||
|
request.Description = &description
|
||||||
|
}
|
||||||
|
if slug := req.Slug; slug != "" {
|
||||||
|
request.Slug = &slug
|
||||||
|
}
|
||||||
|
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package response
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type CustomStaticPagesResponse struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
HtmlBody string `json:"htmlBody"`
|
||||||
|
IsActive bool `json:"isActive"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"go-humas-be/app/database/entity"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/mapper"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/repository"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/request"
|
||||||
|
"go-humas-be/app/module/custom_static_pages/response"
|
||||||
|
usersRepository "go-humas-be/app/module/users/repository"
|
||||||
|
"go-humas-be/utils/paginator"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CustomStaticPagesService
|
||||||
|
type customStaticPagesService struct {
|
||||||
|
Repo repository.CustomStaticPagesRepository
|
||||||
|
UsersRepo usersRepository.UsersRepository
|
||||||
|
Log zerolog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomStaticPagesService define interface of ICustomStaticPagesService
|
||||||
|
type CustomStaticPagesService interface {
|
||||||
|
All(req request.CustomStaticPagesQueryRequest) (customStaticPages []*response.CustomStaticPagesResponse, paging paginator.Pagination, err error)
|
||||||
|
Show(id uint) (customStaticPages *response.CustomStaticPagesResponse, err error)
|
||||||
|
ShowBySlug(slug string) (customStaticPages *response.CustomStaticPagesResponse, err error)
|
||||||
|
Save(req request.CustomStaticPagesCreateRequest, authToken string) (customStaticPages *entity.CustomStaticPages, err error)
|
||||||
|
Update(id uint, req request.CustomStaticPagesUpdateRequest) (err error)
|
||||||
|
Delete(id uint) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCustomStaticPagesService init CustomStaticPagesService
|
||||||
|
func NewCustomStaticPagesService(repo repository.CustomStaticPagesRepository, log zerolog.Logger, usersRepo usersRepository.UsersRepository) CustomStaticPagesService {
|
||||||
|
|
||||||
|
return &customStaticPagesService{
|
||||||
|
Repo: repo,
|
||||||
|
Log: log,
|
||||||
|
UsersRepo: usersRepo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// All implement interface of CustomStaticPagesService
|
||||||
|
func (_i *customStaticPagesService) All(req request.CustomStaticPagesQueryRequest) (customStaticPagess []*response.CustomStaticPagesResponse, paging paginator.Pagination, err error) {
|
||||||
|
results, paging, err := _i.Repo.GetAll(req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, result := range results {
|
||||||
|
customStaticPagess = append(customStaticPagess, mapper.CustomStaticPagesResponseMapper(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesService) Show(id uint) (customStaticPages *response.CustomStaticPagesResponse, err error) {
|
||||||
|
result, err := _i.Repo.FindOne(id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapper.CustomStaticPagesResponseMapper(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesService) ShowBySlug(slug string) (customStaticPages *response.CustomStaticPagesResponse, err error) {
|
||||||
|
result, err := _i.Repo.FindOneBySlug(slug)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapper.CustomStaticPagesResponseMapper(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesService) Save(req request.CustomStaticPagesCreateRequest, authToken string) (customStaticPages *entity.CustomStaticPages, err error) {
|
||||||
|
_i.Log.Info().Interface("data", req).Msg("")
|
||||||
|
|
||||||
|
newReq := req.ToEntity()
|
||||||
|
|
||||||
|
//createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||||
|
//newReq.CreatedById = &createdBy.ID
|
||||||
|
|
||||||
|
return _i.Repo.Create(newReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesService) Update(id uint, req request.CustomStaticPagesUpdateRequest) (err error) {
|
||||||
|
_i.Log.Info().Interface("data", req).Msg("")
|
||||||
|
return _i.Repo.Update(id, req.ToEntity())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *customStaticPagesService) Delete(id uint) error {
|
||||||
|
result, err := _i.Repo.FindOne(id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
result.IsActive = false
|
||||||
|
return _i.Repo.Update(id, result)
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
_ "github.com/gofiber/fiber/v2"
|
||||||
"go-humas-be/app/module/users/request"
|
"go-humas-be/app/module/users/request"
|
||||||
"go-humas-be/app/module/users/service"
|
"go-humas-be/app/module/users/service"
|
||||||
"go-humas-be/utils/paginator"
|
"go-humas-be/utils/paginator"
|
||||||
|
|
@ -153,7 +154,7 @@ func (_i *usersController) Save(c *fiber.Ctx) error {
|
||||||
|
|
||||||
authToken := c.Get("Authorization")
|
authToken := c.Get("Authorization")
|
||||||
|
|
||||||
err := _i.usersService.Save(*req, authToken)
|
dataResult, err := _i.usersService.Save(*req, authToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -161,6 +162,7 @@ func (_i *usersController) Save(c *fiber.Ctx) error {
|
||||||
return utilRes.Resp(c, utilRes.Response{
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
Success: true,
|
Success: true,
|
||||||
Messages: utilRes.Messages{"Users successfully created"},
|
Messages: utilRes.Messages{"Users successfully created"},
|
||||||
|
Data: dataResult,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ type UsersRepository interface {
|
||||||
GetAll(req request.UsersQueryRequest) (userss []*entity.Users, paging paginator.Pagination, err error)
|
GetAll(req request.UsersQueryRequest) (userss []*entity.Users, paging paginator.Pagination, err error)
|
||||||
FindOne(id uint) (users *entity.Users, err error)
|
FindOne(id uint) (users *entity.Users, err error)
|
||||||
FindByKeycloakId(keycloakId string) (users *entity.Users, err error)
|
FindByKeycloakId(keycloakId string) (users *entity.Users, err error)
|
||||||
Create(users *entity.Users) (err error)
|
Create(users *entity.Users) (userReturn *entity.Users, err error)
|
||||||
Update(id uint, users *entity.Users) (err error)
|
Update(id uint, users *entity.Users) (err error)
|
||||||
Delete(id uint) (err error)
|
Delete(id uint) (err error)
|
||||||
}
|
}
|
||||||
|
|
@ -116,8 +116,9 @@ func (_i *usersRepository) FindByKeycloakId(keycloakId string) (users *entity.Us
|
||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *usersRepository) Create(users *entity.Users) (err error) {
|
func (_i *usersRepository) Create(users *entity.Users) (userReturn *entity.Users, err error) {
|
||||||
return _i.DB.DB.Create(users).Error
|
result := _i.DB.DB.Create(users)
|
||||||
|
return users, result.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *usersRepository) Update(id uint, users *entity.Users) (err error) {
|
func (_i *usersRepository) Update(id uint, users *entity.Users) (err error) {
|
||||||
|
|
|
||||||
|
|
@ -51,16 +51,16 @@ func (req UsersCreateRequest) ToEntity() *entity.Users {
|
||||||
Username: req.Username,
|
Username: req.Username,
|
||||||
Email: req.Email,
|
Email: req.Email,
|
||||||
Fullname: req.Fullname,
|
Fullname: req.Fullname,
|
||||||
Address: *req.Address,
|
Address: req.Address,
|
||||||
PhoneNumber: *req.PhoneNumber,
|
PhoneNumber: req.PhoneNumber,
|
||||||
WorkType: *req.WorkType,
|
WorkType: req.WorkType,
|
||||||
GenderType: *req.GenderType,
|
GenderType: req.GenderType,
|
||||||
IdentityType: *req.IdentityType,
|
IdentityType: req.IdentityType,
|
||||||
IdentityGroup: *req.IdentityGroup,
|
IdentityGroup: req.IdentityGroup,
|
||||||
IdentityGroupNumber: *req.IdentityGroupNumber,
|
IdentityGroupNumber: req.IdentityGroupNumber,
|
||||||
IdentityNumber: *req.IdentityNumber,
|
IdentityNumber: req.IdentityNumber,
|
||||||
DateOfBirth: *req.DateOfBirth,
|
DateOfBirth: req.DateOfBirth,
|
||||||
LastEducation: *req.LastEducation,
|
LastEducation: req.LastEducation,
|
||||||
UserRoleId: req.UserRoleId,
|
UserRoleId: req.UserRoleId,
|
||||||
UserLevelId: req.UserLevelId,
|
UserLevelId: req.UserLevelId,
|
||||||
}
|
}
|
||||||
|
|
@ -91,16 +91,16 @@ func (req UsersUpdateRequest) ToEntity() *entity.Users {
|
||||||
Username: req.Username,
|
Username: req.Username,
|
||||||
Email: req.Email,
|
Email: req.Email,
|
||||||
Fullname: req.Fullname,
|
Fullname: req.Fullname,
|
||||||
Address: *req.Address,
|
Address: req.Address,
|
||||||
PhoneNumber: *req.PhoneNumber,
|
PhoneNumber: req.PhoneNumber,
|
||||||
WorkType: *req.WorkType,
|
WorkType: req.WorkType,
|
||||||
GenderType: *req.GenderType,
|
GenderType: req.GenderType,
|
||||||
IdentityType: *req.IdentityType,
|
IdentityType: req.IdentityType,
|
||||||
IdentityGroup: *req.IdentityGroup,
|
IdentityGroup: req.IdentityGroup,
|
||||||
IdentityGroupNumber: *req.IdentityGroupNumber,
|
IdentityGroupNumber: req.IdentityGroupNumber,
|
||||||
IdentityNumber: *req.IdentityNumber,
|
IdentityNumber: req.IdentityNumber,
|
||||||
DateOfBirth: *req.DateOfBirth,
|
DateOfBirth: req.DateOfBirth,
|
||||||
LastEducation: *req.LastEducation,
|
LastEducation: req.LastEducation,
|
||||||
UserRoleId: req.UserRoleId,
|
UserRoleId: req.UserRoleId,
|
||||||
StatusId: req.StatusId,
|
StatusId: req.StatusId,
|
||||||
UserLevelId: req.UserLevelId,
|
UserLevelId: req.UserLevelId,
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@ type UsersResponse struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Fullname string `json:"fullname"`
|
Fullname string `json:"fullname"`
|
||||||
Address string `json:"address"`
|
Address *string `json:"address"`
|
||||||
PhoneNumber string `json:"phoneNumber"`
|
PhoneNumber *string `json:"phoneNumber"`
|
||||||
WorkType string `json:"workType"`
|
WorkType *string `json:"workType"`
|
||||||
GenderType string `json:"genderType"`
|
GenderType *string `json:"genderType"`
|
||||||
IdentityType string `json:"identityType"`
|
IdentityType *string `json:"identityType"`
|
||||||
IdentityNumber string `json:"identityNumber"`
|
IdentityNumber *string `json:"identityNumber"`
|
||||||
DateOfBirth string `json:"dateOfBirth"`
|
DateOfBirth *string `json:"dateOfBirth"`
|
||||||
LastEducation string `json:"lastEducation"`
|
LastEducation *string `json:"lastEducation"`
|
||||||
KeycloakId *string `json:"keycloakId"`
|
KeycloakId *string `json:"keycloakId"`
|
||||||
UserRoleId uint `json:"userRoleId"`
|
UserRoleId uint `json:"userRoleId"`
|
||||||
UserLevelId uint `json:"userLevelId"`
|
UserLevelId uint `json:"userLevelId"`
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package service
|
||||||
import (
|
import (
|
||||||
"github.com/Nerzal/gocloak/v13"
|
"github.com/Nerzal/gocloak/v13"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
"go-humas-be/app/database/entity"
|
||||||
userLevelsRepository "go-humas-be/app/module/user_levels/repository"
|
userLevelsRepository "go-humas-be/app/module/user_levels/repository"
|
||||||
"go-humas-be/app/module/users/mapper"
|
"go-humas-be/app/module/users/mapper"
|
||||||
"go-humas-be/app/module/users/repository"
|
"go-humas-be/app/module/users/repository"
|
||||||
|
|
@ -26,7 +27,7 @@ type UsersService interface {
|
||||||
All(req request.UsersQueryRequest) (users []*response.UsersResponse, paging paginator.Pagination, err error)
|
All(req request.UsersQueryRequest) (users []*response.UsersResponse, paging paginator.Pagination, err error)
|
||||||
Show(id uint) (users *response.UsersResponse, err error)
|
Show(id uint) (users *response.UsersResponse, err error)
|
||||||
ShowUserInfo(authToken string) (users *response.UsersResponse, err error)
|
ShowUserInfo(authToken string) (users *response.UsersResponse, err error)
|
||||||
Save(req request.UsersCreateRequest, authToken string) (err error)
|
Save(req request.UsersCreateRequest, authToken string) (userReturn *entity.Users, err error)
|
||||||
Login(req request.UserLogin) (res *gocloak.JWT, err error)
|
Login(req request.UserLogin) (res *gocloak.JWT, err error)
|
||||||
Update(id uint, req request.UsersUpdateRequest) (err error)
|
Update(id uint, req request.UsersUpdateRequest) (err error)
|
||||||
Delete(id uint) error
|
Delete(id uint) error
|
||||||
|
|
@ -72,7 +73,7 @@ func (_i *usersService) ShowUserInfo(authToken string) (users *response.UsersRes
|
||||||
return mapper.UsersResponseMapper(userInfo, _i.UserLevelsRepo), nil
|
return mapper.UsersResponseMapper(userInfo, _i.UserLevelsRepo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *usersService) Save(req request.UsersCreateRequest, authToken string) (err error) {
|
func (_i *usersService) Save(req request.UsersCreateRequest, authToken string) (userReturn *entity.Users, err error) {
|
||||||
_i.Log.Info().Interface("data", req).Msg("")
|
_i.Log.Info().Interface("data", req).Msg("")
|
||||||
newReq := req.ToEntity()
|
newReq := req.ToEntity()
|
||||||
|
|
||||||
|
|
@ -85,7 +86,7 @@ func (_i *usersService) Save(req request.UsersCreateRequest, authToken string) (
|
||||||
|
|
||||||
keycloakId, err := _i.Keycloak.CreateUser(req.Fullname, req.Email, req.Username, req.Password)
|
keycloakId, err := _i.Keycloak.CreateUser(req.Fullname, req.Email, req.Username, req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newReq.KeycloakId = &keycloakId
|
newReq.KeycloakId = &keycloakId
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"go-humas-be/app/module/article_files"
|
"go-humas-be/app/module/article_files"
|
||||||
"go-humas-be/app/module/articles"
|
"go-humas-be/app/module/articles"
|
||||||
"go-humas-be/app/module/cities"
|
"go-humas-be/app/module/cities"
|
||||||
|
"go-humas-be/app/module/custom_static_pages"
|
||||||
"go-humas-be/app/module/districts"
|
"go-humas-be/app/module/districts"
|
||||||
"go-humas-be/app/module/magazine_files"
|
"go-humas-be/app/module/magazine_files"
|
||||||
"go-humas-be/app/module/magazines"
|
"go-humas-be/app/module/magazines"
|
||||||
|
|
@ -31,6 +32,7 @@ type Router struct {
|
||||||
ArticleFilesRouter *article_files.ArticleFilesRouter
|
ArticleFilesRouter *article_files.ArticleFilesRouter
|
||||||
ArticlesRouter *articles.ArticlesRouter
|
ArticlesRouter *articles.ArticlesRouter
|
||||||
CitiesRouter *cities.CitiesRouter
|
CitiesRouter *cities.CitiesRouter
|
||||||
|
CustomStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter
|
||||||
DistrictsRouter *districts.DistrictsRouter
|
DistrictsRouter *districts.DistrictsRouter
|
||||||
MagazineFilesRouter *magazine_files.MagazineFilesRouter
|
MagazineFilesRouter *magazine_files.MagazineFilesRouter
|
||||||
MagazinesRouter *magazines.MagazinesRouter
|
MagazinesRouter *magazines.MagazinesRouter
|
||||||
|
|
@ -52,6 +54,7 @@ func NewRouter(
|
||||||
articleFilesRouter *article_files.ArticleFilesRouter,
|
articleFilesRouter *article_files.ArticleFilesRouter,
|
||||||
articlesRouter *articles.ArticlesRouter,
|
articlesRouter *articles.ArticlesRouter,
|
||||||
citiesRouter *cities.CitiesRouter,
|
citiesRouter *cities.CitiesRouter,
|
||||||
|
customStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter,
|
||||||
districtsRouter *districts.DistrictsRouter,
|
districtsRouter *districts.DistrictsRouter,
|
||||||
magazineFilesRouter *magazine_files.MagazineFilesRouter,
|
magazineFilesRouter *magazine_files.MagazineFilesRouter,
|
||||||
magazinesRouter *magazines.MagazinesRouter,
|
magazinesRouter *magazines.MagazinesRouter,
|
||||||
|
|
@ -71,6 +74,7 @@ func NewRouter(
|
||||||
ArticleFilesRouter: articleFilesRouter,
|
ArticleFilesRouter: articleFilesRouter,
|
||||||
ArticlesRouter: articlesRouter,
|
ArticlesRouter: articlesRouter,
|
||||||
CitiesRouter: citiesRouter,
|
CitiesRouter: citiesRouter,
|
||||||
|
CustomStaticPagesRouter: customStaticPagesRouter,
|
||||||
DistrictsRouter: districtsRouter,
|
DistrictsRouter: districtsRouter,
|
||||||
MagazineFilesRouter: magazineFilesRouter,
|
MagazineFilesRouter: magazineFilesRouter,
|
||||||
MagazinesRouter: magazinesRouter,
|
MagazinesRouter: magazinesRouter,
|
||||||
|
|
@ -100,6 +104,7 @@ func (r *Router) Register() {
|
||||||
r.ArticleFilesRouter.RegisterArticleFilesRoutes()
|
r.ArticleFilesRouter.RegisterArticleFilesRoutes()
|
||||||
r.ArticlesRouter.RegisterArticlesRoutes()
|
r.ArticlesRouter.RegisterArticlesRoutes()
|
||||||
r.CitiesRouter.RegisterCitiesRoutes()
|
r.CitiesRouter.RegisterCitiesRoutes()
|
||||||
|
r.CustomStaticPagesRouter.RegisterCustomStaticPagesRoutes()
|
||||||
r.DistrictsRouter.RegisterDistrictsRoutes()
|
r.DistrictsRouter.RegisterDistrictsRoutes()
|
||||||
r.MagazinesRouter.RegisterMagazinesRoutes()
|
r.MagazinesRouter.RegisterMagazinesRoutes()
|
||||||
r.MagazineFilesRouter.RegisterMagazineFilesRoutes()
|
r.MagazineFilesRouter.RegisterMagazineFilesRoutes()
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ body-limit = 104857600 # "100 * 1024 * 1024"
|
||||||
|
|
||||||
[db.postgres]
|
[db.postgres]
|
||||||
dsn = "postgresql://humas_user:HumasDB@2024@38.47.180.165:5432/humas_db" # <driver>://<username>:<password>@<host>:<port>/<database>
|
dsn = "postgresql://humas_user:HumasDB@2024@38.47.180.165:5432/humas_db" # <driver>://<username>:<password>@<host>:<port>/<database>
|
||||||
migrate = false
|
migrate = true
|
||||||
seed = false
|
seed = false
|
||||||
|
|
||||||
[logger]
|
[logger]
|
||||||
|
|
|
||||||
|
|
@ -1768,6 +1768,358 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/custom-static-pages": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting all CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Get all CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "description",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "htmlBody",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "slug",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "title",
|
||||||
|
"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",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for create CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Create CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Required payload",
|
||||||
|
"name": "payload",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/request.CustomStaticPagesCreateRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/custom-static-pages/slug/{slug}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting one CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Get one CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "CustomStaticPages Slug",
|
||||||
|
"name": "slug",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/custom-static-pages/{id}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting one CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Get one CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "CustomStaticPages ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for update CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "update CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Required payload",
|
||||||
|
"name": "payload",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/request.CustomStaticPagesUpdateRequest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "CustomStaticPages ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for delete CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "delete CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "CustomStaticPages ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/districts": {
|
"/districts": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -5465,6 +5817,57 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request.CustomStaticPagesCreateRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"htmlBody",
|
||||||
|
"slug",
|
||||||
|
"title"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"htmlBody": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"request.CustomStaticPagesUpdateRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"htmlBody",
|
||||||
|
"id",
|
||||||
|
"slug",
|
||||||
|
"title"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"htmlBody": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request.MasterMenusCreateRequest": {
|
"request.MasterMenusCreateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -5774,7 +6177,6 @@ const docTemplate = `{
|
||||||
"email",
|
"email",
|
||||||
"fullname",
|
"fullname",
|
||||||
"password",
|
"password",
|
||||||
"phoneNumber",
|
|
||||||
"userLevelId",
|
"userLevelId",
|
||||||
"userRoleId",
|
"userRoleId",
|
||||||
"username"
|
"username"
|
||||||
|
|
@ -5836,7 +6238,6 @@ const docTemplate = `{
|
||||||
"email",
|
"email",
|
||||||
"fullname",
|
"fullname",
|
||||||
"password",
|
"password",
|
||||||
"phoneNumber",
|
|
||||||
"userLevelId",
|
"userLevelId",
|
||||||
"userRoleId",
|
"userRoleId",
|
||||||
"username"
|
"username"
|
||||||
|
|
|
||||||
|
|
@ -1757,6 +1757,358 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/custom-static-pages": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting all CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Get all CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "description",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "htmlBody",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "slug",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "title",
|
||||||
|
"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",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for create CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Create CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Required payload",
|
||||||
|
"name": "payload",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/request.CustomStaticPagesCreateRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/custom-static-pages/slug/{slug}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting one CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Get one CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "CustomStaticPages Slug",
|
||||||
|
"name": "slug",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/custom-static-pages/{id}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting one CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "Get one CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "CustomStaticPages ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for update CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "update CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Required payload",
|
||||||
|
"name": "payload",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/request.CustomStaticPagesUpdateRequest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "CustomStaticPages ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for delete CustomStaticPages",
|
||||||
|
"tags": [
|
||||||
|
"CustomStaticPages"
|
||||||
|
],
|
||||||
|
"summary": "delete CustomStaticPages",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "CustomStaticPages ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.BadRequestError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UnauthorizedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.InternalServerError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/districts": {
|
"/districts": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -5454,6 +5806,57 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request.CustomStaticPagesCreateRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"htmlBody",
|
||||||
|
"slug",
|
||||||
|
"title"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"htmlBody": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"request.CustomStaticPagesUpdateRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"htmlBody",
|
||||||
|
"id",
|
||||||
|
"slug",
|
||||||
|
"title"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"htmlBody": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request.MasterMenusCreateRequest": {
|
"request.MasterMenusCreateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -5763,7 +6166,6 @@
|
||||||
"email",
|
"email",
|
||||||
"fullname",
|
"fullname",
|
||||||
"password",
|
"password",
|
||||||
"phoneNumber",
|
|
||||||
"userLevelId",
|
"userLevelId",
|
||||||
"userRoleId",
|
"userRoleId",
|
||||||
"username"
|
"username"
|
||||||
|
|
@ -5825,7 +6227,6 @@
|
||||||
"email",
|
"email",
|
||||||
"fullname",
|
"fullname",
|
||||||
"password",
|
"password",
|
||||||
"phoneNumber",
|
|
||||||
"userLevelId",
|
"userLevelId",
|
||||||
"userRoleId",
|
"userRoleId",
|
||||||
"username"
|
"username"
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,41 @@ definitions:
|
||||||
- id
|
- id
|
||||||
- prov_id
|
- prov_id
|
||||||
type: object
|
type: object
|
||||||
|
request.CustomStaticPagesCreateRequest:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
htmlBody:
|
||||||
|
type: string
|
||||||
|
slug:
|
||||||
|
type: string
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- htmlBody
|
||||||
|
- slug
|
||||||
|
- title
|
||||||
|
type: object
|
||||||
|
request.CustomStaticPagesUpdateRequest:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
htmlBody:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
slug:
|
||||||
|
type: string
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- htmlBody
|
||||||
|
- id
|
||||||
|
- slug
|
||||||
|
- title
|
||||||
|
type: object
|
||||||
request.MasterMenusCreateRequest:
|
request.MasterMenusCreateRequest:
|
||||||
properties:
|
properties:
|
||||||
description:
|
description:
|
||||||
|
|
@ -420,7 +455,6 @@ definitions:
|
||||||
- email
|
- email
|
||||||
- fullname
|
- fullname
|
||||||
- password
|
- password
|
||||||
- phoneNumber
|
|
||||||
- userLevelId
|
- userLevelId
|
||||||
- userRoleId
|
- userRoleId
|
||||||
- username
|
- username
|
||||||
|
|
@ -465,7 +499,6 @@ definitions:
|
||||||
- email
|
- email
|
||||||
- fullname
|
- fullname
|
||||||
- password
|
- password
|
||||||
- phoneNumber
|
|
||||||
- userLevelId
|
- userLevelId
|
||||||
- userRoleId
|
- userRoleId
|
||||||
- username
|
- username
|
||||||
|
|
@ -1633,6 +1666,227 @@ paths:
|
||||||
summary: Update Cities
|
summary: Update Cities
|
||||||
tags:
|
tags:
|
||||||
- Untags
|
- Untags
|
||||||
|
/custom-static-pages:
|
||||||
|
get:
|
||||||
|
description: API for getting all CustomStaticPages
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: description
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: htmlBody
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: slug
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: title
|
||||||
|
type: string
|
||||||
|
- 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.UnauthorizedError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
|
security:
|
||||||
|
- Bearer: []
|
||||||
|
summary: Get all CustomStaticPages
|
||||||
|
tags:
|
||||||
|
- CustomStaticPages
|
||||||
|
post:
|
||||||
|
description: API for create CustomStaticPages
|
||||||
|
parameters:
|
||||||
|
- description: Required payload
|
||||||
|
in: body
|
||||||
|
name: payload
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.CustomStaticPagesCreateRequest'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.BadRequestError'
|
||||||
|
"401":
|
||||||
|
description: Unauthorized
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.UnauthorizedError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
|
security:
|
||||||
|
- Bearer: []
|
||||||
|
summary: Create CustomStaticPages
|
||||||
|
tags:
|
||||||
|
- CustomStaticPages
|
||||||
|
/custom-static-pages/{id}:
|
||||||
|
delete:
|
||||||
|
description: API for delete CustomStaticPages
|
||||||
|
parameters:
|
||||||
|
- description: CustomStaticPages ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
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.UnauthorizedError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
|
security:
|
||||||
|
- Bearer: []
|
||||||
|
summary: delete CustomStaticPages
|
||||||
|
tags:
|
||||||
|
- CustomStaticPages
|
||||||
|
get:
|
||||||
|
description: API for getting one CustomStaticPages
|
||||||
|
parameters:
|
||||||
|
- description: CustomStaticPages ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
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.UnauthorizedError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
|
security:
|
||||||
|
- Bearer: []
|
||||||
|
summary: Get one CustomStaticPages
|
||||||
|
tags:
|
||||||
|
- CustomStaticPages
|
||||||
|
put:
|
||||||
|
description: API for update CustomStaticPages
|
||||||
|
parameters:
|
||||||
|
- description: Required payload
|
||||||
|
in: body
|
||||||
|
name: payload
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.CustomStaticPagesUpdateRequest'
|
||||||
|
- description: CustomStaticPages ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
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.UnauthorizedError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
|
security:
|
||||||
|
- Bearer: []
|
||||||
|
summary: update CustomStaticPages
|
||||||
|
tags:
|
||||||
|
- CustomStaticPages
|
||||||
|
/custom-static-pages/slug/{slug}:
|
||||||
|
get:
|
||||||
|
description: API for getting one CustomStaticPages
|
||||||
|
parameters:
|
||||||
|
- description: CustomStaticPages Slug
|
||||||
|
in: path
|
||||||
|
name: slug
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.BadRequestError'
|
||||||
|
"401":
|
||||||
|
description: Unauthorized
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.UnauthorizedError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
|
security:
|
||||||
|
- Bearer: []
|
||||||
|
summary: Get one CustomStaticPages
|
||||||
|
tags:
|
||||||
|
- CustomStaticPages
|
||||||
/districts:
|
/districts:
|
||||||
get:
|
get:
|
||||||
description: API for getting all Districts
|
description: API for getting all Districts
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"go-humas-be/app/module/article_files"
|
"go-humas-be/app/module/article_files"
|
||||||
"go-humas-be/app/module/articles"
|
"go-humas-be/app/module/articles"
|
||||||
"go-humas-be/app/module/cities"
|
"go-humas-be/app/module/cities"
|
||||||
|
"go-humas-be/app/module/custom_static_pages"
|
||||||
"go-humas-be/app/module/districts"
|
"go-humas-be/app/module/districts"
|
||||||
"go-humas-be/app/module/magazine_files"
|
"go-humas-be/app/module/magazine_files"
|
||||||
"go-humas-be/app/module/magazines"
|
"go-humas-be/app/module/magazines"
|
||||||
|
|
@ -54,6 +55,7 @@ func main() {
|
||||||
article_files.NewArticleFilesModule,
|
article_files.NewArticleFilesModule,
|
||||||
articles.NewArticlesModule,
|
articles.NewArticlesModule,
|
||||||
cities.NewCitiesModule,
|
cities.NewCitiesModule,
|
||||||
|
custom_static_pages.NewCustomStaticPagesModule,
|
||||||
districts.NewDistrictsModule,
|
districts.NewDistrictsModule,
|
||||||
magazines.NewMagazinesModule,
|
magazines.NewMagazinesModule,
|
||||||
magazine_files.NewMagazineFilesModule,
|
magazine_files.NewMagazineFilesModule,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue