feat: fixing ppid data categories

This commit is contained in:
hanif salafi 2024-05-15 13:52:42 +07:00
parent 960d21a2ee
commit eef2822c2b
2 changed files with 10 additions and 1 deletions

View File

@ -2,10 +2,12 @@ package controller
import ( import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/rs/zerolog"
"go-humas-be/app/module/ppid_data_categories/request" "go-humas-be/app/module/ppid_data_categories/request"
"go-humas-be/app/module/ppid_data_categories/service" "go-humas-be/app/module/ppid_data_categories/service"
"go-humas-be/utils/paginator" "go-humas-be/utils/paginator"
"strconv" "strconv"
"time"
utilRes "go-humas-be/utils/response" utilRes "go-humas-be/utils/response"
utilVal "go-humas-be/utils/validator" utilVal "go-humas-be/utils/validator"
@ -13,6 +15,7 @@ import (
type ppidDataCategoriesController struct { type ppidDataCategoriesController struct {
ppidDataCategoriesService service.PpidDataCategoriesService ppidDataCategoriesService service.PpidDataCategoriesService
Log zerolog.Logger
} }
type PpidDataCategoriesController interface { type PpidDataCategoriesController interface {
@ -57,6 +60,11 @@ func (_i *ppidDataCategoriesController) All(c *fiber.Ctx) error {
IsOnlyTop: c.Query("isOnlyTop"), IsOnlyTop: c.Query("isOnlyTop"),
} }
req := reqContext.ToParamRequest() req := reqContext.ToParamRequest()
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service:All", "ppidDataCategoriesController").
Interface("req", req).Msg("")
req.Pagination = paginate req.Pagination = paginate
ppidDataCategoriesData, paging, err := _i.ppidDataCategoriesService.All(req) ppidDataCategoriesData, paging, err := _i.ppidDataCategoriesService.All(req)

View File

@ -72,8 +72,9 @@ func (req PpidDataCategoriesQueryRequestContext) ToParamRequest() PpidDataCatego
} }
if parentIdStr := req.ParentId; parentIdStr != "" { if parentIdStr := req.ParentId; parentIdStr != "" {
parentId, err := strconv.ParseUint(parentIdStr, 10, 0) parentId, err := strconv.ParseUint(parentIdStr, 10, 0)
parentIdUint := uint(parentId)
if err == nil { if err == nil {
*request.ParentId = uint(parentId) request.ParentId = &parentIdUint
} }
} }
if isOnlyTopStr := req.IsOnlyTop; isOnlyTopStr != "" { if isOnlyTopStr := req.IsOnlyTop; isOnlyTopStr != "" {