feat: update for position in ppid data, files, category
This commit is contained in:
parent
89761a5c89
commit
c3946bdd81
|
|
@ -6,11 +6,9 @@ import (
|
||||||
"go-humas-be/app/module/ppid_data_files/request"
|
"go-humas-be/app/module/ppid_data_files/request"
|
||||||
"go-humas-be/app/module/ppid_data_files/service"
|
"go-humas-be/app/module/ppid_data_files/service"
|
||||||
"go-humas-be/utils/paginator"
|
"go-humas-be/utils/paginator"
|
||||||
"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"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ppidDataFilesController struct {
|
type ppidDataFilesController struct {
|
||||||
|
|
@ -167,8 +165,8 @@ func (_i *ppidDataFilesController) Update(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePosition PpidDataFiles
|
// UpdatePosition PpidDataFiles
|
||||||
// @Summary UpdatePosition PpidDataFiles
|
// @Summary updatePosition PpidDataFiles
|
||||||
// @Description API for Update Position PpidDataFiles
|
// @Description API for PpidDataFiles
|
||||||
// @Tags PPID Files
|
// @Tags PPID Files
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
// @Param payload body request.PpidDataFilesUpdatePositionPayload true "Required payload"
|
// @Param payload body request.PpidDataFilesUpdatePositionPayload true "Required payload"
|
||||||
|
|
@ -176,31 +174,17 @@ func (_i *ppidDataFilesController) Update(c *fiber.Ctx) error {
|
||||||
// @Failure 400 {object} response.BadRequestError
|
// @Failure 400 {object} response.BadRequestError
|
||||||
// @Failure 401 {object} response.UnauthorizedError
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
// @Failure 500 {object} response.InternalServerError
|
// @Failure 500 {object} response.InternalServerError
|
||||||
// @Router /ppid-data-files/position [post]
|
// @Router /ppid-data-files/update/position [post]
|
||||||
func (_i *ppidDataFilesController) UpdatePosition(c *fiber.Ctx) error {
|
func (_i *ppidDataFilesController) UpdatePosition(c *fiber.Ctx) error {
|
||||||
|
req := new(request.PpidDataFilesUpdatePositionPayload)
|
||||||
|
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
_i.Log.Info().Str("timestamp", time.Now().
|
err := _i.ppidDataFilesService.UpdatePosition(req.Positions)
|
||||||
Format(time.RFC3339)).Str("Service:All", "ppidDataFilesController").
|
if err != nil {
|
||||||
Interface("req", "TEST").Msg("")
|
return err
|
||||||
|
}
|
||||||
//req := new(request.PpidDataFilesUpdatePositionPayload)
|
|
||||||
//
|
|
||||||
//_i.Log.Info().Str("timestamp", time.Now().
|
|
||||||
// Format(time.RFC3339)).Str("Service:All", "ppidDataCategoriesController").
|
|
||||||
// Interface("req", "TEST").Msg("")
|
|
||||||
//
|
|
||||||
//if err := utilVal.ParseAndValidate(c, req); err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//_i.Log.Info().Str("timestamp", time.Now().
|
|
||||||
// Format(time.RFC3339)).Str("Service:All", "ppidDataCategoriesController").
|
|
||||||
// Interface("req", req).Msg("")
|
|
||||||
//
|
|
||||||
//err := _i.ppidDataFilesService.UpdatePosition(req.Positions)
|
|
||||||
//if err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
|
|
||||||
return utilRes.Resp(c, utilRes.Response{
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
Success: true,
|
Success: true,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ func PpidDataFilesResponseMapper(ppidDataFilesReq *entity.PpidDataFiles) (ppidDa
|
||||||
FileUrl: fileUrl,
|
FileUrl: fileUrl,
|
||||||
FileType: ppidDataFilesReq.FileType,
|
FileType: ppidDataFilesReq.FileType,
|
||||||
DownloadCount: ppidDataFilesReq.DownloadCount,
|
DownloadCount: ppidDataFilesReq.DownloadCount,
|
||||||
|
Position: ppidDataFilesReq.Position,
|
||||||
CreatedById: ppidDataFilesReq.CreatedById,
|
CreatedById: ppidDataFilesReq.CreatedById,
|
||||||
StatusId: ppidDataFilesReq.StatusId,
|
StatusId: ppidDataFilesReq.StatusId,
|
||||||
IsPublish: ppidDataFilesReq.IsPublish,
|
IsPublish: ppidDataFilesReq.IsPublish,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func (_i *PpidDataFilesRouter) RegisterPpidDataFilesRoutes() {
|
||||||
router.Get("/:id", ppidDataFilesController.Show)
|
router.Get("/:id", ppidDataFilesController.Show)
|
||||||
router.Post("/:ppidDataId", ppidDataFilesController.Save)
|
router.Post("/:ppidDataId", ppidDataFilesController.Save)
|
||||||
router.Put("/:id", ppidDataFilesController.Update)
|
router.Put("/:id", ppidDataFilesController.Update)
|
||||||
router.Post("/position", ppidDataFilesController.UpdatePosition)
|
router.Post("/update/position", ppidDataFilesController.UpdatePosition)
|
||||||
router.Delete("/:id", ppidDataFilesController.Delete)
|
router.Delete("/:id", ppidDataFilesController.Delete)
|
||||||
router.Get("/viewer/:filename", ppidDataFilesController.Viewer)
|
router.Get("/viewer/:filename", ppidDataFilesController.Viewer)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,8 @@ type PpidDataFilesUpdatePositionPayload struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PpidDataFilesUpdatePositionRequest struct {
|
type PpidDataFilesUpdatePositionRequest struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id" validate:"required"`
|
||||||
Position int `json:"position"`
|
Position int `json:"position" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req PpidDataFilesUpdatePositionRequest) ToEntity() *entity.PpidDataFiles {
|
func (req PpidDataFilesUpdatePositionRequest) ToEntity() *entity.PpidDataFiles {
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,11 @@ type PpidDataFilesResponse struct {
|
||||||
FileUrl string `json:"fileUrl"`
|
FileUrl string `json:"fileUrl"`
|
||||||
DownloadCount *int `json:"downloadCount"`
|
DownloadCount *int `json:"downloadCount"`
|
||||||
CreatedById *int `json:"createdById"`
|
CreatedById *int `json:"createdById"`
|
||||||
StatusId *int `json:"status_id"`
|
Position *int `json:"position"`
|
||||||
IsPublish *bool `json:"is_publish"`
|
StatusId *int `json:"statusId"`
|
||||||
PublishedAt *time.Time `json:"published_at"`
|
IsPublish *bool `json:"isPublish"`
|
||||||
IsActive *bool `json:"is_active"`
|
PublishedAt *time.Time `json:"publishedAt"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
IsActive *bool `json:"isActive"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ func PpidDatasResponseMapper(
|
||||||
CategoryName: &categoryName,
|
CategoryName: &categoryName,
|
||||||
CreatedById: ppidDatasReq.CreatedById,
|
CreatedById: ppidDatasReq.CreatedById,
|
||||||
CreatedByName: &createdByName,
|
CreatedByName: &createdByName,
|
||||||
|
Position: ppidDatasReq.Position,
|
||||||
StatusId: ppidDatasReq.StatusId,
|
StatusId: ppidDatasReq.StatusId,
|
||||||
IsPublish: ppidDatasReq.IsPublish,
|
IsPublish: ppidDatasReq.IsPublish,
|
||||||
PublishedAt: ppidDatasReq.PublishedAt,
|
PublishedAt: ppidDatasReq.PublishedAt,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type PpidDatasResponse struct {
|
||||||
StatusId int `json:"statusId"`
|
StatusId int `json:"statusId"`
|
||||||
StatusName int `json:"statusName"`
|
StatusName int `json:"statusName"`
|
||||||
IsPublish *bool `json:"isPublish"`
|
IsPublish *bool `json:"isPublish"`
|
||||||
|
Position *int `json:"position"`
|
||||||
PublishedAt *time.Time `json:"publishedAt"`
|
PublishedAt *time.Time `json:"publishedAt"`
|
||||||
IsActive *bool `json:"isActive"`
|
IsActive *bool `json:"isActive"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
|
|
||||||
|
|
@ -4253,18 +4253,18 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/ppid-data-files/position": {
|
"/ppid-data-files/update/position": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for Update Position PpidDataFiles",
|
"description": "API for PpidDataFiles",
|
||||||
"tags": [
|
"tags": [
|
||||||
"PPID Files"
|
"PPID Files"
|
||||||
],
|
],
|
||||||
"summary": "UpdatePosition PpidDataFiles",
|
"summary": "updatePosition PpidDataFiles",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"description": "Required payload",
|
||||||
|
|
@ -7223,6 +7223,10 @@ const docTemplate = `{
|
||||||
},
|
},
|
||||||
"request.PpidDataFilesUpdatePositionRequest": {
|
"request.PpidDataFilesUpdatePositionRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"position"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
|
|
||||||
|
|
@ -4242,18 +4242,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/ppid-data-files/position": {
|
"/ppid-data-files/update/position": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for Update Position PpidDataFiles",
|
"description": "API for PpidDataFiles",
|
||||||
"tags": [
|
"tags": [
|
||||||
"PPID Files"
|
"PPID Files"
|
||||||
],
|
],
|
||||||
"summary": "UpdatePosition PpidDataFiles",
|
"summary": "updatePosition PpidDataFiles",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"description": "Required payload",
|
||||||
|
|
@ -7212,6 +7212,10 @@
|
||||||
},
|
},
|
||||||
"request.PpidDataFilesUpdatePositionRequest": {
|
"request.PpidDataFilesUpdatePositionRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"position"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,9 @@ definitions:
|
||||||
type: integer
|
type: integer
|
||||||
position:
|
position:
|
||||||
type: integer
|
type: integer
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- position
|
||||||
type: object
|
type: object
|
||||||
request.PpidDataFilesUpdateRequest:
|
request.PpidDataFilesUpdateRequest:
|
||||||
properties:
|
properties:
|
||||||
|
|
@ -3476,9 +3479,9 @@ paths:
|
||||||
summary: Create PpidDataFiles
|
summary: Create PpidDataFiles
|
||||||
tags:
|
tags:
|
||||||
- PPID Files
|
- PPID Files
|
||||||
/ppid-data-files/position:
|
/ppid-data-files/update/position:
|
||||||
post:
|
post:
|
||||||
description: API for Update Position PpidDataFiles
|
description: API for PpidDataFiles
|
||||||
parameters:
|
parameters:
|
||||||
- description: Required payload
|
- description: Required payload
|
||||||
in: body
|
in: body
|
||||||
|
|
@ -3505,7 +3508,7 @@ paths:
|
||||||
$ref: '#/definitions/response.InternalServerError'
|
$ref: '#/definitions/response.InternalServerError'
|
||||||
security:
|
security:
|
||||||
- Bearer: []
|
- Bearer: []
|
||||||
summary: UpdatePosition PpidDataFiles
|
summary: updatePosition PpidDataFiles
|
||||||
tags:
|
tags:
|
||||||
- PPID Files
|
- PPID Files
|
||||||
/ppid-data-files/viewer/{filename}:
|
/ppid-data-files/viewer/{filename}:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue