feat: update ppid data approval
This commit is contained in:
parent
4013617092
commit
fb56849f7e
|
|
@ -6,10 +6,10 @@ type PpidDataApprovalHistories struct {
|
|||
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
||||
Message string `json:"message" gorm:"type:varchar"`
|
||||
ApprovalStatusId int `json:"approval_status_id" gorm:"type:int4"`
|
||||
PpidDataId int `json:"ppid_data_id" gorm:"type:int4"`
|
||||
ApprovalBy int `json:"approval_by" gorm:"type:int4"`
|
||||
PpidDataId uint `json:"ppid_data_id" gorm:"type:int4"`
|
||||
ApprovalBy uint `json:"approval_by" gorm:"type:int4"`
|
||||
ApprovalAtLevel int `json:"approval_at_level" gorm:"type:int4"`
|
||||
IsActive bool `json:"is_active" gorm:"type:bool"`
|
||||
IsActive bool `json:"is_active" gorm:"type:bool;default:true"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,15 @@ type PpidDatas struct {
|
|||
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
|
||||
LevelGroupId *int `json:"level_group_id" gorm:"type:int4"`
|
||||
Group *string `json:"group" gorm:"type:varchar"`
|
||||
StatusId int `json:"status_id" gorm:"type:int4"`
|
||||
NeedApprovalFrom *int `json:"need_approval_from" gorm:"type:int4"`
|
||||
BackApprovalTo *int `json:"back_approval_to" gorm:"type:int4"`
|
||||
NeedApprovalFromUserRole *string `json:"need_approval_from_user_role" gorm:"type:varchar"`
|
||||
NeedApprovalFromUserLevel *string `json:"need_approval_from_user_level" gorm:"type:varchar"`
|
||||
BackApprovalToUserRole *int `json:"back_approval_to_user_role" gorm:"type:varchar"`
|
||||
BackApprovalToUserLevel *int `json:"back_approval_to_user_level" gorm:"type:varchar"`
|
||||
IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"`
|
||||
PublishLevel *int `json:"publish_level" gorm:"type:int4"`
|
||||
PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"`
|
||||
ApprovalStatusId int `json:"approval_status_id" gorm:"type:int4"`
|
||||
StatusId int `json:"status_id" gorm:"type:int4"`
|
||||
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
||||
|
|
|
|||
|
|
@ -78,8 +78,10 @@ func Models() []interface{} {
|
|||
entity.MasterMenus{},
|
||||
entity.MasterModules{},
|
||||
entity.MasterStatuses{},
|
||||
entity.MasterApprovalStatuses{},
|
||||
entity.PpidDatas{},
|
||||
entity.PpidDataFiles{},
|
||||
entity.PpidDataApprovalHistories{},
|
||||
entity.PpidDataCategories{},
|
||||
entity.Provinces{},
|
||||
entity.UserLevels{},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"github.com/gofiber/fiber/v2"
|
||||
"go-humas-be/app/module/ppid_data_approval_histories/request"
|
||||
"go-humas-be/app/module/ppid_data_approval_histories/service"
|
||||
"go-humas-be/utils/paginator"
|
||||
"strconv"
|
||||
|
||||
utilRes "go-humas-be/utils/response"
|
||||
|
|
@ -18,8 +17,8 @@ type ppidDataApprovalHistoriesController struct {
|
|||
type PpidDataApprovalHistoriesController interface {
|
||||
All(c *fiber.Ctx) error
|
||||
Show(c *fiber.Ctx) error
|
||||
ShowByPpidData(c *fiber.Ctx) error
|
||||
Save(c *fiber.Ctx) error
|
||||
Update(c *fiber.Ctx) error
|
||||
Delete(c *fiber.Ctx) error
|
||||
}
|
||||
|
||||
|
|
@ -29,49 +28,39 @@ func NewPpidDataApprovalHistoriesController(ppidDataApprovalHistoriesService ser
|
|||
}
|
||||
}
|
||||
|
||||
// All get all PpidDataApprovalHistories
|
||||
// All PpidDataApprovalHistories
|
||||
// @Summary Get all PpidDataApprovalHistories
|
||||
// @Description API for getting all PpidDataApprovalHistories
|
||||
// @Tags Task
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
// @Failure 404 {object} response.Response
|
||||
// @Failure 422 {object} response.Response
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /ppid-data-approval-histories [get]
|
||||
func (_i *ppidDataApprovalHistoriesController) All(c *fiber.Ctx) error {
|
||||
paginate, err := paginator.Paginate(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var req request.PpidDataApprovalHistoriesQueryRequest
|
||||
req.Pagination = paginate
|
||||
|
||||
ppidDataApprovalHistoriesData, paging, err := _i.ppidDataApprovalHistoriesService.All(req)
|
||||
ppidDataApprovalHistoriesData, err := _i.ppidDataApprovalHistoriesService.All()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"PpidDataApprovalHistories list successfully retrieved"},
|
||||
Data: ppidDataApprovalHistoriesData,
|
||||
Meta: paging,
|
||||
})
|
||||
}
|
||||
|
||||
// Show get one PpidDataApprovalHistories
|
||||
// Show PpidDataApprovalHistories
|
||||
// @Summary Get one PpidDataApprovalHistories
|
||||
// @Description API for getting one PpidDataApprovalHistories
|
||||
// @Tags Task
|
||||
// @Security Bearer
|
||||
// @Param id path int true "PpidDataApprovalHistories ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
// @Failure 404 {object} response.Response
|
||||
// @Failure 422 {object} response.Response
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /ppid-data-approval-histories/:id [get]
|
||||
func (_i *ppidDataApprovalHistoriesController) Show(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
||||
|
|
@ -85,6 +74,36 @@ func (_i *ppidDataApprovalHistoriesController) Show(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"PpidDataApprovalHistories successfully retrieved"},
|
||||
Data: ppidDataApprovalHistoriesData,
|
||||
})
|
||||
}
|
||||
|
||||
// ShowByPpidData PpidDataApprovalHistories
|
||||
// @Summary Get one PpidDataApprovalHistories
|
||||
// @Description API for getting one PpidDataApprovalHistories
|
||||
// @Tags Task
|
||||
// @Security Bearer
|
||||
// @Param ppidDataId path int true "PpidData ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /ppid-data-approval-histories/ppid-data/:ppidDataId [get]
|
||||
func (_i *ppidDataApprovalHistoriesController) ShowByPpidData(c *fiber.Ctx) error {
|
||||
ppidDataId, err := strconv.Atoi(c.Params("ppidDataId"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ppidDataApprovalHistoriesData, err := _i.ppidDataApprovalHistoriesService.ShowByPpidData(uint(ppidDataId))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"PpidDataApprovalHistories successfully retrieved"},
|
||||
Data: ppidDataApprovalHistoriesData,
|
||||
})
|
||||
|
|
@ -95,6 +114,7 @@ func (_i *ppidDataApprovalHistoriesController) Show(c *fiber.Ctx) error {
|
|||
// @Description API for create PpidDataApprovalHistories
|
||||
// @Tags Task
|
||||
// @Security Bearer
|
||||
// @Param Authorization header string true "Insert your access token" default(Bearer <Add access token here>)
|
||||
// @Body request.PpidDataApprovalHistoriesCreateRequest
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
|
|
@ -108,7 +128,9 @@ func (_i *ppidDataApprovalHistoriesController) Save(c *fiber.Ctx) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err := _i.ppidDataApprovalHistoriesService.Save(*req)
|
||||
authToken := c.Get("Authorization")
|
||||
|
||||
err := _i.ppidDataApprovalHistoriesService.Save(*req, authToken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -118,40 +140,6 @@ func (_i *ppidDataApprovalHistoriesController) Save(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
// Update update PpidDataApprovalHistories
|
||||
// @Summary update PpidDataApprovalHistories
|
||||
// @Description API for update PpidDataApprovalHistories
|
||||
// @Tags Task
|
||||
// @Security Bearer
|
||||
// @Body request.PpidDataApprovalHistoriesUpdateRequest
|
||||
// @Param id path int true "PpidDataApprovalHistories ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 401 {object} response.Response
|
||||
// @Failure 404 {object} response.Response
|
||||
// @Failure 422 {object} response.Response
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Router /ppid-data-approval-histories/:id [put]
|
||||
func (_i *ppidDataApprovalHistoriesController) Update(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := new(request.PpidDataApprovalHistoriesUpdateRequest)
|
||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = _i.ppidDataApprovalHistoriesService.Update(uint(id), *req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Messages: utilRes.Messages{"PpidDataApprovalHistories successfully updated"},
|
||||
})
|
||||
}
|
||||
|
||||
// Delete delete PpidDataApprovalHistories
|
||||
// @Summary delete PpidDataApprovalHistories
|
||||
// @Description API for delete PpidDataApprovalHistories
|
||||
|
|
|
|||
|
|
@ -3,16 +3,25 @@ package mapper
|
|||
import (
|
||||
"go-humas-be/app/database/entity"
|
||||
res "go-humas-be/app/module/ppid_data_approval_histories/response"
|
||||
|
||||
usersRepository "go-humas-be/app/module/users/repository"
|
||||
)
|
||||
|
||||
func PpidDataApprovalHistoriesResponseMapper(ppidDataApprovalHistoriesReq *entity.PpidDataApprovalHistories) (ppidDataApprovalHistoriesRes *res.PpidDataApprovalHistoriesResponse) {
|
||||
func PpidDataApprovalHistoriesResponseMapper(ppidDataApprovalHistoriesReq *entity.PpidDataApprovalHistories, usersRepo usersRepository.UsersRepository) (ppidDataApprovalHistoriesRes *res.PpidDataApprovalHistoriesResponse) {
|
||||
if ppidDataApprovalHistoriesReq != nil {
|
||||
findUser, _ := usersRepo.FindOne(ppidDataApprovalHistoriesReq.ApprovalBy)
|
||||
createdByName := ""
|
||||
if findUser != nil {
|
||||
createdByName = findUser.Fullname
|
||||
}
|
||||
|
||||
ppidDataApprovalHistoriesRes = &res.PpidDataApprovalHistoriesResponse{
|
||||
ID: ppidDataApprovalHistoriesReq.ID,
|
||||
Message: ppidDataApprovalHistoriesReq.Message,
|
||||
ApprovalStatusId: ppidDataApprovalHistoriesReq.ApprovalStatusId,
|
||||
PpidDataId: ppidDataApprovalHistoriesReq.PpidDataId,
|
||||
ApprovalBy: ppidDataApprovalHistoriesReq.ApprovalBy,
|
||||
ApprovalById: ppidDataApprovalHistoriesReq.ApprovalBy,
|
||||
ApprovalByName: createdByName,
|
||||
ApprovalAtLevel: ppidDataApprovalHistoriesReq.ApprovalAtLevel,
|
||||
IsActive: ppidDataApprovalHistoriesReq.IsActive,
|
||||
CreatedAt: ppidDataApprovalHistoriesReq.CreatedAt,
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ func (_i *PpidDataApprovalHistoriesRouter) RegisterPpidDataApprovalHistoriesRout
|
|||
_i.App.Route("/ppid-data-approval-histories", func(router fiber.Router) {
|
||||
router.Get("/", ppidDataApprovalHistoriesController.All)
|
||||
router.Get("/:id", ppidDataApprovalHistoriesController.Show)
|
||||
router.Get("/ppid-data/:ppidDataId", ppidDataApprovalHistoriesController.ShowByPpidData)
|
||||
router.Post("/", ppidDataApprovalHistoriesController.Save)
|
||||
router.Put("/:id", ppidDataApprovalHistoriesController.Update)
|
||||
router.Delete("/:id", ppidDataApprovalHistoriesController.Delete)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package repository
|
|||
import (
|
||||
"go-humas-be/app/database"
|
||||
"go-humas-be/app/database/entity"
|
||||
"go-humas-be/app/module/ppid_data_approval_histories/request"
|
||||
"go-humas-be/utils/paginator"
|
||||
)
|
||||
|
||||
type ppidDataApprovalHistoriesRepository struct {
|
||||
|
|
@ -13,8 +11,9 @@ type ppidDataApprovalHistoriesRepository struct {
|
|||
|
||||
// PpidDataApprovalHistoriesRepository define interface of IPpidDataApprovalHistoriesRepository
|
||||
type PpidDataApprovalHistoriesRepository interface {
|
||||
GetAll(req request.PpidDataApprovalHistoriesQueryRequest) (ppidDataApprovalHistoriess []*entity.PpidDataApprovalHistories, paging paginator.Pagination, err error)
|
||||
GetAll() (ppidDataApprovalHistories []*entity.PpidDataApprovalHistories, err error)
|
||||
FindOne(id uint) (ppidDataApprovalHistories *entity.PpidDataApprovalHistories, err error)
|
||||
FindByPpidData(ppidDataId uint) (ppidDataApprovalHistories []*entity.PpidDataApprovalHistories, err error)
|
||||
Create(ppidDataApprovalHistories *entity.PpidDataApprovalHistories) (err error)
|
||||
Update(id uint, ppidDataApprovalHistories *entity.PpidDataApprovalHistories) (err error)
|
||||
Delete(id uint) (err error)
|
||||
|
|
@ -27,23 +26,13 @@ func NewPpidDataApprovalHistoriesRepository(db *database.Database) PpidDataAppro
|
|||
}
|
||||
|
||||
// implement interface of IPpidDataApprovalHistoriesRepository
|
||||
func (_i *ppidDataApprovalHistoriesRepository) GetAll(req request.PpidDataApprovalHistoriesQueryRequest) (ppidDataApprovalHistoriess []*entity.PpidDataApprovalHistories, paging paginator.Pagination, err error) {
|
||||
var count int64
|
||||
|
||||
query := _i.DB.DB.Model(&entity.PpidDataApprovalHistories{})
|
||||
query.Count(&count)
|
||||
|
||||
req.Pagination.Count = count
|
||||
req.Pagination = paginator.Paging(req.Pagination)
|
||||
|
||||
err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&ppidDataApprovalHistoriess).Error
|
||||
if err != nil {
|
||||
return
|
||||
func (_i *ppidDataApprovalHistoriesRepository) GetAll() (ppidDataApprovalHistories []*entity.PpidDataApprovalHistories, err error) {
|
||||
if err := _i.DB.DB.Find(&ppidDataApprovalHistories).
|
||||
Where(&entity.PpidDataApprovalHistories{IsActive: true}).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
paging = *req.Pagination
|
||||
|
||||
return
|
||||
return ppidDataApprovalHistories, nil
|
||||
}
|
||||
|
||||
func (_i *ppidDataApprovalHistoriesRepository) FindOne(id uint) (ppidDataApprovalHistories *entity.PpidDataApprovalHistories, err error) {
|
||||
|
|
@ -54,6 +43,15 @@ func (_i *ppidDataApprovalHistoriesRepository) FindOne(id uint) (ppidDataApprova
|
|||
return ppidDataApprovalHistories, nil
|
||||
}
|
||||
|
||||
func (_i *ppidDataApprovalHistoriesRepository) FindByPpidData(ppidDataId uint) (ppidDataApprovalHistories []*entity.PpidDataApprovalHistories, err error) {
|
||||
if err := _i.DB.DB.Find(&ppidDataApprovalHistories).
|
||||
Where(&entity.PpidDataApprovalHistories{PpidDataId: ppidDataId, IsActive: true}).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ppidDataApprovalHistories, nil
|
||||
}
|
||||
|
||||
func (_i *ppidDataApprovalHistoriesRepository) Create(ppidDataApprovalHistories *entity.PpidDataApprovalHistories) (err error) {
|
||||
return _i.DB.DB.Create(ppidDataApprovalHistories).Error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,66 +2,24 @@ package request
|
|||
|
||||
import (
|
||||
"go-humas-be/app/database/entity"
|
||||
"go-humas-be/utils/paginator"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PpidDataApprovalHistoriesGeneric interface {
|
||||
ToEntity()
|
||||
}
|
||||
|
||||
type PpidDataApprovalHistoriesQueryRequest struct {
|
||||
Message string `json:"message" validate:"required"`
|
||||
ApprovalStatusId int `json:"approval_status_id" validate:"required"`
|
||||
PpidDataId int `json:"ppid_data_id" validate:"required"`
|
||||
ApprovalBy int `json:"approval_by" validate:"required"`
|
||||
ApprovalAtLevel int `json:"approval_at_level" validate:"required"`
|
||||
IsActive bool `json:"is_active" validate:"required"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type PpidDataApprovalHistoriesCreateRequest struct {
|
||||
PpidDataId uint `json:"ppidDataId" validate:"required"`
|
||||
Message string `json:"message" validate:"required"`
|
||||
ApprovalStatusId int `json:"approval_status_id" validate:"required"`
|
||||
PpidDataId int `json:"ppid_data_id" validate:"required"`
|
||||
ApprovalBy int `json:"approval_by" validate:"required"`
|
||||
ApprovalAtLevel int `json:"approval_at_level" validate:"required"`
|
||||
IsActive bool `json:"is_active" validate:"required"`
|
||||
ApprovalStatusId int `json:"approvalStatusId" validate:"required"`
|
||||
ApprovalAtLevel int `json:"approvalAtLevel" validate:"required"`
|
||||
}
|
||||
|
||||
func (req PpidDataApprovalHistoriesCreateRequest) ToEntity() *entity.PpidDataApprovalHistories {
|
||||
return &entity.PpidDataApprovalHistories{
|
||||
PpidDataId: req.PpidDataId,
|
||||
Message: req.Message,
|
||||
ApprovalStatusId: req.ApprovalStatusId,
|
||||
PpidDataId: req.PpidDataId,
|
||||
ApprovalBy: req.ApprovalBy,
|
||||
ApprovalAtLevel: req.ApprovalAtLevel,
|
||||
IsActive: req.IsActive,
|
||||
}
|
||||
}
|
||||
|
||||
type PpidDataApprovalHistoriesUpdateRequest struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
Message string `json:"message" validate:"required"`
|
||||
ApprovalStatusId int `json:"approval_status_id" validate:"required"`
|
||||
PpidDataId int `json:"ppid_data_id" validate:"required"`
|
||||
ApprovalBy int `json:"approval_by" validate:"required"`
|
||||
ApprovalAtLevel int `json:"approval_at_level" validate:"required"`
|
||||
IsActive bool `json:"is_active" validate:"required"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (req PpidDataApprovalHistoriesUpdateRequest) ToEntity() *entity.PpidDataApprovalHistories {
|
||||
return &entity.PpidDataApprovalHistories{
|
||||
ID: req.ID,
|
||||
Message: req.Message,
|
||||
ApprovalStatusId: req.ApprovalStatusId,
|
||||
PpidDataId: req.PpidDataId,
|
||||
ApprovalBy: req.ApprovalBy,
|
||||
ApprovalAtLevel: req.ApprovalAtLevel,
|
||||
IsActive: req.IsActive,
|
||||
CreatedAt: req.CreatedAt,
|
||||
UpdatedAt: req.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ type PpidDataApprovalHistoriesResponse struct {
|
|||
ID uint `json:"id"`
|
||||
Message string `json:"message"`
|
||||
ApprovalStatusId int `json:"approval_status_id"`
|
||||
PpidDataId int `json:"ppid_data_id"`
|
||||
ApprovalBy int `json:"approval_by"`
|
||||
PpidDataId uint `json:"ppid_data_id"`
|
||||
ApprovalById uint `json:"approval_by_id"`
|
||||
ApprovalByName string `json:"approval_by_name"`
|
||||
ApprovalAtLevel int `json:"approval_at_level"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
|
|
|
|||
|
|
@ -6,42 +6,45 @@ import (
|
|||
"go-humas-be/app/module/ppid_data_approval_histories/repository"
|
||||
"go-humas-be/app/module/ppid_data_approval_histories/request"
|
||||
"go-humas-be/app/module/ppid_data_approval_histories/response"
|
||||
"go-humas-be/utils/paginator"
|
||||
usersRepository "go-humas-be/app/module/users/repository"
|
||||
utilSvc "go-humas-be/utils/service"
|
||||
)
|
||||
|
||||
// PpidDataApprovalHistoriesService
|
||||
type ppidDataApprovalHistoriesService struct {
|
||||
Repo repository.PpidDataApprovalHistoriesRepository
|
||||
UsersRepo usersRepository.UsersRepository
|
||||
Log zerolog.Logger
|
||||
}
|
||||
|
||||
// PpidDataApprovalHistoriesService define interface of IPpidDataApprovalHistoriesService
|
||||
type PpidDataApprovalHistoriesService interface {
|
||||
All(req request.PpidDataApprovalHistoriesQueryRequest) (ppidDataApprovalHistories []*response.PpidDataApprovalHistoriesResponse, paging paginator.Pagination, err error)
|
||||
All() (ppidDataApprovalHistories []*response.PpidDataApprovalHistoriesResponse, err error)
|
||||
Show(id uint) (ppidDataApprovalHistories *response.PpidDataApprovalHistoriesResponse, err error)
|
||||
Save(req request.PpidDataApprovalHistoriesCreateRequest) (err error)
|
||||
Update(id uint, req request.PpidDataApprovalHistoriesUpdateRequest) (err error)
|
||||
ShowByPpidData(ppidDataId uint) (ppidDataApprovalHistories []*response.PpidDataApprovalHistoriesResponse, err error)
|
||||
Save(req request.PpidDataApprovalHistoriesCreateRequest, authToken string) (err error)
|
||||
Delete(id uint) error
|
||||
}
|
||||
|
||||
// NewPpidDataApprovalHistoriesService init PpidDataApprovalHistoriesService
|
||||
func NewPpidDataApprovalHistoriesService(repo repository.PpidDataApprovalHistoriesRepository, log zerolog.Logger) PpidDataApprovalHistoriesService {
|
||||
func NewPpidDataApprovalHistoriesService(repo repository.PpidDataApprovalHistoriesRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger) PpidDataApprovalHistoriesService {
|
||||
|
||||
return &ppidDataApprovalHistoriesService{
|
||||
Repo: repo,
|
||||
UsersRepo: usersRepo,
|
||||
Log: log,
|
||||
}
|
||||
}
|
||||
|
||||
// All implement interface of PpidDataApprovalHistoriesService
|
||||
func (_i *ppidDataApprovalHistoriesService) All(req request.PpidDataApprovalHistoriesQueryRequest) (ppidDataApprovalHistoriess []*response.PpidDataApprovalHistoriesResponse, paging paginator.Pagination, err error) {
|
||||
results, paging, err := _i.Repo.GetAll(req)
|
||||
func (_i *ppidDataApprovalHistoriesService) All() (ppidDataApprovalHistories []*response.PpidDataApprovalHistoriesResponse, err error) {
|
||||
results, err := _i.Repo.GetAll()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, result := range results {
|
||||
ppidDataApprovalHistoriess = append(ppidDataApprovalHistoriess, mapper.PpidDataApprovalHistoriesResponseMapper(result))
|
||||
ppidDataApprovalHistories = append(ppidDataApprovalHistories, mapper.PpidDataApprovalHistoriesResponseMapper(result, _i.UsersRepo))
|
||||
}
|
||||
|
||||
return
|
||||
|
|
@ -53,18 +56,30 @@ func (_i *ppidDataApprovalHistoriesService) Show(id uint) (ppidDataApprovalHisto
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return mapper.PpidDataApprovalHistoriesResponseMapper(result), nil
|
||||
return mapper.PpidDataApprovalHistoriesResponseMapper(result, _i.UsersRepo), nil
|
||||
}
|
||||
|
||||
func (_i *ppidDataApprovalHistoriesService) Save(req request.PpidDataApprovalHistoriesCreateRequest) (err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
func (_i *ppidDataApprovalHistoriesService) ShowByPpidData(ppidDataId uint) (ppidDataApprovalHistories []*response.PpidDataApprovalHistoriesResponse, err error) {
|
||||
results, err := _i.Repo.FindByPpidData(ppidDataId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return _i.Repo.Create(req.ToEntity())
|
||||
for _, result := range results {
|
||||
ppidDataApprovalHistories = append(ppidDataApprovalHistories, mapper.PpidDataApprovalHistoriesResponseMapper(result, _i.UsersRepo))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (_i *ppidDataApprovalHistoriesService) Update(id uint, req request.PpidDataApprovalHistoriesUpdateRequest) (err error) {
|
||||
func (_i *ppidDataApprovalHistoriesService) Save(req request.PpidDataApprovalHistoriesCreateRequest, authToken string) (err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
return _i.Repo.Update(id, req.ToEntity())
|
||||
newReq := req.ToEntity()
|
||||
|
||||
createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||
newReq.ApprovalBy = createdBy.ID
|
||||
|
||||
return _i.Repo.Create(newReq)
|
||||
}
|
||||
|
||||
func (_i *ppidDataApprovalHistoriesService) Delete(id uint) error {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"go-humas-be/utils/paginator"
|
||||
"strconv"
|
||||
|
||||
requestPpidApproval "go-humas-be/app/module/ppid_data_approval_histories/request"
|
||||
utilRes "go-humas-be/utils/response"
|
||||
utilVal "go-humas-be/utils/validator"
|
||||
)
|
||||
|
|
@ -20,6 +21,7 @@ type PpidDatasController interface {
|
|||
Show(c *fiber.Ctx) error
|
||||
Save(c *fiber.Ctx) error
|
||||
Update(c *fiber.Ctx) error
|
||||
UpdateApprovalStatus(c *fiber.Ctx) error
|
||||
Delete(c *fiber.Ctx) error
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +164,35 @@ func (_i *ppidDatasController) Update(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
// UpdateApprovalStatus PpidDatas
|
||||
// @Summary UpdateApprovalStatus PpidDatas
|
||||
// @Description API for UpdateApprovalStatus PpidDatas
|
||||
// @Tags PPID Data
|
||||
// @Security Bearer
|
||||
// @Param payload body requestPpidApproval.PpidDataApprovalHistoriesCreateRequest true "Required payload"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /ppid-datas/approval [put]
|
||||
func (_i *ppidDatasController) UpdateApprovalStatus(c *fiber.Ctx) error {
|
||||
req := new(requestPpidApproval.PpidDataApprovalHistoriesCreateRequest)
|
||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
authToken := c.Get("Authorization")
|
||||
err := _i.ppidDatasService.UpdateApprovalStatus(*req, authToken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"PpidDatas successfully updated"},
|
||||
})
|
||||
}
|
||||
|
||||
// Delete PpidDatas
|
||||
// @Summary delete PpidDatas
|
||||
// @Description API for delete PpidDatas
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ func (_i *PpidDatasRouter) RegisterPpidDatasRoutes() {
|
|||
router.Get("/:id", ppidDatasController.Show)
|
||||
router.Post("/", ppidDatasController.Save)
|
||||
router.Put("/:id", ppidDatasController.Update)
|
||||
router.Put("/approval", ppidDatasController.UpdateApprovalStatus)
|
||||
router.Delete("/:id", ppidDatasController.Delete)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ type PpidDatasCreateRequest struct {
|
|||
Slug string `json:"slug" validate:"required"`
|
||||
CategoryId uint `json:"categoryId" validate:"required"`
|
||||
StatusId int `json:"statusId" validate:"required"`
|
||||
CreatedById *uint `json:"createdById"`
|
||||
LevelGroupId *int `json:"levelGroupId"`
|
||||
Group *string `json:"group"`
|
||||
}
|
||||
|
|
@ -40,7 +39,6 @@ func (req PpidDatasCreateRequest) ToEntity() *entity.PpidDatas {
|
|||
Description: req.Description,
|
||||
Slug: req.Slug,
|
||||
CategoryId: req.CategoryId,
|
||||
CreatedById: req.CreatedById,
|
||||
StatusId: req.StatusId,
|
||||
LevelGroupId: req.LevelGroupId,
|
||||
Group: req.Group,
|
||||
|
|
@ -52,11 +50,15 @@ type PpidDatasUpdateRequest struct {
|
|||
Title string `json:"title" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
Slug string `json:"slug" validate:"required"`
|
||||
CategoryId uint `json:"category_id" validate:"required"`
|
||||
StatusId int `json:"status_id" validate:"required"`
|
||||
CreatedById *uint `json:"created_by_id"`
|
||||
IsPublish *bool `json:"is_publish"`
|
||||
PublishedAt *time.Time `json:"published_at"`
|
||||
CategoryId uint `json:"categoryId" validate:"required"`
|
||||
StatusId int `json:"statusId" validate:"required"`
|
||||
NeedApprovalFromUserRole *string `json:"needApprovalFrom"`
|
||||
NeedApprovalFromUserLevel *string `json:"needApprovalFromUserLevel"`
|
||||
BackApprovalToUserRole *int `json:"backApprovalToUserRole"`
|
||||
BackApprovalToUserLevel *int `json:"backApprovalToUserLevel"`
|
||||
IsPublish *bool `json:"isPublish"`
|
||||
PublishLevel *int `json:"publishLevel"`
|
||||
PublishedAt *time.Time `json:"publishedAt"`
|
||||
LevelGroupId *int `json:"levelGroupId"`
|
||||
Group *string `json:"group"`
|
||||
}
|
||||
|
|
@ -68,8 +70,11 @@ func (req PpidDatasUpdateRequest) ToEntity() *entity.PpidDatas {
|
|||
Description: req.Description,
|
||||
Slug: req.Slug,
|
||||
CategoryId: req.CategoryId,
|
||||
CreatedById: req.CreatedById,
|
||||
StatusId: req.StatusId,
|
||||
NeedApprovalFromUserRole: req.NeedApprovalFromUserRole,
|
||||
NeedApprovalFromUserLevel: req.NeedApprovalFromUserLevel,
|
||||
BackApprovalToUserRole: req.BackApprovalToUserRole,
|
||||
BackApprovalToUserLevel: req.BackApprovalToUserLevel,
|
||||
IsPublish: req.IsPublish,
|
||||
PublishedAt: req.PublishedAt,
|
||||
LevelGroupId: req.LevelGroupId,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/rs/zerolog"
|
||||
"go-humas-be/app/database/entity"
|
||||
requestPpidApproval "go-humas-be/app/module/ppid_data_approval_histories/request"
|
||||
ppidDataCategoriesRepository "go-humas-be/app/module/ppid_data_categories/repository"
|
||||
ppidDataFilesRepository "go-humas-be/app/module/ppid_data_files/repository"
|
||||
"go-humas-be/app/module/ppid_datas/mapper"
|
||||
|
|
@ -10,10 +12,13 @@ import (
|
|||
"go-humas-be/app/module/ppid_datas/request"
|
||||
"go-humas-be/app/module/ppid_datas/response"
|
||||
userLevelsRepository "go-humas-be/app/module/user_levels/repository"
|
||||
userRoleLevelDetailsRepository "go-humas-be/app/module/user_role_level_details/repository"
|
||||
usersRepository "go-humas-be/app/module/users/repository"
|
||||
"go-humas-be/utils/paginator"
|
||||
utilSvc "go-humas-be/utils/service"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PpidDatasService
|
||||
|
|
@ -23,6 +28,7 @@ type ppidDatasService struct {
|
|||
PpidDataFilesRepo ppidDataFilesRepository.PpidDataFilesRepository
|
||||
UsersRepo usersRepository.UsersRepository
|
||||
UserLevelsRepo userLevelsRepository.UserLevelsRepository
|
||||
userRoleLevelDetailsRepo userRoleLevelDetailsRepository.UserRoleLevelDetailsRepository
|
||||
Log zerolog.Logger
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +38,7 @@ type PpidDatasService interface {
|
|||
Show(id string) (ppidDatas *response.PpidDatasResponse, err error)
|
||||
Save(req request.PpidDatasCreateRequest, authToken string) (ppidDatas *entity.PpidDatas, err error)
|
||||
Update(id uint, req request.PpidDatasUpdateRequest) (err error)
|
||||
UpdateApprovalStatus(req requestPpidApproval.PpidDataApprovalHistoriesCreateRequest, authToken string) (err error)
|
||||
Delete(id uint) error
|
||||
}
|
||||
|
||||
|
|
@ -42,6 +49,7 @@ func NewPpidDatasService(
|
|||
ppidDataFilesRepo ppidDataFilesRepository.PpidDataFilesRepository,
|
||||
usersRepo usersRepository.UsersRepository,
|
||||
userLevelsRepo userLevelsRepository.UserLevelsRepository,
|
||||
userRoleLevelDetailsRepo userRoleLevelDetailsRepository.UserRoleLevelDetailsRepository,
|
||||
log zerolog.Logger,
|
||||
) PpidDatasService {
|
||||
|
||||
|
|
@ -51,6 +59,7 @@ func NewPpidDatasService(
|
|||
PpidDataFilesRepo: ppidDataFilesRepo,
|
||||
UsersRepo: usersRepo,
|
||||
UserLevelsRepo: userLevelsRepo,
|
||||
userRoleLevelDetailsRepo: userRoleLevelDetailsRepo,
|
||||
Log: log,
|
||||
}
|
||||
}
|
||||
|
|
@ -111,6 +120,59 @@ func (_i *ppidDatasService) Update(id uint, req request.PpidDatasUpdateRequest)
|
|||
return _i.Repo.Update(id, req.ToEntity())
|
||||
}
|
||||
|
||||
func (_i *ppidDatasService) UpdateApprovalStatus(req requestPpidApproval.PpidDataApprovalHistoriesCreateRequest, authToken string) (err error) {
|
||||
ppidData, err := _i.Repo.FindOne(req.PpidDataId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if req.ApprovalStatusId == 1 {
|
||||
ppidData.NeedApprovalFromUserRole = nil
|
||||
ppidData.NeedApprovalFromUserLevel = nil
|
||||
ppidData.BackApprovalToUserRole = nil
|
||||
ppidData.BackApprovalToUserLevel = nil
|
||||
}
|
||||
|
||||
approvalBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||
if approvalBy != nil {
|
||||
findUserLevel, _ := _i.UserLevelsRepo.FindOne(uint(approvalBy.UserLevelId))
|
||||
findUserParentLevel, _ := _i.UserLevelsRepo.FindOne(uint(findUserLevel.ParentLevelId))
|
||||
if findUserLevel != nil {
|
||||
if findUserLevel.LevelNumber == 1 {
|
||||
isPublish := true
|
||||
publishLevel := 1
|
||||
timeNow := time.Now()
|
||||
ppidData.IsPublish = &isPublish
|
||||
ppidData.PublishLevel = &publishLevel
|
||||
ppidData.PublishedAt = &timeNow
|
||||
ppidData.NeedApprovalFromUserRole = nil
|
||||
ppidData.NeedApprovalFromUserLevel = nil
|
||||
} else if findUserLevel.LevelNumber == 2 {
|
||||
isPublish := true
|
||||
publishLevel := 2
|
||||
timeNow := time.Now()
|
||||
ppidData.IsPublish = &isPublish
|
||||
ppidData.PublishLevel = &publishLevel
|
||||
ppidData.PublishedAt = &timeNow
|
||||
|
||||
needApprovalFromUserLevel := fmt.Sprintf("%s", findUserParentLevel.ID)
|
||||
ppidData.NeedApprovalFromUserLevel = &needApprovalFromUserLevel
|
||||
|
||||
findUserRoles, _ := _i.userRoleLevelDetailsRepo.FindByUserLevels(findUserParentLevel.ID)
|
||||
var needApprovalFromUserRole []string
|
||||
for _, role := range findUserRoles {
|
||||
roleId := fmt.Sprintf("%s", role.UserRoleId)
|
||||
needApprovalFromUserRole = append(needApprovalFromUserRole, roleId)
|
||||
}
|
||||
needApprovalFromUserRoleStr := strings.Join(needApprovalFromUserRole, "/")
|
||||
ppidData.NeedApprovalFromUserRole = &needApprovalFromUserRoleStr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _i.Repo.Update(req.PpidDataId, ppidData)
|
||||
}
|
||||
|
||||
func (_i *ppidDatasService) Delete(id uint) error {
|
||||
result, err := _i.Repo.FindOne(id)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ type userRoleLevelDetailsRepository struct {
|
|||
type UserRoleLevelDetailsRepository interface {
|
||||
GetAll(req request.UserRoleLevelDetailsQueryRequest) (userRoleLevelDetailss []*entity.UserRoleLevelDetails, paging paginator.Pagination, err error)
|
||||
FindOne(id uint) (userRoleLevelDetails *entity.UserRoleLevelDetails, err error)
|
||||
FindByUserLevels(userLevelId uint) (userRoleLevelDetails []*entity.UserRoleLevelDetails, err error)
|
||||
Create(userRoleLevelDetails *entity.UserRoleLevelDetails) (err error)
|
||||
Update(id uint, userRoleLevelDetails *entity.UserRoleLevelDetails) (err error)
|
||||
Delete(id uint) (err error)
|
||||
|
|
@ -54,6 +55,15 @@ func (_i *userRoleLevelDetailsRepository) FindOne(id uint) (userRoleLevelDetails
|
|||
return userRoleLevelDetails, nil
|
||||
}
|
||||
|
||||
func (_i *userRoleLevelDetailsRepository) FindByUserLevels(userLevelId uint) (userRoleLevelDetails []*entity.UserRoleLevelDetails, err error) {
|
||||
if err := _i.DB.DB.Find(&userRoleLevelDetails).
|
||||
Where(&entity.UserRoleLevelDetails{UserLevelId: userLevelId}).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return userRoleLevelDetails, nil
|
||||
}
|
||||
|
||||
func (_i *userRoleLevelDetailsRepository) Create(userRoleLevelDetails *entity.UserRoleLevelDetails) (err error) {
|
||||
return _i.DB.DB.Create(userRoleLevelDetails).Error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3375,6 +3375,251 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/ppid-data-approval-histories": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting all PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Get all PpidDataApprovalHistories",
|
||||
"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 PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Create PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ppid-data-approval-histories/:id": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting one PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Get one PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "PpidDataApprovalHistories 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 PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "delete PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "PpidDataApprovalHistories ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ppid-data-approval-histories/ppid-data/:ppidDataId": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting one PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Get one PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "PpidData ID",
|
||||
"name": "ppidDataId",
|
||||
"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": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -6689,9 +6934,6 @@ const docTemplate = `{
|
|||
"categoryId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createdById": {
|
||||
"type": "integer"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3364,6 +3364,251 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/ppid-data-approval-histories": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting all PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Get all PpidDataApprovalHistories",
|
||||
"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 PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Create PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ppid-data-approval-histories/:id": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting one PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Get one PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "PpidDataApprovalHistories 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 PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "delete PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "PpidDataApprovalHistories ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ppid-data-approval-histories/ppid-data/:ppidDataId": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting one PpidDataApprovalHistories",
|
||||
"tags": [
|
||||
"Task"
|
||||
],
|
||||
"summary": "Get one PpidDataApprovalHistories",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "PpidData ID",
|
||||
"name": "ppidDataId",
|
||||
"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": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -6678,9 +6923,6 @@
|
|||
"categoryId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createdById": {
|
||||
"type": "integer"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -299,8 +299,6 @@ definitions:
|
|||
properties:
|
||||
categoryId:
|
||||
type: integer
|
||||
createdById:
|
||||
type: integer
|
||||
description:
|
||||
type: string
|
||||
group:
|
||||
|
|
@ -2749,6 +2747,162 @@ paths:
|
|||
summary: Update MasterStatuses
|
||||
tags:
|
||||
- Untags
|
||||
/ppid-data-approval-histories:
|
||||
get:
|
||||
description: API for getting all PpidDataApprovalHistories
|
||||
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 PpidDataApprovalHistories
|
||||
tags:
|
||||
- Task
|
||||
post:
|
||||
description: API for create PpidDataApprovalHistories
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"422":
|
||||
description: Unprocessable Entity
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create PpidDataApprovalHistories
|
||||
tags:
|
||||
- Task
|
||||
/ppid-data-approval-histories/:id:
|
||||
delete:
|
||||
description: API for delete PpidDataApprovalHistories
|
||||
parameters:
|
||||
- description: PpidDataApprovalHistories ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"422":
|
||||
description: Unprocessable Entity
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: delete PpidDataApprovalHistories
|
||||
tags:
|
||||
- Task
|
||||
get:
|
||||
description: API for getting one PpidDataApprovalHistories
|
||||
parameters:
|
||||
- description: PpidDataApprovalHistories 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 PpidDataApprovalHistories
|
||||
tags:
|
||||
- Task
|
||||
/ppid-data-approval-histories/ppid-data/:ppidDataId:
|
||||
get:
|
||||
description: API for getting one PpidDataApprovalHistories
|
||||
parameters:
|
||||
- description: PpidData ID
|
||||
in: path
|
||||
name: ppidDataId
|
||||
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 PpidDataApprovalHistories
|
||||
tags:
|
||||
- Task
|
||||
/ppid-data-categories:
|
||||
get:
|
||||
description: API for getting all PpidDataCategories
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -14,6 +14,7 @@ import (
|
|||
"go-humas-be/app/module/magazines"
|
||||
"go-humas-be/app/module/master_menus"
|
||||
"go-humas-be/app/module/master_modules"
|
||||
"go-humas-be/app/module/ppid_data_approval_histories"
|
||||
"go-humas-be/app/module/ppid_data_categories"
|
||||
"go-humas-be/app/module/ppid_data_files"
|
||||
"go-humas-be/app/module/ppid_datas"
|
||||
|
|
@ -64,6 +65,7 @@ func main() {
|
|||
master_modules.NewMasterModulesModule,
|
||||
ppid_data_files.NewPpidDataFilesModule,
|
||||
ppid_data_categories.NewPpidDataCategoriesModule,
|
||||
ppid_data_approval_histories.NewPpidDataApprovalHistoriesModule,
|
||||
ppid_datas.NewPpidDatasModule,
|
||||
provinces.NewProvincesModule,
|
||||
user_levels.NewUserLevelsModule,
|
||||
|
|
|
|||
Loading…
Reference in New Issue