update ppid categories
This commit is contained in:
parent
8d0a00b37a
commit
61c7b2cf6c
|
|
@ -7,6 +7,7 @@ type PpidDataCategories struct {
|
||||||
Title string `json:"title" gorm:"type:varchar"`
|
Title string `json:"title" gorm:"type:varchar"`
|
||||||
Description string `json:"description" gorm:"type:varchar"`
|
Description string `json:"description" gorm:"type:varchar"`
|
||||||
Slug string `json:"slug" gorm:"type:varchar"`
|
Slug string `json:"slug" gorm:"type:varchar"`
|
||||||
|
ParentId *uint `json:"parent_id" gorm:"type:int4"`
|
||||||
ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"`
|
ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"`
|
||||||
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
||||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -18,6 +18,7 @@ type ppidDataCategoriesController struct {
|
||||||
type PpidDataCategoriesController interface {
|
type PpidDataCategoriesController interface {
|
||||||
All(c *fiber.Ctx) error
|
All(c *fiber.Ctx) error
|
||||||
Show(c *fiber.Ctx) error
|
Show(c *fiber.Ctx) error
|
||||||
|
ShowBySlug(c *fiber.Ctx) error
|
||||||
Save(c *fiber.Ctx) error
|
Save(c *fiber.Ctx) error
|
||||||
SaveThumbnail(c *fiber.Ctx) error
|
SaveThumbnail(c *fiber.Ctx) error
|
||||||
Update(c *fiber.Ctx) error
|
Update(c *fiber.Ctx) error
|
||||||
|
|
@ -52,6 +53,8 @@ func (_i *ppidDataCategoriesController) All(c *fiber.Ctx) error {
|
||||||
reqContext := request.PpidDataCategoriesQueryRequestContext{
|
reqContext := request.PpidDataCategoriesQueryRequestContext{
|
||||||
Title: c.Query("title"),
|
Title: c.Query("title"),
|
||||||
Description: c.Query("description"),
|
Description: c.Query("description"),
|
||||||
|
ParentId: c.Query("parentId"),
|
||||||
|
IsOnlyTop: c.Query("isOnlyTop"),
|
||||||
}
|
}
|
||||||
req := reqContext.ToParamRequest()
|
req := reqContext.ToParamRequest()
|
||||||
req.Pagination = paginate
|
req.Pagination = paginate
|
||||||
|
|
@ -98,6 +101,32 @@ func (_i *ppidDataCategoriesController) Show(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShowBySlug PpidDataCategories
|
||||||
|
// @Summary Get one PpidDataCategories
|
||||||
|
// @Description API for getting one PpidDataCategories
|
||||||
|
// @Tags PPID Categories
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param slug path string true "PpidDataCategories Slug"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 400 {object} response.BadRequestError
|
||||||
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
// @Failure 500 {object} response.InternalServerError
|
||||||
|
// @Router /ppid-data-categories/slug/{slug} [get]
|
||||||
|
func (_i *ppidDataCategoriesController) ShowBySlug(c *fiber.Ctx) error {
|
||||||
|
slug := c.Params("slug")
|
||||||
|
|
||||||
|
ppidDataCategoriesData, err := _i.ppidDataCategoriesService.ShowBySlug(slug)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Messages: utilRes.Messages{"PpidDataCategories successfully retrieved"},
|
||||||
|
Data: ppidDataCategoriesData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Save PpidDataCategories
|
// Save PpidDataCategories
|
||||||
// @Summary Create PpidDataCategories
|
// @Summary Create PpidDataCategories
|
||||||
// @Description API for create PpidDataCategories
|
// @Description API for create PpidDataCategories
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,13 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PpidDataCategoriesResponseMapper(ppidDataCategoriesReq *entity.PpidDataCategories) (ppidDataCategoriesRes *res.PpidDataCategoriesResponse) {
|
func PpidDataCategoriesResponseMapper(ppidDataCategoriesReq *entity.PpidDataCategories, childPpidDataCategoriesReq []*entity.PpidDataCategories) (ppidDataCategoriesRes *res.PpidDataCategoriesResponse) {
|
||||||
if ppidDataCategoriesReq != nil {
|
if ppidDataCategoriesReq != nil {
|
||||||
|
var childPpidDataCategoriesRes []*res.PpidDataCategoriesResponse
|
||||||
|
for _, item := range childPpidDataCategoriesReq {
|
||||||
|
childPpidDataCategoriesRes = append(childPpidDataCategoriesRes, PpidDataCategoriesResponseMapper(item, nil))
|
||||||
|
}
|
||||||
|
|
||||||
ppidDataCategoriesRes = &res.PpidDataCategoriesResponse{
|
ppidDataCategoriesRes = &res.PpidDataCategoriesResponse{
|
||||||
ID: ppidDataCategoriesReq.ID,
|
ID: ppidDataCategoriesReq.ID,
|
||||||
Title: ppidDataCategoriesReq.Title,
|
Title: ppidDataCategoriesReq.Title,
|
||||||
|
|
@ -17,6 +22,8 @@ func PpidDataCategoriesResponseMapper(ppidDataCategoriesReq *entity.PpidDataCate
|
||||||
IsActive: ppidDataCategoriesReq.IsActive,
|
IsActive: ppidDataCategoriesReq.IsActive,
|
||||||
CreatedAt: ppidDataCategoriesReq.CreatedAt,
|
CreatedAt: ppidDataCategoriesReq.CreatedAt,
|
||||||
UpdatedAt: ppidDataCategoriesReq.UpdatedAt,
|
UpdatedAt: ppidDataCategoriesReq.UpdatedAt,
|
||||||
|
|
||||||
|
Children: childPpidDataCategoriesRes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ppidDataCategoriesRes
|
return ppidDataCategoriesRes
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ func (_i *PpidDataCategoriesRouter) RegisterPpidDataCategoriesRoutes() {
|
||||||
_i.App.Route("/ppid-data-categories", func(router fiber.Router) {
|
_i.App.Route("/ppid-data-categories", func(router fiber.Router) {
|
||||||
router.Get("/", ppidDataCategoriesController.All)
|
router.Get("/", ppidDataCategoriesController.All)
|
||||||
router.Get("/:id", ppidDataCategoriesController.Show)
|
router.Get("/:id", ppidDataCategoriesController.Show)
|
||||||
|
router.Get("/slug/:slug", ppidDataCategoriesController.ShowBySlug)
|
||||||
router.Post("/", ppidDataCategoriesController.Save)
|
router.Post("/", ppidDataCategoriesController.Save)
|
||||||
router.Put("/:id", ppidDataCategoriesController.Update)
|
router.Put("/:id", ppidDataCategoriesController.Update)
|
||||||
router.Post("/thumbnail/:id", ppidDataCategoriesController.SaveThumbnail)
|
router.Post("/thumbnail/:id", ppidDataCategoriesController.SaveThumbnail)
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,35 @@ package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"go-humas-be/app/database"
|
"go-humas-be/app/database"
|
||||||
"go-humas-be/app/database/entity"
|
"go-humas-be/app/database/entity"
|
||||||
"go-humas-be/app/module/ppid_data_categories/request"
|
"go-humas-be/app/module/ppid_data_categories/request"
|
||||||
"go-humas-be/utils/paginator"
|
"go-humas-be/utils/paginator"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ppidDataCategoriesRepository struct {
|
type ppidDataCategoriesRepository struct {
|
||||||
DB *database.Database
|
DB *database.Database
|
||||||
|
Log zerolog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// PpidDataCategoriesRepository define interface of IPpidDataCategoriesRepository
|
// PpidDataCategoriesRepository define interface of IPpidDataCategoriesRepository
|
||||||
type PpidDataCategoriesRepository interface {
|
type PpidDataCategoriesRepository interface {
|
||||||
GetAll(req request.PpidDataCategoriesQueryRequest) (ppidDataCategoriess []*entity.PpidDataCategories, paging paginator.Pagination, err error)
|
GetAll(req request.PpidDataCategoriesQueryRequest) (ppidDataCategoriess []*entity.PpidDataCategories, paging paginator.Pagination, err error)
|
||||||
|
GetAllNonPage(req request.PpidDataCategoriesQueryRequest) (ppidDataCategoriess []*entity.PpidDataCategories, paging paginator.Pagination, err error)
|
||||||
FindOne(id uint) (ppidDataCategories *entity.PpidDataCategories, err error)
|
FindOne(id uint) (ppidDataCategories *entity.PpidDataCategories, err error)
|
||||||
|
FindOneBySlug(slug string) (ppidDataCategories *entity.PpidDataCategories, err error)
|
||||||
Create(ppidDataCategories *entity.PpidDataCategories) (err error)
|
Create(ppidDataCategories *entity.PpidDataCategories) (err error)
|
||||||
Update(id uint, ppidDataCategories *entity.PpidDataCategories) (err error)
|
Update(id uint, ppidDataCategories *entity.PpidDataCategories) (err error)
|
||||||
Delete(id uint) (err error)
|
Delete(id uint) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPpidDataCategoriesRepository(db *database.Database) PpidDataCategoriesRepository {
|
func NewPpidDataCategoriesRepository(db *database.Database, logger zerolog.Logger) PpidDataCategoriesRepository {
|
||||||
return &ppidDataCategoriesRepository{
|
return &ppidDataCategoriesRepository{
|
||||||
DB: db,
|
DB: db,
|
||||||
|
Log: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,6 +38,10 @@ func NewPpidDataCategoriesRepository(db *database.Database) PpidDataCategoriesRe
|
||||||
func (_i *ppidDataCategoriesRepository) GetAll(req request.PpidDataCategoriesQueryRequest) (ppidDataCategoriess []*entity.PpidDataCategories, paging paginator.Pagination, err error) {
|
func (_i *ppidDataCategoriesRepository) GetAll(req request.PpidDataCategoriesQueryRequest) (ppidDataCategoriess []*entity.PpidDataCategories, paging paginator.Pagination, err error) {
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
|
_i.Log.Info().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:GetAll", "Interface:ppidDataCategoriesRepository").
|
||||||
|
Interface("req", req).Msg("")
|
||||||
|
|
||||||
query := _i.DB.DB.Model(&entity.PpidDataCategories{})
|
query := _i.DB.DB.Model(&entity.PpidDataCategories{})
|
||||||
query = query.Where("is_active = ?", true)
|
query = query.Where("is_active = ?", true)
|
||||||
|
|
||||||
|
|
@ -43,6 +53,14 @@ func (_i *ppidDataCategoriesRepository) GetAll(req request.PpidDataCategoriesQue
|
||||||
description := strings.ToLower(*req.Description)
|
description := strings.ToLower(*req.Description)
|
||||||
query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%")
|
query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%")
|
||||||
}
|
}
|
||||||
|
if req.ParentId != nil {
|
||||||
|
query = query.Where("parent_id = ?", req.ParentId)
|
||||||
|
}
|
||||||
|
if req.IsOnlyTop != nil {
|
||||||
|
if *req.IsOnlyTop == true {
|
||||||
|
query = query.Where("parent_id IS NULL")
|
||||||
|
}
|
||||||
|
}
|
||||||
query.Count(&count)
|
query.Count(&count)
|
||||||
|
|
||||||
if req.Pagination.SortBy != "" {
|
if req.Pagination.SortBy != "" {
|
||||||
|
|
@ -66,6 +84,43 @@ func (_i *ppidDataCategoriesRepository) GetAll(req request.PpidDataCategoriesQue
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// implement interface of IPpidDataCategoriesRepository
|
||||||
|
func (_i *ppidDataCategoriesRepository) GetAllNonPage(req request.PpidDataCategoriesQueryRequest) (ppidDataCategoriess []*entity.PpidDataCategories, paging paginator.Pagination, err error) {
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
_i.Log.Info().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:GetAll", "Interface:ppidDataCategoriesRepository").
|
||||||
|
Interface("req", req).Msg("")
|
||||||
|
|
||||||
|
query := _i.DB.DB.Model(&entity.PpidDataCategories{})
|
||||||
|
query = query.Where("is_active = ?", true)
|
||||||
|
|
||||||
|
if req.Title != nil && *req.Title != "" {
|
||||||
|
title := strings.ToLower(*req.Title)
|
||||||
|
query = query.Where("LOWER(title) LIKE ?", "%"+strings.ToLower(title)+"%")
|
||||||
|
}
|
||||||
|
if req.Description != nil && *req.Description != "" {
|
||||||
|
description := strings.ToLower(*req.Description)
|
||||||
|
query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%")
|
||||||
|
}
|
||||||
|
if req.ParentId != nil {
|
||||||
|
query = query.Where("parent_id = ?", req.ParentId)
|
||||||
|
}
|
||||||
|
if req.IsOnlyTop != nil {
|
||||||
|
if *req.IsOnlyTop == true {
|
||||||
|
query = query.Where("parent_id IS NULL")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.Count(&count)
|
||||||
|
|
||||||
|
err = query.Find(&ppidDataCategoriess).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (_i *ppidDataCategoriesRepository) FindOne(id uint) (ppidDataCategories *entity.PpidDataCategories, err error) {
|
func (_i *ppidDataCategoriesRepository) FindOne(id uint) (ppidDataCategories *entity.PpidDataCategories, err error) {
|
||||||
if err := _i.DB.DB.First(&ppidDataCategories, id).Error; err != nil {
|
if err := _i.DB.DB.First(&ppidDataCategories, id).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -74,6 +129,14 @@ func (_i *ppidDataCategoriesRepository) FindOne(id uint) (ppidDataCategories *en
|
||||||
return ppidDataCategories, nil
|
return ppidDataCategories, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_i *ppidDataCategoriesRepository) FindOneBySlug(slug string) (ppidDataCategories *entity.PpidDataCategories, err error) {
|
||||||
|
if err := _i.DB.DB.Where("slug = ?", slug).First(&ppidDataCategories).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ppidDataCategories, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (_i *ppidDataCategoriesRepository) Create(ppidDataCategories *entity.PpidDataCategories) (err error) {
|
func (_i *ppidDataCategoriesRepository) Create(ppidDataCategories *entity.PpidDataCategories) (err error) {
|
||||||
return _i.DB.DB.Create(ppidDataCategories).Error
|
return _i.DB.DB.Create(ppidDataCategories).Error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package request
|
||||||
import (
|
import (
|
||||||
"go-humas-be/app/database/entity"
|
"go-humas-be/app/database/entity"
|
||||||
"go-humas-be/utils/paginator"
|
"go-humas-be/utils/paginator"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -13,6 +14,8 @@ type PpidDataCategoriesGeneric interface {
|
||||||
type PpidDataCategoriesQueryRequest struct {
|
type PpidDataCategoriesQueryRequest struct {
|
||||||
Title *string `json:"title"`
|
Title *string `json:"title"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
|
IsOnlyTop *bool `json:"isOnlyTop"`
|
||||||
|
ParentId *uint `json:"parentId"`
|
||||||
Pagination *paginator.Pagination `json:"pagination"`
|
Pagination *paginator.Pagination `json:"pagination"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,7 +23,7 @@ type PpidDataCategoriesCreateRequest struct {
|
||||||
Title string `json:"title" validate:"required"`
|
Title string `json:"title" validate:"required"`
|
||||||
Description string `json:"description" validate:"required"`
|
Description string `json:"description" validate:"required"`
|
||||||
Slug string `json:"slug" validate:"required"`
|
Slug string `json:"slug" validate:"required"`
|
||||||
ThumbnailPath *string `json:"thumbnailPath"`
|
ParentId *uint `json:"parentId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req PpidDataCategoriesCreateRequest) ToEntity() *entity.PpidDataCategories {
|
func (req PpidDataCategoriesCreateRequest) ToEntity() *entity.PpidDataCategories {
|
||||||
|
|
@ -28,7 +31,7 @@ func (req PpidDataCategoriesCreateRequest) ToEntity() *entity.PpidDataCategories
|
||||||
Title: req.Title,
|
Title: req.Title,
|
||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
Slug: req.Slug,
|
Slug: req.Slug,
|
||||||
ThumbnailPath: req.ThumbnailPath,
|
ParentId: req.ParentId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,7 +40,7 @@ type PpidDataCategoriesUpdateRequest struct {
|
||||||
Title string `json:"title" validate:"required"`
|
Title string `json:"title" validate:"required"`
|
||||||
Description string `json:"description" validate:"required"`
|
Description string `json:"description" validate:"required"`
|
||||||
Slug string `json:"slug" validate:"required"`
|
Slug string `json:"slug" validate:"required"`
|
||||||
ThumbnailPath *string `json:"thumbnailPath"`
|
ParentId *uint `json:"parentId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req PpidDataCategoriesUpdateRequest) ToEntity() *entity.PpidDataCategories {
|
func (req PpidDataCategoriesUpdateRequest) ToEntity() *entity.PpidDataCategories {
|
||||||
|
|
@ -46,7 +49,7 @@ func (req PpidDataCategoriesUpdateRequest) ToEntity() *entity.PpidDataCategories
|
||||||
Title: req.Title,
|
Title: req.Title,
|
||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
Slug: req.Slug,
|
Slug: req.Slug,
|
||||||
ThumbnailPath: req.ThumbnailPath,
|
ParentId: req.ParentId,
|
||||||
UpdatedAt: time.Now(),
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +57,8 @@ func (req PpidDataCategoriesUpdateRequest) ToEntity() *entity.PpidDataCategories
|
||||||
type PpidDataCategoriesQueryRequestContext struct {
|
type PpidDataCategoriesQueryRequestContext struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
IsOnlyTop string `json:"isOnlyTop"`
|
||||||
|
ParentId string `json:"parentId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req PpidDataCategoriesQueryRequestContext) ToParamRequest() PpidDataCategoriesQueryRequest {
|
func (req PpidDataCategoriesQueryRequestContext) ToParamRequest() PpidDataCategoriesQueryRequest {
|
||||||
|
|
@ -65,6 +70,18 @@ func (req PpidDataCategoriesQueryRequestContext) ToParamRequest() PpidDataCatego
|
||||||
if description := req.Description; description != "" {
|
if description := req.Description; description != "" {
|
||||||
request.Description = &description
|
request.Description = &description
|
||||||
}
|
}
|
||||||
|
if parentIdStr := req.ParentId; parentIdStr != "" {
|
||||||
|
parentId, err := strconv.ParseUint(parentIdStr, 10, 0)
|
||||||
|
if err == nil {
|
||||||
|
*request.ParentId = uint(parentId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if isOnlyTopStr := req.IsOnlyTop; isOnlyTopStr != "" {
|
||||||
|
isOnlyTop, err := strconv.ParseBool(isOnlyTopStr)
|
||||||
|
if err == nil {
|
||||||
|
request.IsOnlyTop = &isOnlyTop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,6 @@ type PpidDataCategoriesResponse struct {
|
||||||
IsActive *bool `json:"isActive"`
|
IsActive *bool `json:"isActive"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
|
||||||
|
Children []*PpidDataCategoriesResponse `json:"children"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ type ppidDataCategoriesService struct {
|
||||||
type PpidDataCategoriesService interface {
|
type PpidDataCategoriesService interface {
|
||||||
All(req request.PpidDataCategoriesQueryRequest) (ppidDataCategories []*response.PpidDataCategoriesResponse, paging paginator.Pagination, err error)
|
All(req request.PpidDataCategoriesQueryRequest) (ppidDataCategories []*response.PpidDataCategoriesResponse, paging paginator.Pagination, err error)
|
||||||
Show(id uint) (ppidDataCategories *response.PpidDataCategoriesResponse, err error)
|
Show(id uint) (ppidDataCategories *response.PpidDataCategoriesResponse, err error)
|
||||||
|
ShowBySlug(slug string) (ppidDataCategories *response.PpidDataCategoriesResponse, err error)
|
||||||
Save(req request.PpidDataCategoriesCreateRequest) (err error)
|
Save(req request.PpidDataCategoriesCreateRequest) (err error)
|
||||||
SaveThumbnail(c *fiber.Ctx) (err error)
|
SaveThumbnail(c *fiber.Ctx) (err error)
|
||||||
Update(id uint, req request.PpidDataCategoriesUpdateRequest) (err error)
|
Update(id uint, req request.PpidDataCategoriesUpdateRequest) (err error)
|
||||||
|
|
@ -57,7 +58,7 @@ func (_i *ppidDataCategoriesService) All(req request.PpidDataCategoriesQueryRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
ppidDataCategoriess = append(ppidDataCategoriess, mapper.PpidDataCategoriesResponseMapper(result))
|
ppidDataCategoriess = append(ppidDataCategoriess, mapper.PpidDataCategoriesResponseMapper(result, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -69,7 +70,34 @@ func (_i *ppidDataCategoriesService) Show(id uint) (ppidDataCategories *response
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapper.PpidDataCategoriesResponseMapper(result), nil
|
req := request.PpidDataCategoriesQueryRequest{
|
||||||
|
ParentId: &result.ID,
|
||||||
|
}
|
||||||
|
_i.Log.Info().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:Show", "Interface:ppidDataCategoriesService").
|
||||||
|
Interface("req", req).Msg("")
|
||||||
|
|
||||||
|
subResult, _, _ := _i.Repo.GetAllNonPage(req)
|
||||||
|
|
||||||
|
_i.Log.Info().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:Show", "Interface:ppidDataCategoriesService").
|
||||||
|
Interface("res", subResult).Msg("")
|
||||||
|
|
||||||
|
return mapper.PpidDataCategoriesResponseMapper(result, subResult), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_i *ppidDataCategoriesService) ShowBySlug(slug string) (ppidDataCategories *response.PpidDataCategoriesResponse, err error) {
|
||||||
|
result, err := _i.Repo.FindOneBySlug(slug)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req := request.PpidDataCategoriesQueryRequest{
|
||||||
|
ParentId: result.ParentId,
|
||||||
|
}
|
||||||
|
subResult, _, _ := _i.Repo.GetAll(req)
|
||||||
|
|
||||||
|
return mapper.PpidDataCategoriesResponseMapper(result, subResult), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *ppidDataCategoriesService) Save(req request.PpidDataCategoriesCreateRequest) (err error) {
|
func (_i *ppidDataCategoriesService) Save(req request.PpidDataCategoriesCreateRequest) (err error) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ production = false
|
||||||
|
|
||||||
[db.postgres]
|
[db.postgres]
|
||||||
dsn = "postgresql://humas_polri:P@ssw0rd.1@103.82.242.92:5432/humas_polri" # <driver>://<username>:<password>@<host>:<port>/<database>
|
dsn = "postgresql://humas_polri:P@ssw0rd.1@103.82.242.92:5432/humas_polri" # <driver>://<username>:<password>@<host>:<port>/<database>
|
||||||
migrate = true
|
migrate = false
|
||||||
seed = false
|
seed = false
|
||||||
|
|
||||||
[logger]
|
[logger]
|
||||||
|
|
|
||||||
|
|
@ -3638,6 +3638,16 @@ const docTemplate = `{
|
||||||
"name": "description",
|
"name": "description",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"name": "isOnlyTop",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "parentId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"name": "title",
|
"name": "title",
|
||||||
|
|
@ -3761,6 +3771,55 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/ppid-data-categories/slug/{slug}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting one PpidDataCategories",
|
||||||
|
"tags": [
|
||||||
|
"PPID Categories"
|
||||||
|
],
|
||||||
|
"summary": "Get one PpidDataCategories",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "PpidDataCategories 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/ppid-data-categories/thumbnail/viewer/{id}": {
|
"/ppid-data-categories/thumbnail/viewer/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -6922,10 +6981,10 @@ const docTemplate = `{
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"slug": {
|
"parentId": {
|
||||||
"type": "string"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"thumbnailPath": {
|
"slug": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
@ -6948,10 +7007,10 @@ const docTemplate = `{
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"slug": {
|
"parentId": {
|
||||||
"type": "string"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"thumbnailPath": {
|
"slug": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
|
||||||
|
|
@ -3627,6 +3627,16 @@
|
||||||
"name": "description",
|
"name": "description",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"name": "isOnlyTop",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "parentId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"name": "title",
|
"name": "title",
|
||||||
|
|
@ -3750,6 +3760,55 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/ppid-data-categories/slug/{slug}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Bearer": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "API for getting one PpidDataCategories",
|
||||||
|
"tags": [
|
||||||
|
"PPID Categories"
|
||||||
|
],
|
||||||
|
"summary": "Get one PpidDataCategories",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "PpidDataCategories 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/ppid-data-categories/thumbnail/viewer/{id}": {
|
"/ppid-data-categories/thumbnail/viewer/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -6911,10 +6970,10 @@
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"slug": {
|
"parentId": {
|
||||||
"type": "string"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"thumbnailPath": {
|
"slug": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
@ -6937,10 +6996,10 @@
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"slug": {
|
"parentId": {
|
||||||
"type": "string"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"thumbnailPath": {
|
"slug": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
|
||||||
|
|
@ -258,10 +258,10 @@ definitions:
|
||||||
properties:
|
properties:
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
|
parentId:
|
||||||
|
type: integer
|
||||||
slug:
|
slug:
|
||||||
type: string
|
type: string
|
||||||
thumbnailPath:
|
|
||||||
type: string
|
|
||||||
title:
|
title:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
|
|
@ -275,10 +275,10 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
|
parentId:
|
||||||
|
type: integer
|
||||||
slug:
|
slug:
|
||||||
type: string
|
type: string
|
||||||
thumbnailPath:
|
|
||||||
type: string
|
|
||||||
title:
|
title:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
|
|
@ -2926,6 +2926,12 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: description
|
name: description
|
||||||
type: string
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: isOnlyTop
|
||||||
|
type: boolean
|
||||||
|
- in: query
|
||||||
|
name: parentId
|
||||||
|
type: integer
|
||||||
- in: query
|
- in: query
|
||||||
name: title
|
name: title
|
||||||
type: string
|
type: string
|
||||||
|
|
@ -3103,6 +3109,37 @@ paths:
|
||||||
summary: Update PpidDataCategories
|
summary: Update PpidDataCategories
|
||||||
tags:
|
tags:
|
||||||
- PPID Categories
|
- PPID Categories
|
||||||
|
/ppid-data-categories/slug/{slug}:
|
||||||
|
get:
|
||||||
|
description: API for getting one PpidDataCategories
|
||||||
|
parameters:
|
||||||
|
- description: PpidDataCategories 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 PpidDataCategories
|
||||||
|
tags:
|
||||||
|
- PPID Categories
|
||||||
/ppid-data-categories/thumbnail/{id}:
|
/ppid-data-categories/thumbnail/{id}:
|
||||||
post:
|
post:
|
||||||
description: API for Upload PpidDataCategories Thumbnail
|
description: API for Upload PpidDataCategories Thumbnail
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue