feat: add request for informations, ..items, ..replies

This commit is contained in:
hanif salafi 2024-07-02 09:02:56 +07:00
parent 776cbd6921
commit 2d4462df11
35 changed files with 4694 additions and 42 deletions

View File

@ -0,0 +1,13 @@
package entity
import "time"
type RequestForInformationItems struct {
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
RequestedInfo string `json:"requested_info" gorm:"type:varchar"`
Reason string `json:"reason" gorm:"type:varchar"`
StatusId int `json:"status_id" gorm:"type:int4"`
IsActive *bool `json:"is_active" gorm:"type:bool"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
}

View File

@ -0,0 +1,15 @@
package entity
import "time"
type RequestForInformationReplies struct {
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
RequestForInformationItemId int `json:"request_for_information_item_id" gorm:"type:int4"`
FileUrl string `json:"file_url" gorm:"type:varchar"`
Response string `json:"response" gorm:"type:varchar"`
StatusId int `json:"status_id" gorm:"type:int4"`
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
IsActive *bool `json:"is_active" gorm:"type:bool"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
}

View File

@ -0,0 +1,16 @@
package entity
import "time"
type RequestForInformations struct {
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
TicketNumber string `json:"ticket_number" gorm:"type:varchar"`
HowToGetInfo string `json:"how_to_get_info" gorm:"type:varchar"`
HowToGetFiles string `json:"how_to_get_files" gorm:"type:varchar"`
NextAction string `json:"next_action" gorm:"type:varchar"`
StatusId int `json:"status_id" gorm:"type:int4"`
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
IsActive *bool `json:"is_active" gorm:"type:bool"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
}

View File

@ -89,6 +89,9 @@ func Models() []interface{} {
entity.UserRoleAccesses{},
entity.Users{},
entity.UserRoleLevelDetails{},
entity.RequestForInformations{},
entity.RequestForInformationItems{},
entity.RequestForInformationReplies{},
}
}

View File

@ -230,7 +230,14 @@ func (_i *ppidDataFilesService) UpdatePosition(req []request.PpidDataFilesUpdate
}
func (_i *ppidDataFilesService) Delete(id uint) error {
return _i.Repo.Delete(id)
result, err := _i.Repo.FindOne(id)
if err != nil {
return err
}
isActive := false
result.IsActive = &isActive
return _i.Repo.Update(id, result)
}
func (_i *ppidDataFilesService) Viewer(c *fiber.Ctx, filename string) (err error) {

View File

@ -230,5 +230,5 @@ func (_i *ppidDatasService) Delete(id uint) error {
isActive := false
result.IsActive = &isActive
return _i.Repo.Delete(id)
return _i.Repo.Update(id, result)
}

View File

@ -0,0 +1,16 @@
package controller
import (
"github.com/rs/zerolog"
"go-humas-be/app/module/request_for_information_items/service"
)
type Controller struct {
RequestForInformationItems RequestForInformationItemsController
}
func NewController(RequestForInformationItemsService service.RequestForInformationItemsService, log zerolog.Logger) *Controller {
return &Controller{
RequestForInformationItems: NewRequestForInformationItemsController(RequestForInformationItemsService, log),
}
}

View File

@ -0,0 +1,192 @@
package controller
import (
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog"
"go-humas-be/app/module/request_for_information_items/request"
"go-humas-be/app/module/request_for_information_items/service"
"go-humas-be/utils/paginator"
utilRes "go-humas-be/utils/response"
utilVal "go-humas-be/utils/validator"
"strconv"
)
type requestForInformationItemsController struct {
requestForInformationItemsService service.RequestForInformationItemsService
Log zerolog.Logger
}
type RequestForInformationItemsController interface {
All(c *fiber.Ctx) error
Show(c *fiber.Ctx) error
Save(c *fiber.Ctx) error
Update(c *fiber.Ctx) error
Delete(c *fiber.Ctx) error
}
func NewRequestForInformationItemsController(requestForInformationItemsService service.RequestForInformationItemsService, log zerolog.Logger) RequestForInformationItemsController {
return &requestForInformationItemsController{
requestForInformationItemsService: requestForInformationItemsService,
Log: log,
}
}
// All get all RequestForInformationItems
// @Summary Get all RequestForInformationItems
// @Description API for getting all RequestForInformationItems
// @Tags RequestForInformationItems
// @Security Bearer
// @Param req query request.RequestForInformationItemsQueryRequest false "query parameters"
// @Param req query paginator.Pagination false "pagination parameters"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-items [get]
func (_i *requestForInformationItemsController) All(c *fiber.Ctx) error {
paginate, err := paginator.Paginate(c)
if err != nil {
return err
}
reqContext := request.RequestForInformationItemsQueryRequestContext{
RequestedInfo: c.Query("requested_info"),
Reason: c.Query("reason"),
StatusId: c.Query("status_id"),
}
req := reqContext.ToParamRequest()
req.Pagination = paginate
requestForInformationItemsData, paging, err := _i.requestForInformationItemsService.All(req)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationItems list successfully retrieved"},
Data: requestForInformationItemsData,
Meta: paging,
})
}
// Show get one RequestForInformationItems
// @Summary Get one RequestForInformationItems
// @Description API for getting one RequestForInformationItems
// @Tags RequestForInformationItems
// @Security Bearer
// @Param id path int true "RequestForInformationItems ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-items/:id [get]
func (_i *requestForInformationItemsController) Show(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
requestForInformationItemsData, err := _i.requestForInformationItemsService.Show(uint(id))
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationItems successfully retrieved"},
Data: requestForInformationItemsData,
})
}
// Save create RequestForInformationItems
// @Summary Create RequestForInformationItems
// @Description API for create RequestForInformationItems
// @Tags RequestForInformationItems
// @Security Bearer
// @Param payload body request.RequestForInformationItemsCreateRequest true "Required payload"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-items [post]
func (_i *requestForInformationItemsController) Save(c *fiber.Ctx) error {
req := new(request.RequestForInformationItemsCreateRequest)
if err := utilVal.ParseAndValidate(c, req); err != nil {
return err
}
authToken := c.Get("Authorization")
dataResult, err := _i.requestForInformationItemsService.Save(*req, authToken)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationItems successfully created"},
Data: dataResult,
})
}
// Update update RequestForInformationItems
// @Summary update RequestForInformationItems
// @Description API for update RequestForInformationItems
// @Tags RequestForInformationItems
// @Security Bearer
// @Param payload body request.RequestForInformationItemsUpdateRequest true "Required payload"
// @Param id path int true "RequestForInformationItems ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-items/:id [put]
func (_i *requestForInformationItemsController) Update(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
req := new(request.RequestForInformationItemsUpdateRequest)
if err := utilVal.ParseAndValidate(c, req); err != nil {
return err
}
err = _i.requestForInformationItemsService.Update(uint(id), *req)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationItems successfully updated"},
})
}
// Delete delete RequestForInformationItems
// @Summary delete RequestForInformationItems
// @Description API for delete RequestForInformationItems
// @Tags RequestForInformationItems
// @Security Bearer
// @Param id path int true "RequestForInformationItems ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-items/:id [delete]
func (_i *requestForInformationItemsController) Delete(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
err = _i.requestForInformationItemsService.Delete(uint(id))
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationItems successfully deleted"},
})
}

View File

@ -0,0 +1,21 @@
package mapper
import (
"go-humas-be/app/database/entity"
res "go-humas-be/app/module/request_for_information_items/response"
)
func RequestForInformationItemsResponseMapper(requestForInformationItemsReq *entity.RequestForInformationItems) (requestForInformationItemsRes *res.RequestForInformationItemsResponse) {
if requestForInformationItemsReq != nil {
requestForInformationItemsRes = &res.RequestForInformationItemsResponse{
ID: requestForInformationItemsReq.ID,
RequestedInfo: requestForInformationItemsReq.RequestedInfo,
Reason: requestForInformationItemsReq.Reason,
StatusId: requestForInformationItemsReq.StatusId,
IsActive: requestForInformationItemsReq.IsActive,
CreatedAt: requestForInformationItemsReq.CreatedAt,
UpdatedAt: requestForInformationItemsReq.UpdatedAt,
}
}
return requestForInformationItemsRes
}

View File

@ -0,0 +1,96 @@
package repository
import (
"fmt"
"github.com/rs/zerolog"
"go-humas-be/app/database"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/request_for_information_items/request"
"go-humas-be/utils/paginator"
"strings"
)
type requestForInformationItemsRepository struct {
DB *database.Database
Log zerolog.Logger
}
// RequestForInformationItemsRepository define interface of IRequestForInformationItemsRepository
type RequestForInformationItemsRepository interface {
GetAll(req request.RequestForInformationItemsQueryRequest) (requestForInformationItemss []*entity.RequestForInformationItems, paging paginator.Pagination, err error)
FindOne(id uint) (requestForInformationItems *entity.RequestForInformationItems, err error)
Create(requestForInformationItems *entity.RequestForInformationItems) (requestForInformationItemsReturn *entity.RequestForInformationItems, err error)
Update(id uint, requestForInformationItems *entity.RequestForInformationItems) (err error)
Delete(id uint) (err error)
}
func NewRequestForInformationItemsRepository(db *database.Database, logger zerolog.Logger) RequestForInformationItemsRepository {
return &requestForInformationItemsRepository{
DB: db,
Log: logger,
}
}
// implement interface of IRequestForInformationItemsRepository
func (_i *requestForInformationItemsRepository) GetAll(req request.RequestForInformationItemsQueryRequest) (requestForInformationItemss []*entity.RequestForInformationItems, paging paginator.Pagination, err error) {
var count int64
query := _i.DB.DB.Model(&entity.RequestForInformationItems{})
query = query.Where("is_active = ?", true)
if req.RequestedInfo != nil && *req.RequestedInfo != "" {
requestedInfo := strings.ToLower(*req.RequestedInfo)
query = query.Where("LOWER(requested_info) LIKE ?", "%"+strings.ToLower(requestedInfo)+"%")
}
if req.Reason != nil && *req.Reason != "" {
reason := strings.ToLower(*req.Reason)
query = query.Where("LOWER(reason) LIKE ?", "%"+strings.ToLower(reason)+"%")
}
if req.StatusId != nil {
query = query.Where("status_id = ?", req.StatusId)
}
query.Count(&count)
if req.Pagination.SortBy != "" {
direction := "ASC"
if req.Pagination.Sort == "desc" {
direction = "DESC"
}
query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction))
}
req.Pagination.Count = count
req.Pagination = paginator.Paging(req.Pagination)
err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&requestForInformationItemss).Error
if err != nil {
return
}
paging = *req.Pagination
return
}
func (_i *requestForInformationItemsRepository) FindOne(id uint) (requestForInformationItems *entity.RequestForInformationItems, err error) {
if err := _i.DB.DB.First(&requestForInformationItems, id).Error; err != nil {
return nil, err
}
return requestForInformationItems, nil
}
func (_i *requestForInformationItemsRepository) Create(requestForInformationItems *entity.RequestForInformationItems) (requestForInformationItemsReturn *entity.RequestForInformationItems, err error) {
result := _i.DB.DB.Create(requestForInformationItems)
return requestForInformationItems, result.Error
}
func (_i *requestForInformationItemsRepository) Update(id uint, requestForInformationItems *entity.RequestForInformationItems) (err error) {
return _i.DB.DB.Model(&entity.RequestForInformationItems{}).
Where(&entity.RequestForInformationItems{ID: id}).
Updates(requestForInformationItems).Error
}
func (_i *requestForInformationItemsRepository) Delete(id uint) error {
return _i.DB.DB.Delete(&entity.RequestForInformationItems{}, id).Error
}

View File

@ -0,0 +1,76 @@
package request
import (
"go-humas-be/app/database/entity"
"go-humas-be/utils/paginator"
"strconv"
"time"
)
type RequestForInformationItemsGeneric interface {
ToEntity()
}
type RequestForInformationItemsQueryRequest struct {
RequestedInfo *string `json:"requested_info"`
Reason *string `json:"reason"`
StatusId *int `json:"status_id"`
Pagination *paginator.Pagination `json:"pagination"`
}
type RequestForInformationItemsCreateRequest struct {
RequestedInfo string `json:"requested_info" validate:"required"`
Reason string `json:"reason" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
}
func (req RequestForInformationItemsCreateRequest) ToEntity() *entity.RequestForInformationItems {
return &entity.RequestForInformationItems{
RequestedInfo: req.RequestedInfo,
Reason: req.Reason,
StatusId: req.StatusId,
}
}
type RequestForInformationItemsUpdateRequest struct {
ID uint `json:"id" validate:"required"`
RequestedInfo string `json:"requested_info" validate:"required"`
Reason string `json:"reason" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
UpdatedAt time.Time `json:"updated_at"`
}
func (req RequestForInformationItemsUpdateRequest) ToEntity() *entity.RequestForInformationItems {
return &entity.RequestForInformationItems{
ID: req.ID,
RequestedInfo: req.RequestedInfo,
Reason: req.Reason,
StatusId: req.StatusId,
UpdatedAt: req.UpdatedAt,
}
}
type RequestForInformationItemsQueryRequestContext struct {
RequestedInfo string `json:"requested_info"`
Reason string `json:"reason"`
StatusId string `json:"status_id"`
}
func (req RequestForInformationItemsQueryRequestContext) ToParamRequest() RequestForInformationItemsQueryRequest {
var request RequestForInformationItemsQueryRequest
if requestedInfo := req.RequestedInfo; requestedInfo != "" {
request.RequestedInfo = &requestedInfo
}
if reason := req.Reason; reason != "" {
request.Reason = &reason
}
if statusIdStr := req.StatusId; statusIdStr != "" {
statusId, err := strconv.Atoi(statusIdStr)
if err == nil {
request.StatusId = &statusId
}
}
return request
}

View File

@ -0,0 +1,53 @@
package request_for_information_items
import (
"github.com/gofiber/fiber/v2"
"go-humas-be/app/module/request_for_information_items/controller"
"go-humas-be/app/module/request_for_information_items/repository"
"go-humas-be/app/module/request_for_information_items/service"
"go.uber.org/fx"
)
// struct of RequestForInformationItemsRouter
type RequestForInformationItemsRouter struct {
App fiber.Router
Controller *controller.Controller
}
// register bulky of RequestForInformationItems module
var NewRequestForInformationItemsModule = fx.Options(
// register repository of RequestForInformationItems module
fx.Provide(repository.NewRequestForInformationItemsRepository),
// register service of RequestForInformationItems module
fx.Provide(service.NewRequestForInformationItemsService),
// register controller of RequestForInformationItems module
fx.Provide(controller.NewController),
// register router of RequestForInformationItems module
fx.Provide(NewRequestForInformationItemsRouter),
)
// init RequestForInformationItemsRouter
func NewRequestForInformationItemsRouter(fiber *fiber.App, controller *controller.Controller) *RequestForInformationItemsRouter {
return &RequestForInformationItemsRouter{
App: fiber,
Controller: controller,
}
}
// register routes of RequestForInformationItems module
func (_i *RequestForInformationItemsRouter) RegisterRequestForInformationItemsRoutes() {
// define controllers
requestForInformationItemsController := _i.Controller.RequestForInformationItems
// define routes
_i.App.Route("/request-for-information-items", func(router fiber.Router) {
router.Get("/", requestForInformationItemsController.All)
router.Get("/:id", requestForInformationItemsController.Show)
router.Post("/", requestForInformationItemsController.Save)
router.Put("/:id", requestForInformationItemsController.Update)
router.Delete("/:id", requestForInformationItemsController.Delete)
})
}

View File

@ -0,0 +1,13 @@
package response
import "time"
type RequestForInformationItemsResponse struct {
ID uint `json:"id"`
RequestedInfo string `json:"requested_info"`
Reason string `json:"reason"`
StatusId int `json:"status_id"`
IsActive *bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@ -0,0 +1,85 @@
package service
import (
"github.com/rs/zerolog"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/request_for_information_items/mapper"
"go-humas-be/app/module/request_for_information_items/repository"
"go-humas-be/app/module/request_for_information_items/request"
"go-humas-be/app/module/request_for_information_items/response"
usersRepository "go-humas-be/app/module/users/repository"
"go-humas-be/utils/paginator"
)
// RequestForInformationItemsService
type requestForInformationItemsService struct {
Repo repository.RequestForInformationItemsRepository
UsersRepo usersRepository.UsersRepository
Log zerolog.Logger
}
// RequestForInformationItemsService define interface of IRequestForInformationItemsService
type RequestForInformationItemsService interface {
All(req request.RequestForInformationItemsQueryRequest) (requestForInformationItems []*response.RequestForInformationItemsResponse, paging paginator.Pagination, err error)
Show(id uint) (requestForInformationItems *response.RequestForInformationItemsResponse, err error)
Save(req request.RequestForInformationItemsCreateRequest, authToken string) (requestForInformationItems *entity.RequestForInformationItems, err error)
Update(id uint, req request.RequestForInformationItemsUpdateRequest) (err error)
Delete(id uint) error
}
// NewRequestForInformationItemsService init RequestForInformationItemsService
func NewRequestForInformationItemsService(repo repository.RequestForInformationItemsRepository, log zerolog.Logger, usersRepo usersRepository.UsersRepository) RequestForInformationItemsService {
return &requestForInformationItemsService{
Repo: repo,
Log: log,
UsersRepo: usersRepo,
}
}
// All implement interface of RequestForInformationItemsService
func (_i *requestForInformationItemsService) All(req request.RequestForInformationItemsQueryRequest) (requestForInformationItemss []*response.RequestForInformationItemsResponse, paging paginator.Pagination, err error) {
results, paging, err := _i.Repo.GetAll(req)
if err != nil {
return
}
for _, result := range results {
requestForInformationItemss = append(requestForInformationItemss, mapper.RequestForInformationItemsResponseMapper(result))
}
return
}
func (_i *requestForInformationItemsService) Show(id uint) (requestForInformationItems *response.RequestForInformationItemsResponse, err error) {
result, err := _i.Repo.FindOne(id)
if err != nil {
return nil, err
}
return mapper.RequestForInformationItemsResponseMapper(result), nil
}
func (_i *requestForInformationItemsService) Save(req request.RequestForInformationItemsCreateRequest, authToken string) (requestForInformationItems *entity.RequestForInformationItems, err error) {
_i.Log.Info().Interface("data", req).Msg("")
newReq := req.ToEntity()
return _i.Repo.Create(newReq)
}
func (_i *requestForInformationItemsService) Update(id uint, req request.RequestForInformationItemsUpdateRequest) (err error) {
_i.Log.Info().Interface("data", req).Msg("")
return _i.Repo.Update(id, req.ToEntity())
}
func (_i *requestForInformationItemsService) Delete(id uint) error {
result, err := _i.Repo.FindOne(id)
if err != nil {
return err
}
isActive := false
result.IsActive = &isActive
return _i.Repo.Update(id, result)
}

View File

@ -0,0 +1,16 @@
package controller
import (
"github.com/rs/zerolog"
"go-humas-be/app/module/request_for_information_replies/service"
)
type Controller struct {
RequestForInformationReplies RequestForInformationRepliesController
}
func NewController(RequestForInformationRepliesService service.RequestForInformationRepliesService, log zerolog.Logger) *Controller {
return &Controller{
RequestForInformationReplies: NewRequestForInformationRepliesController(RequestForInformationRepliesService, log),
}
}

View File

@ -0,0 +1,193 @@
package controller
import (
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog"
"go-humas-be/app/module/request_for_information_replies/request"
"go-humas-be/app/module/request_for_information_replies/service"
"go-humas-be/utils/paginator"
utilRes "go-humas-be/utils/response"
utilVal "go-humas-be/utils/validator"
"strconv"
)
type requestForInformationRepliesController struct {
requestForInformationRepliesService service.RequestForInformationRepliesService
Log zerolog.Logger
}
type RequestForInformationRepliesController interface {
All(c *fiber.Ctx) error
Show(c *fiber.Ctx) error
Save(c *fiber.Ctx) error
Update(c *fiber.Ctx) error
Delete(c *fiber.Ctx) error
}
func NewRequestForInformationRepliesController(requestForInformationRepliesService service.RequestForInformationRepliesService, log zerolog.Logger) RequestForInformationRepliesController {
return &requestForInformationRepliesController{
requestForInformationRepliesService: requestForInformationRepliesService,
Log: log,
}
}
// All get all RequestForInformationReplies
// @Summary Get all RequestForInformationReplies
// @Description API for getting all RequestForInformationReplies
// @Tags RequestForInformationReplies
// @Security Bearer
// @Param req query request.RequestForInformationRepliesQueryRequest false "query parameters"
// @Param req query paginator.Pagination false "pagination parameters"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-replies [get]
func (_i *requestForInformationRepliesController) All(c *fiber.Ctx) error {
paginate, err := paginator.Paginate(c)
if err != nil {
return err
}
reqContext := request.RequestForInformationRepliesQueryRequestContext{
RequestForInformationItemId: c.Query("request_for_information_item_id"),
FileUrl: c.Query("file_url"),
Response: c.Query("response"),
StatusId: c.Query("status_id"),
}
req := reqContext.ToParamRequest()
req.Pagination = paginate
requestForInformationRepliesData, paging, err := _i.requestForInformationRepliesService.All(req)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationReplies list successfully retrieved"},
Data: requestForInformationRepliesData,
Meta: paging,
})
}
// Show get one RequestForInformationReplies
// @Summary Get one RequestForInformationReplies
// @Description API for getting one RequestForInformationReplies
// @Tags RequestForInformationReplies
// @Security Bearer
// @Param id path int true "RequestForInformationReplies ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-replies/:id [get]
func (_i *requestForInformationRepliesController) Show(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
requestForInformationRepliesData, err := _i.requestForInformationRepliesService.Show(uint(id))
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationReplies successfully retrieved"},
Data: requestForInformationRepliesData,
})
}
// Save create RequestForInformationReplies
// @Summary Create RequestForInformationReplies
// @Description API for create RequestForInformationReplies
// @Tags RequestForInformationReplies
// @Security Bearer
// @Param payload body request.RequestForInformationRepliesCreateRequest true "Required payload"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-replies [post]
func (_i *requestForInformationRepliesController) Save(c *fiber.Ctx) error {
req := new(request.RequestForInformationRepliesCreateRequest)
if err := utilVal.ParseAndValidate(c, req); err != nil {
return err
}
authToken := c.Get("Authorization")
dataResult, err := _i.requestForInformationRepliesService.Save(*req, authToken)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationReplies successfully created"},
Data: dataResult,
})
}
// Update update RequestForInformationReplies
// @Summary update RequestForInformationReplies
// @Description API for update RequestForInformationReplies
// @Tags RequestForInformationReplies
// @Security Bearer
// @Param payload body request.RequestForInformationRepliesUpdateRequest true "Required payload"
// @Param id path int true "RequestForInformationReplies ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-replies/:id [put]
func (_i *requestForInformationRepliesController) Update(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
req := new(request.RequestForInformationRepliesUpdateRequest)
if err := utilVal.ParseAndValidate(c, req); err != nil {
return err
}
err = _i.requestForInformationRepliesService.Update(uint(id), *req)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationReplies successfully updated"},
})
}
// Delete delete RequestForInformationReplies
// @Summary delete RequestForInformationReplies
// @Description API for delete RequestForInformationReplies
// @Tags RequestForInformationReplies
// @Security Bearer
// @Param id path int true "RequestForInformationReplies ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-information-replies/:id [delete]
func (_i *requestForInformationRepliesController) Delete(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
err = _i.requestForInformationRepliesService.Delete(uint(id))
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformationReplies successfully deleted"},
})
}

View File

@ -0,0 +1,23 @@
package mapper
import (
"go-humas-be/app/database/entity"
res "go-humas-be/app/module/request_for_information_replies/response"
)
func RequestForInformationRepliesResponseMapper(requestForInformationRepliesReq *entity.RequestForInformationReplies) (requestForInformationRepliesRes *res.RequestForInformationRepliesResponse) {
if requestForInformationRepliesReq != nil {
requestForInformationRepliesRes = &res.RequestForInformationRepliesResponse{
ID: requestForInformationRepliesReq.ID,
RequestForInformationItemId: requestForInformationRepliesReq.RequestForInformationItemId,
FileUrl: requestForInformationRepliesReq.FileUrl,
Response: requestForInformationRepliesReq.Response,
StatusId: requestForInformationRepliesReq.StatusId,
CreatedById: requestForInformationRepliesReq.CreatedById,
IsActive: requestForInformationRepliesReq.IsActive,
CreatedAt: requestForInformationRepliesReq.CreatedAt,
UpdatedAt: requestForInformationRepliesReq.UpdatedAt,
}
}
return requestForInformationRepliesRes
}

View File

@ -0,0 +1,99 @@
package repository
import (
"fmt"
"github.com/rs/zerolog"
"go-humas-be/app/database"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/request_for_information_replies/request"
"go-humas-be/utils/paginator"
"strings"
)
type requestForInformationRepliesRepository struct {
DB *database.Database
Log zerolog.Logger
}
// RequestForInformationRepliesRepository define interface of IRequestForInformationRepliesRepository
type RequestForInformationRepliesRepository interface {
GetAll(req request.RequestForInformationRepliesQueryRequest) (requestForInformationRepliess []*entity.RequestForInformationReplies, paging paginator.Pagination, err error)
FindOne(id uint) (requestForInformationReplies *entity.RequestForInformationReplies, err error)
Create(requestForInformationReplies *entity.RequestForInformationReplies) (requestForInformationRepliesReturn *entity.RequestForInformationReplies, err error)
Update(id uint, requestForInformationReplies *entity.RequestForInformationReplies) (err error)
Delete(id uint) (err error)
}
func NewRequestForInformationRepliesRepository(db *database.Database, logger zerolog.Logger) RequestForInformationRepliesRepository {
return &requestForInformationRepliesRepository{
DB: db,
Log: logger,
}
}
// implement interface of IRequestForInformationRepliesRepository
func (_i *requestForInformationRepliesRepository) GetAll(req request.RequestForInformationRepliesQueryRequest) (requestForInformationRepliess []*entity.RequestForInformationReplies, paging paginator.Pagination, err error) {
var count int64
query := _i.DB.DB.Model(&entity.RequestForInformationReplies{})
query = query.Where("is_active = ?", true)
if req.RequestForInformationItemId != nil {
query = query.Where("request_for_information_item_id = ?", req.RequestForInformationItemId)
}
if req.FileUrl != nil && *req.FileUrl != "" {
fileUrl := strings.ToLower(*req.FileUrl)
query = query.Where("LOWER(file_url) LIKE ?", "%"+strings.ToLower(fileUrl)+"%")
}
if req.Response != nil && *req.Response != "" {
response := strings.ToLower(*req.Response)
query = query.Where("LOWER(response) LIKE ?", "%"+strings.ToLower(response)+"%")
}
if req.StatusId != nil {
query = query.Where("status_id = ?", req.StatusId)
}
query.Count(&count)
if req.Pagination.SortBy != "" {
direction := "ASC"
if req.Pagination.Sort == "desc" {
direction = "DESC"
}
query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction))
}
req.Pagination.Count = count
req.Pagination = paginator.Paging(req.Pagination)
err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&requestForInformationRepliess).Error
if err != nil {
return
}
paging = *req.Pagination
return
}
func (_i *requestForInformationRepliesRepository) FindOne(id uint) (requestForInformationReplies *entity.RequestForInformationReplies, err error) {
if err := _i.DB.DB.First(&requestForInformationReplies, id).Error; err != nil {
return nil, err
}
return requestForInformationReplies, nil
}
func (_i *requestForInformationRepliesRepository) Create(requestForInformationReplies *entity.RequestForInformationReplies) (requestForInformationRepliesReturn *entity.RequestForInformationReplies, err error) {
result := _i.DB.DB.Create(requestForInformationReplies)
return requestForInformationReplies, result.Error
}
func (_i *requestForInformationRepliesRepository) Update(id uint, requestForInformationReplies *entity.RequestForInformationReplies) (err error) {
return _i.DB.DB.Model(&entity.RequestForInformationReplies{}).
Where(&entity.RequestForInformationReplies{ID: id}).
Updates(requestForInformationReplies).Error
}
func (_i *requestForInformationRepliesRepository) Delete(id uint) error {
return _i.DB.DB.Delete(&entity.RequestForInformationReplies{}, id).Error
}

View File

@ -0,0 +1,88 @@
package request
import (
"go-humas-be/app/database/entity"
"go-humas-be/utils/paginator"
"strconv"
"time"
)
type RequestForInformationRepliesGeneric interface {
ToEntity()
}
type RequestForInformationRepliesQueryRequest struct {
RequestForInformationItemId *int `json:"request_for_information_item_id"`
FileUrl *string `json:"file_url"`
Response *string `json:"response"`
StatusId *int `json:"status_id"`
Pagination *paginator.Pagination `json:"pagination"`
}
type RequestForInformationRepliesCreateRequest struct {
RequestForInformationItemId int `json:"request_for_information_item_id" validate:"required"`
FileUrl string `json:"file_url" validate:"required"`
Response string `json:"response" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
}
func (req RequestForInformationRepliesCreateRequest) ToEntity() *entity.RequestForInformationReplies {
return &entity.RequestForInformationReplies{
RequestForInformationItemId: req.RequestForInformationItemId,
FileUrl: req.FileUrl,
Response: req.Response,
StatusId: req.StatusId,
}
}
type RequestForInformationRepliesUpdateRequest struct {
ID uint `json:"id" validate:"required"`
RequestForInformationItemId int `json:"request_for_information_item_id" validate:"required"`
FileUrl string `json:"file_url" validate:"required"`
Response string `json:"response" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
UpdatedAt time.Time `json:"updated_at"`
}
func (req RequestForInformationRepliesUpdateRequest) ToEntity() *entity.RequestForInformationReplies {
return &entity.RequestForInformationReplies{
ID: req.ID,
RequestForInformationItemId: req.RequestForInformationItemId,
FileUrl: req.FileUrl,
Response: req.Response,
StatusId: req.StatusId,
UpdatedAt: req.UpdatedAt,
}
}
type RequestForInformationRepliesQueryRequestContext struct {
RequestForInformationItemId string `json:"request_for_information_item_id"`
FileUrl string `json:"file_url"`
Response string `json:"response"`
StatusId string `json:"status_id"`
}
func (req RequestForInformationRepliesQueryRequestContext) ToParamRequest() RequestForInformationRepliesQueryRequest {
var request RequestForInformationRepliesQueryRequest
if requestForInformationItemIdStr := req.RequestForInformationItemId; requestForInformationItemIdStr != "" {
requestForInformationItemId, err := strconv.Atoi(requestForInformationItemIdStr)
if err == nil {
request.RequestForInformationItemId = &requestForInformationItemId
}
}
if fileUrl := req.FileUrl; fileUrl != "" {
request.FileUrl = &fileUrl
}
if response := req.Response; response != "" {
request.Response = &response
}
if statusIdStr := req.StatusId; statusIdStr != "" {
statusId, err := strconv.Atoi(statusIdStr)
if err == nil {
request.StatusId = &statusId
}
}
return request
}

View File

@ -0,0 +1,53 @@
package request_for_information_replies
import (
"github.com/gofiber/fiber/v2"
"go-humas-be/app/module/request_for_information_replies/controller"
"go-humas-be/app/module/request_for_information_replies/repository"
"go-humas-be/app/module/request_for_information_replies/service"
"go.uber.org/fx"
)
// struct of RequestForInformationRepliesRouter
type RequestForInformationRepliesRouter struct {
App fiber.Router
Controller *controller.Controller
}
// register bulky of RequestForInformationReplies module
var NewRequestForInformationRepliesModule = fx.Options(
// register repository of RequestForInformationReplies module
fx.Provide(repository.NewRequestForInformationRepliesRepository),
// register service of RequestForInformationReplies module
fx.Provide(service.NewRequestForInformationRepliesService),
// register controller of RequestForInformationReplies module
fx.Provide(controller.NewController),
// register router of RequestForInformationReplies module
fx.Provide(NewRequestForInformationRepliesRouter),
)
// init RequestForInformationRepliesRouter
func NewRequestForInformationRepliesRouter(fiber *fiber.App, controller *controller.Controller) *RequestForInformationRepliesRouter {
return &RequestForInformationRepliesRouter{
App: fiber,
Controller: controller,
}
}
// register routes of RequestForInformationReplies module
func (_i *RequestForInformationRepliesRouter) RegisterRequestForInformationRepliesRoutes() {
// define controllers
requestForInformationRepliesController := _i.Controller.RequestForInformationReplies
// define routes
_i.App.Route("/request-for-information-replies", func(router fiber.Router) {
router.Get("/", requestForInformationRepliesController.All)
router.Get("/:id", requestForInformationRepliesController.Show)
router.Post("/", requestForInformationRepliesController.Save)
router.Put("/:id", requestForInformationRepliesController.Update)
router.Delete("/:id", requestForInformationRepliesController.Delete)
})
}

View File

@ -0,0 +1,15 @@
package response
import "time"
type RequestForInformationRepliesResponse struct {
ID uint `json:"id"`
RequestForInformationItemId int `json:"request_for_information_item_id"`
FileUrl string `json:"file_url"`
Response string `json:"response"`
StatusId int `json:"status_id"`
CreatedById *uint `json:"created_by_id"`
IsActive *bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@ -0,0 +1,90 @@
package service
import (
"github.com/rs/zerolog"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/request_for_information_replies/mapper"
"go-humas-be/app/module/request_for_information_replies/repository"
"go-humas-be/app/module/request_for_information_replies/request"
"go-humas-be/app/module/request_for_information_replies/response"
usersRepository "go-humas-be/app/module/users/repository"
"go-humas-be/utils/paginator"
utilSvc "go-humas-be/utils/service"
)
// RequestForInformationRepliesService
type requestForInformationRepliesService struct {
Repo repository.RequestForInformationRepliesRepository
UsersRepo usersRepository.UsersRepository
Log zerolog.Logger
}
// RequestForInformationRepliesService define interface of IRequestForInformationRepliesService
type RequestForInformationRepliesService interface {
All(req request.RequestForInformationRepliesQueryRequest) (requestForInformationReplies []*response.RequestForInformationRepliesResponse, paging paginator.Pagination, err error)
Show(id uint) (requestForInformationReplies *response.RequestForInformationRepliesResponse, err error)
Save(req request.RequestForInformationRepliesCreateRequest, authToken string) (requestForInformationReplies *entity.RequestForInformationReplies, err error)
Update(id uint, req request.RequestForInformationRepliesUpdateRequest) (err error)
Delete(id uint) error
}
// NewRequestForInformationRepliesService init RequestForInformationRepliesService
func NewRequestForInformationRepliesService(repo repository.RequestForInformationRepliesRepository, log zerolog.Logger, usersRepo usersRepository.UsersRepository) RequestForInformationRepliesService {
return &requestForInformationRepliesService{
Repo: repo,
Log: log,
UsersRepo: usersRepo,
}
}
// All implement interface of RequestForInformationRepliesService
func (_i *requestForInformationRepliesService) All(req request.RequestForInformationRepliesQueryRequest) (requestForInformationRepliess []*response.RequestForInformationRepliesResponse, paging paginator.Pagination, err error) {
results, paging, err := _i.Repo.GetAll(req)
if err != nil {
return
}
for _, result := range results {
requestForInformationRepliess = append(requestForInformationRepliess, mapper.RequestForInformationRepliesResponseMapper(result))
}
return
}
func (_i *requestForInformationRepliesService) Show(id uint) (requestForInformationReplies *response.RequestForInformationRepliesResponse, err error) {
result, err := _i.Repo.FindOne(id)
if err != nil {
return nil, err
}
return mapper.RequestForInformationRepliesResponseMapper(result), nil
}
func (_i *requestForInformationRepliesService) Save(req request.RequestForInformationRepliesCreateRequest, authToken string) (requestForInformationReplies *entity.RequestForInformationReplies, err error) {
_i.Log.Info().Interface("data", req).Msg("")
newReq := req.ToEntity()
createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
newReq.CreatedById = &createdBy.ID
return _i.Repo.Create(newReq)
}
func (_i *requestForInformationRepliesService) Update(id uint, req request.RequestForInformationRepliesUpdateRequest) (err error) {
_i.Log.Info().Interface("data", req).Msg("")
return _i.Repo.Update(id, req.ToEntity())
}
func (_i *requestForInformationRepliesService) Delete(id uint) error {
result, err := _i.Repo.FindOne(id)
if err != nil {
return err
}
isActive := false
result.IsActive = &isActive
return _i.Repo.Update(id, result)
}

View File

@ -0,0 +1,16 @@
package controller
import (
"github.com/rs/zerolog"
"go-humas-be/app/module/request_for_informations/service"
)
type Controller struct {
RequestForInformations RequestForInformationsController
}
func NewController(RequestForInformationsService service.RequestForInformationsService, log zerolog.Logger) *Controller {
return &Controller{
RequestForInformations: NewRequestForInformationsController(RequestForInformationsService, log),
}
}

View File

@ -0,0 +1,197 @@
package controller
import (
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog"
"go-humas-be/app/module/request_for_informations/request"
"go-humas-be/app/module/request_for_informations/service"
"go-humas-be/utils/paginator"
utilRes "go-humas-be/utils/response"
utilVal "go-humas-be/utils/validator"
"strconv"
)
type requestForInformationsController struct {
requestForInformationsService service.RequestForInformationsService
Log zerolog.Logger
}
type RequestForInformationsController interface {
All(c *fiber.Ctx) error
Show(c *fiber.Ctx) error
Save(c *fiber.Ctx) error
Update(c *fiber.Ctx) error
Delete(c *fiber.Ctx) error
}
func NewRequestForInformationsController(requestForInformationsService service.RequestForInformationsService, log zerolog.Logger) RequestForInformationsController {
return &requestForInformationsController{
requestForInformationsService: requestForInformationsService,
Log: log,
}
}
// All get all RequestForInformations
// @Summary Get all RequestForInformations
// @Description API for getting all RequestForInformations
// @Tags RequestForInformations
// @Security Bearer
// @Param req query request.RequestForInformationsQueryRequest false "query parameters"
// @Param req query paginator.Pagination false "pagination parameters"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-informations [get]
func (_i *requestForInformationsController) All(c *fiber.Ctx) error {
paginate, err := paginator.Paginate(c)
if err != nil {
return err
}
reqContext := request.RequestForInformationsQueryRequestContext{
TicketNumber: c.Query("ticket_number"),
HowToGetInfo: c.Query("how_to_get_info"),
HowToGetFiles: c.Query("how_to_get_files"),
NextAction: c.Query("next_action"),
CreatedById: c.Query("created_by_id"),
StatusId: c.Query("status_id"),
}
req := reqContext.ToParamRequest()
req.Pagination = paginate
requestForInformationsData, paging, err := _i.requestForInformationsService.All(req)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformations list successfully retrieved"},
Data: requestForInformationsData,
Meta: paging,
})
}
// Show get one RequestForInformations
// @Summary Get one RequestForInformations
// @Description API for getting one RequestForInformations
// @Tags RequestForInformations
// @Security Bearer
// @Param id path int true "RequestForInformations ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-informations/:id [get]
func (_i *requestForInformationsController) Show(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
requestForInformationsData, err := _i.requestForInformationsService.Show(uint(id))
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformations successfully retrieved"},
Data: requestForInformationsData,
})
}
// Save create RequestForInformations
// @Summary Create RequestForInformations
// @Description API for create RequestForInformations
// @Tags RequestForInformations
// @Security Bearer
// @Param Authorization header string true "Insert your access token" default(Bearer <Add access token here>)
// @Param payload body request.RequestForInformationsCreateRequest true "Required payload"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-informations [post]
func (_i *requestForInformationsController) Save(c *fiber.Ctx) error {
req := new(request.RequestForInformationsCreateRequest)
if err := utilVal.ParseAndValidate(c, req); err != nil {
return err
}
authToken := c.Get("Authorization")
dataResult, err := _i.requestForInformationsService.Save(*req, authToken)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformations successfully created"},
Data: dataResult,
})
}
// Update update RequestForInformations
// @Summary update RequestForInformations
// @Description API for update RequestForInformations
// @Tags RequestForInformations
// @Security Bearer
// @Param Authorization header string true "Insert your access token" default(Bearer <Add access token here>)
// @Param payload body request.RequestForInformationsUpdateRequest true "Required payload"
// @Param id path int true "RequestForInformations ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-informations/:id [put]
func (_i *requestForInformationsController) Update(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
req := new(request.RequestForInformationsUpdateRequest)
if err := utilVal.ParseAndValidate(c, req); err != nil {
return err
}
err = _i.requestForInformationsService.Update(uint(id), *req)
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformations successfully updated"},
})
}
// Delete delete RequestForInformations
// @Summary delete RequestForInformations
// @Description API for delete RequestForInformations
// @Tags RequestForInformations
// @Security Bearer
// @Param id path int true "RequestForInformations ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /request-for-informations/:id [delete]
func (_i *requestForInformationsController) Delete(c *fiber.Ctx) error {
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
if err != nil {
return err
}
err = _i.requestForInformationsService.Delete(uint(id))
if err != nil {
return err
}
return utilRes.Resp(c, utilRes.Response{
Success: true,
Messages: utilRes.Messages{"RequestForInformations successfully deleted"},
})
}

View File

@ -0,0 +1,24 @@
package mapper
import (
"go-humas-be/app/database/entity"
res "go-humas-be/app/module/request_for_informations/response"
)
func RequestForInformationsResponseMapper(requestForInformationsReq *entity.RequestForInformations) (requestForInformationsRes *res.RequestForInformationsResponse) {
if requestForInformationsReq != nil {
requestForInformationsRes = &res.RequestForInformationsResponse{
ID: requestForInformationsReq.ID,
TicketNumber: requestForInformationsReq.TicketNumber,
HowToGetInfo: requestForInformationsReq.HowToGetInfo,
HowToGetFiles: requestForInformationsReq.HowToGetFiles,
NextAction: requestForInformationsReq.NextAction,
CreatedById: requestForInformationsReq.CreatedById,
StatusId: requestForInformationsReq.StatusId,
IsActive: requestForInformationsReq.IsActive,
CreatedAt: requestForInformationsReq.CreatedAt,
UpdatedAt: requestForInformationsReq.UpdatedAt,
}
}
return requestForInformationsRes
}

View File

@ -0,0 +1,107 @@
package repository
import (
"fmt"
"github.com/rs/zerolog"
"go-humas-be/app/database"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/request_for_informations/request"
"go-humas-be/utils/paginator"
"strings"
)
type requestForInformationsRepository struct {
DB *database.Database
Log zerolog.Logger
}
// RequestForInformationsRepository define interface of IRequestForInformationsRepository
type RequestForInformationsRepository interface {
GetAll(req request.RequestForInformationsQueryRequest) (requestForInformationss []*entity.RequestForInformations, paging paginator.Pagination, err error)
FindOne(id uint) (requestForInformations *entity.RequestForInformations, err error)
Create(requestForInformations *entity.RequestForInformations) (requestForInformationsReturn *entity.RequestForInformations, err error)
Update(id uint, requestForInformations *entity.RequestForInformations) (err error)
Delete(id uint) (err error)
}
func NewRequestForInformationsRepository(db *database.Database, logger zerolog.Logger) RequestForInformationsRepository {
return &requestForInformationsRepository{
DB: db,
Log: logger,
}
}
// implement interface of IRequestForInformationsRepository
func (_i *requestForInformationsRepository) GetAll(req request.RequestForInformationsQueryRequest) (requestForInformationss []*entity.RequestForInformations, paging paginator.Pagination, err error) {
var count int64
query := _i.DB.DB.Model(&entity.RequestForInformations{})
query = query.Where("is_active = ?", true)
if req.TicketNumber != nil && *req.TicketNumber != "" {
ticketNumber := strings.ToLower(*req.TicketNumber)
query = query.Where("LOWER(ticket_number) LIKE ?", "%"+strings.ToLower(ticketNumber)+"%")
}
if req.HowToGetInfo != nil && *req.HowToGetInfo != "" {
howToGetInfo := strings.ToLower(*req.HowToGetInfo)
query = query.Where("LOWER(how_to_get_info) LIKE ?", "%"+strings.ToLower(howToGetInfo)+"%")
}
if req.HowToGetFiles != nil && *req.HowToGetFiles != "" {
howToGetFiles := strings.ToLower(*req.HowToGetFiles)
query = query.Where("LOWER(how_to_get_files) LIKE ?", "%"+strings.ToLower(howToGetFiles)+"%")
}
if req.NextAction != nil && *req.NextAction != "" {
nextAction := strings.ToLower(*req.NextAction)
query = query.Where("LOWER(next_action) LIKE ?", "%"+strings.ToLower(nextAction)+"%")
}
if req.CreatedById != nil {
query = query.Where("created_by_id = ?", req.CreatedById)
}
if req.StatusId != nil {
query = query.Where("status_id = ?", req.StatusId)
}
query.Count(&count)
if req.Pagination.SortBy != "" {
direction := "ASC"
if req.Pagination.Sort == "desc" {
direction = "DESC"
}
query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction))
}
req.Pagination.Count = count
req.Pagination = paginator.Paging(req.Pagination)
err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&requestForInformationss).Error
if err != nil {
return
}
paging = *req.Pagination
return
}
func (_i *requestForInformationsRepository) FindOne(id uint) (requestForInformations *entity.RequestForInformations, err error) {
if err := _i.DB.DB.First(&requestForInformations, id).Error; err != nil {
return nil, err
}
return requestForInformations, nil
}
func (_i *requestForInformationsRepository) Create(requestForInformations *entity.RequestForInformations) (requestForInformationsReturn *entity.RequestForInformations, err error) {
result := _i.DB.DB.Create(requestForInformations)
return requestForInformations, result.Error
}
func (_i *requestForInformationsRepository) Update(id uint, requestForInformations *entity.RequestForInformations) (err error) {
return _i.DB.DB.Model(&entity.RequestForInformations{}).
Where(&entity.RequestForInformations{ID: id}).
Updates(requestForInformations).Error
}
func (_i *requestForInformationsRepository) Delete(id uint) error {
return _i.DB.DB.Delete(&entity.RequestForInformations{}, id).Error
}

View File

@ -0,0 +1,102 @@
package request
import (
"go-humas-be/app/database/entity"
"go-humas-be/utils/paginator"
"strconv"
"time"
)
type RequestForInformationsGeneric interface {
ToEntity()
}
type RequestForInformationsQueryRequest struct {
TicketNumber *string `json:"ticket_number"`
HowToGetInfo *string `json:"how_to_get_info"`
HowToGetFiles *string `json:"how_to_get_files"`
NextAction *string `json:"next_action"`
CreatedById *int `json:"created_by_id"`
StatusId *int `json:"status_id"`
Pagination *paginator.Pagination `json:"pagination"`
}
type RequestForInformationsCreateRequest struct {
TicketNumber string `json:"ticket_number" validate:"required"`
HowToGetInfo string `json:"how_to_get_info" validate:"required"`
HowToGetFiles string `json:"how_to_get_files" validate:"required"`
NextAction string `json:"next_action" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
}
func (req RequestForInformationsCreateRequest) ToEntity() *entity.RequestForInformations {
return &entity.RequestForInformations{
TicketNumber: req.TicketNumber,
HowToGetInfo: req.HowToGetInfo,
HowToGetFiles: req.HowToGetFiles,
NextAction: req.NextAction,
StatusId: req.StatusId,
IsActive: func() *bool { b := true; return &b }(),
}
}
type RequestForInformationsUpdateRequest struct {
ID uint `json:"id" validate:"required"`
TicketNumber string `json:"ticket_number" validate:"required"`
HowToGetInfo string `json:"how_to_get_info" validate:"required"`
HowToGetFiles string `json:"how_to_get_files" validate:"required"`
NextAction string `json:"next_action" validate:"required"`
StatusId int `json:"status_id" validate:"required"`
}
func (req RequestForInformationsUpdateRequest) ToEntity() *entity.RequestForInformations {
return &entity.RequestForInformations{
ID: req.ID,
TicketNumber: req.TicketNumber,
HowToGetInfo: req.HowToGetInfo,
HowToGetFiles: req.HowToGetFiles,
NextAction: req.NextAction,
StatusId: req.StatusId,
UpdatedAt: time.Now(),
}
}
type RequestForInformationsQueryRequestContext struct {
TicketNumber string `json:"ticket_number"`
HowToGetInfo string `json:"how_to_get_info"`
HowToGetFiles string `json:"how_to_get_files"`
NextAction string `json:"next_action"`
CreatedById string `json:"created_by_id"`
StatusId string `json:"status_id"`
}
func (req RequestForInformationsQueryRequestContext) ToParamRequest() RequestForInformationsQueryRequest {
var request RequestForInformationsQueryRequest
if ticketNumber := req.TicketNumber; ticketNumber != "" {
request.TicketNumber = &ticketNumber
}
if howToGetInfo := req.HowToGetInfo; howToGetInfo != "" {
request.HowToGetInfo = &howToGetInfo
}
if howToGetFiles := req.HowToGetFiles; howToGetFiles != "" {
request.HowToGetFiles = &howToGetFiles
}
if nextAction := req.NextAction; nextAction != "" {
request.NextAction = &nextAction
}
if createdByIdStr := req.CreatedById; createdByIdStr != "" {
createdById, err := strconv.Atoi(createdByIdStr)
if err == nil {
request.CreatedById = &createdById
}
}
if statusIdStr := req.StatusId; statusIdStr != "" {
statusId, err := strconv.Atoi(statusIdStr)
if err == nil {
request.StatusId = &statusId
}
}
return request
}

View File

@ -0,0 +1,53 @@
package request_for_informations
import (
"github.com/gofiber/fiber/v2"
"go-humas-be/app/module/request_for_informations/controller"
"go-humas-be/app/module/request_for_informations/repository"
"go-humas-be/app/module/request_for_informations/service"
"go.uber.org/fx"
)
// struct of RequestForInformationsRouter
type RequestForInformationsRouter struct {
App fiber.Router
Controller *controller.Controller
}
// register bulky of RequestForInformations module
var NewRequestForInformationsModule = fx.Options(
// register repository of RequestForInformations module
fx.Provide(repository.NewRequestForInformationsRepository),
// register service of RequestForInformations module
fx.Provide(service.NewRequestForInformationsService),
// register controller of RequestForInformations module
fx.Provide(controller.NewController),
// register router of RequestForInformations module
fx.Provide(NewRequestForInformationsRouter),
)
// init RequestForInformationsRouter
func NewRequestForInformationsRouter(fiber *fiber.App, controller *controller.Controller) *RequestForInformationsRouter {
return &RequestForInformationsRouter{
App: fiber,
Controller: controller,
}
}
// register routes of RequestForInformations module
func (_i *RequestForInformationsRouter) RegisterRequestForInformationsRoutes() {
// define controllers
requestForInformationsController := _i.Controller.RequestForInformations
// define routes
_i.App.Route("/request-for-informations", func(router fiber.Router) {
router.Get("/", requestForInformationsController.All)
router.Get("/:id", requestForInformationsController.Show)
router.Post("/", requestForInformationsController.Save)
router.Put("/:id", requestForInformationsController.Update)
router.Delete("/:id", requestForInformationsController.Delete)
})
}

View File

@ -0,0 +1,16 @@
package response
import "time"
type RequestForInformationsResponse struct {
ID uint `json:"id"`
TicketNumber string `json:"ticket_number"`
HowToGetInfo string `json:"how_to_get_info"`
HowToGetFiles string `json:"how_to_get_files"`
NextAction string `json:"next_action"`
CreatedById *uint `json:"created_by_id"`
StatusId int `json:"status_id"`
IsActive *bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@ -0,0 +1,89 @@
package service
import (
"github.com/rs/zerolog"
"go-humas-be/app/database/entity"
"go-humas-be/app/module/request_for_informations/mapper"
"go-humas-be/app/module/request_for_informations/repository"
"go-humas-be/app/module/request_for_informations/request"
"go-humas-be/app/module/request_for_informations/response"
usersRepository "go-humas-be/app/module/users/repository"
"go-humas-be/utils/paginator"
utilSvc "go-humas-be/utils/service"
)
// RequestForInformationsService
type requestForInformationsService struct {
Repo repository.RequestForInformationsRepository
UsersRepo usersRepository.UsersRepository
Log zerolog.Logger
}
// RequestForInformationsService define interface of IRequestForInformationsService
type RequestForInformationsService interface {
All(req request.RequestForInformationsQueryRequest) (requestForInformations []*response.RequestForInformationsResponse, paging paginator.Pagination, err error)
Show(id uint) (requestForInformations *response.RequestForInformationsResponse, err error)
Save(req request.RequestForInformationsCreateRequest, authToken string) (requestForInformations *entity.RequestForInformations, err error)
Update(id uint, req request.RequestForInformationsUpdateRequest) (err error)
Delete(id uint) error
}
// NewRequestForInformationsService init RequestForInformationsService
func NewRequestForInformationsService(repo repository.RequestForInformationsRepository, log zerolog.Logger, usersRepo usersRepository.UsersRepository) RequestForInformationsService {
return &requestForInformationsService{
Repo: repo,
Log: log,
UsersRepo: usersRepo,
}
}
// All implement interface of RequestForInformationsService
func (_i *requestForInformationsService) All(req request.RequestForInformationsQueryRequest) (requestForInformationss []*response.RequestForInformationsResponse, paging paginator.Pagination, err error) {
results, paging, err := _i.Repo.GetAll(req)
if err != nil {
return
}
for _, result := range results {
requestForInformationss = append(requestForInformationss, mapper.RequestForInformationsResponseMapper(result))
}
return
}
func (_i *requestForInformationsService) Show(id uint) (requestForInformations *response.RequestForInformationsResponse, err error) {
result, err := _i.Repo.FindOne(id)
if err != nil {
return nil, err
}
return mapper.RequestForInformationsResponseMapper(result), nil
}
func (_i *requestForInformationsService) Save(req request.RequestForInformationsCreateRequest, authToken string) (requestForInformations *entity.RequestForInformations, err error) {
_i.Log.Info().Interface("data", req).Msg("")
newReq := req.ToEntity()
createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
newReq.CreatedById = &createdBy.ID
return _i.Repo.Create(newReq)
}
func (_i *requestForInformationsService) Update(id uint, req request.RequestForInformationsUpdateRequest) (err error) {
_i.Log.Info().Interface("data", req).Msg("")
return _i.Repo.Update(id, req.ToEntity())
}
func (_i *requestForInformationsService) Delete(id uint) error {
result, err := _i.Repo.FindOne(id)
if err != nil {
return err
}
isActive := false
result.IsActive = &isActive
return _i.Repo.Update(id, result)
}

View File

@ -17,6 +17,9 @@ import (
"go-humas-be/app/module/ppid_data_files"
"go-humas-be/app/module/ppid_datas"
"go-humas-be/app/module/provinces"
"go-humas-be/app/module/request_for_information_items"
"go-humas-be/app/module/request_for_information_replies"
"go-humas-be/app/module/request_for_informations"
"go-humas-be/app/module/user_levels"
"go-humas-be/app/module/user_role_accesses"
"go-humas-be/app/module/user_roles"
@ -29,24 +32,27 @@ type Router struct {
App fiber.Router
Cfg *config.Config
ArticleCategoriesRouter *article_categories.ArticleCategoriesRouter
ArticleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter
ArticleFilesRouter *article_files.ArticleFilesRouter
ArticlesRouter *articles.ArticlesRouter
CitiesRouter *cities.CitiesRouter
DistrictsRouter *districts.DistrictsRouter
MagazineFilesRouter *magazine_files.MagazineFilesRouter
MagazinesRouter *magazines.MagazinesRouter
MasterMenusRouter *master_menus.MasterMenusRouter
MasterModulesRouter *master_modules.MasterModulesRouter
PpidDataCategoriesRouter *ppid_data_categories.PpidDataCategoriesRouter
PpidDataFilesRouter *ppid_data_files.PpidDataFilesRouter
PpidDatas *ppid_datas.PpidDatasRouter
ProvincesRouter *provinces.ProvincesRouter
UserLevelsRouter *user_levels.UserLevelsRouter
UserRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter
UserRolesRouter *user_roles.UserRolesRouter
UsersRouter *users.UsersRouter
ArticleCategoriesRouter *article_categories.ArticleCategoriesRouter
ArticleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter
ArticleFilesRouter *article_files.ArticleFilesRouter
ArticlesRouter *articles.ArticlesRouter
CitiesRouter *cities.CitiesRouter
DistrictsRouter *districts.DistrictsRouter
MagazineFilesRouter *magazine_files.MagazineFilesRouter
MagazinesRouter *magazines.MagazinesRouter
MasterMenusRouter *master_menus.MasterMenusRouter
MasterModulesRouter *master_modules.MasterModulesRouter
PpidDataCategoriesRouter *ppid_data_categories.PpidDataCategoriesRouter
PpidDataFilesRouter *ppid_data_files.PpidDataFilesRouter
PpidDatasRouter *ppid_datas.PpidDatasRouter
ProvincesRouter *provinces.ProvincesRouter
RequestForInformationsRouter *request_for_informations.RequestForInformationsRouter
RequestForInformationItemsRouter *request_for_information_items.RequestForInformationItemsRouter
RequestForInformationRepliesRouter *request_for_information_replies.RequestForInformationRepliesRouter
UserLevelsRouter *user_levels.UserLevelsRouter
UserRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter
UserRolesRouter *user_roles.UserRolesRouter
UsersRouter *users.UsersRouter
}
func NewRouter(
@ -65,34 +71,40 @@ func NewRouter(
masterModuleRouter *master_modules.MasterModulesRouter,
ppidDataCategoriesRouter *ppid_data_categories.PpidDataCategoriesRouter,
ppidDataFilesRouter *ppid_data_files.PpidDataFilesRouter,
ppidDatas *ppid_datas.PpidDatasRouter,
ppidDatasRouter *ppid_datas.PpidDatasRouter,
provincesRouter *provinces.ProvincesRouter,
requestForInformationsRouter *request_for_informations.RequestForInformationsRouter,
requestForInformationItemsRouter *request_for_information_items.RequestForInformationItemsRouter,
requestForInformationRepliesRouter *request_for_information_replies.RequestForInformationRepliesRouter,
userLevelsRouter *user_levels.UserLevelsRouter,
userRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter,
userRolesRouter *user_roles.UserRolesRouter,
usersRouter *users.UsersRouter,
) *Router {
return &Router{
App: fiber,
Cfg: cfg,
ArticleCategoriesRouter: articleCategoriesRouter,
ArticleCategoryDetailsRouter: articleCategoryDetailsRouter,
ArticleFilesRouter: articleFilesRouter,
ArticlesRouter: articlesRouter,
CitiesRouter: citiesRouter,
DistrictsRouter: districtsRouter,
MagazineFilesRouter: magazineFilesRouter,
MagazinesRouter: magazinesRouter,
MasterMenusRouter: masterMenuRouter,
MasterModulesRouter: masterModuleRouter,
PpidDataCategoriesRouter: ppidDataCategoriesRouter,
PpidDataFilesRouter: ppidDataFilesRouter,
PpidDatas: ppidDatas,
ProvincesRouter: provincesRouter,
UserLevelsRouter: userLevelsRouter,
UserRoleAccessesRouter: userRoleAccessesRouter,
UserRolesRouter: userRolesRouter,
UsersRouter: usersRouter,
App: fiber,
Cfg: cfg,
ArticleCategoriesRouter: articleCategoriesRouter,
ArticleCategoryDetailsRouter: articleCategoryDetailsRouter,
ArticleFilesRouter: articleFilesRouter,
ArticlesRouter: articlesRouter,
CitiesRouter: citiesRouter,
DistrictsRouter: districtsRouter,
MagazineFilesRouter: magazineFilesRouter,
MagazinesRouter: magazinesRouter,
MasterMenusRouter: masterMenuRouter,
MasterModulesRouter: masterModuleRouter,
PpidDataCategoriesRouter: ppidDataCategoriesRouter,
PpidDataFilesRouter: ppidDataFilesRouter,
PpidDatasRouter: ppidDatasRouter,
ProvincesRouter: provincesRouter,
RequestForInformationsRouter: requestForInformationsRouter,
RequestForInformationItemsRouter: requestForInformationItemsRouter,
RequestForInformationRepliesRouter: requestForInformationRepliesRouter,
UserLevelsRouter: userLevelsRouter,
UserRoleAccessesRouter: userRoleAccessesRouter,
UserRolesRouter: userRolesRouter,
UsersRouter: usersRouter,
}
}
@ -119,8 +131,11 @@ func (r *Router) Register() {
r.MasterModulesRouter.RegisterMasterModulesRoutes()
r.PpidDataCategoriesRouter.RegisterPpidDataCategoriesRoutes()
r.PpidDataFilesRouter.RegisterPpidDataFilesRoutes()
r.PpidDatas.RegisterPpidDatasRoutes()
r.PpidDatasRouter.RegisterPpidDatasRoutes()
r.ProvincesRouter.RegisterProvincesRoutes()
r.RequestForInformationsRouter.RegisterRequestForInformationsRoutes()
r.RequestForInformationItemsRouter.RegisterRequestForInformationItemsRoutes()
r.RequestForInformationRepliesRouter.RegisterRequestForInformationRepliesRoutes()
r.UserLevelsRouter.RegisterUserLevelsRoutes()
r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes()
r.UsersRouter.RegisterUsersRoutes()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -369,6 +369,115 @@ definitions:
- id
- position
type: object
request.RequestForInformationItemsCreateRequest:
properties:
reason:
type: string
requested_info:
type: string
status_id:
type: integer
required:
- reason
- requested_info
- status_id
type: object
request.RequestForInformationItemsUpdateRequest:
properties:
id:
type: integer
reason:
type: string
requested_info:
type: string
status_id:
type: integer
updated_at:
type: string
required:
- id
- reason
- requested_info
- status_id
type: object
request.RequestForInformationRepliesCreateRequest:
properties:
file_url:
type: string
request_for_information_item_id:
type: integer
response:
type: string
status_id:
type: integer
required:
- file_url
- request_for_information_item_id
- response
- status_id
type: object
request.RequestForInformationRepliesUpdateRequest:
properties:
file_url:
type: string
id:
type: integer
request_for_information_item_id:
type: integer
response:
type: string
status_id:
type: integer
updated_at:
type: string
required:
- file_url
- id
- request_for_information_item_id
- response
- status_id
type: object
request.RequestForInformationsCreateRequest:
properties:
how_to_get_files:
type: string
how_to_get_info:
type: string
next_action:
type: string
status_id:
type: integer
ticket_number:
type: string
required:
- how_to_get_files
- how_to_get_info
- next_action
- status_id
- ticket_number
type: object
request.RequestForInformationsUpdateRequest:
properties:
how_to_get_files:
type: string
how_to_get_info:
type: string
id:
type: integer
next_action:
type: string
status_id:
type: integer
ticket_number:
type: string
required:
- how_to_get_files
- how_to_get_info
- id
- next_action
- status_id
- ticket_number
type: object
request.UserLevelsCreateRequest:
properties:
aliasName:
@ -4002,6 +4111,585 @@ paths:
summary: Update Provinces
tags:
- Untags
/request-for-information-items:
get:
description: API for getting all RequestForInformationItems
parameters:
- in: query
name: reason
type: string
- in: query
name: requested_info
type: string
- in: query
name: status_id
type: integer
- in: query
name: count
type: integer
- in: query
name: limit
type: integer
- in: query
name: nextPage
type: integer
- in: query
name: page
type: integer
- in: query
name: previousPage
type: integer
- in: query
name: sort
type: string
- in: query
name: sortBy
type: string
- in: query
name: totalPage
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: Get all RequestForInformationItems
tags:
- RequestForInformationItems
post:
description: API for create RequestForInformationItems
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.RequestForInformationItemsCreateRequest'
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: Create RequestForInformationItems
tags:
- RequestForInformationItems
/request-for-information-items/:id:
delete:
description: API for delete RequestForInformationItems
parameters:
- description: RequestForInformationItems ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: delete RequestForInformationItems
tags:
- RequestForInformationItems
get:
description: API for getting one RequestForInformationItems
parameters:
- description: RequestForInformationItems 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 RequestForInformationItems
tags:
- RequestForInformationItems
put:
description: API for update RequestForInformationItems
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.RequestForInformationItemsUpdateRequest'
- description: RequestForInformationItems ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: update RequestForInformationItems
tags:
- RequestForInformationItems
/request-for-information-replies:
get:
description: API for getting all RequestForInformationReplies
parameters:
- in: query
name: file_url
type: string
- in: query
name: request_for_information_item_id
type: integer
- in: query
name: response
type: string
- in: query
name: status_id
type: integer
- in: query
name: count
type: integer
- in: query
name: limit
type: integer
- in: query
name: nextPage
type: integer
- in: query
name: page
type: integer
- in: query
name: previousPage
type: integer
- in: query
name: sort
type: string
- in: query
name: sortBy
type: string
- in: query
name: totalPage
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: Get all RequestForInformationReplies
tags:
- RequestForInformationReplies
post:
description: API for create RequestForInformationReplies
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.RequestForInformationRepliesCreateRequest'
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: Create RequestForInformationReplies
tags:
- RequestForInformationReplies
/request-for-information-replies/:id:
delete:
description: API for delete RequestForInformationReplies
parameters:
- description: RequestForInformationReplies ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: delete RequestForInformationReplies
tags:
- RequestForInformationReplies
get:
description: API for getting one RequestForInformationReplies
parameters:
- description: RequestForInformationReplies 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 RequestForInformationReplies
tags:
- RequestForInformationReplies
put:
description: API for update RequestForInformationReplies
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.RequestForInformationRepliesUpdateRequest'
- description: RequestForInformationReplies ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: update RequestForInformationReplies
tags:
- RequestForInformationReplies
/request-for-informations:
get:
description: API for getting all RequestForInformations
parameters:
- in: query
name: created_by_id
type: integer
- in: query
name: how_to_get_files
type: string
- in: query
name: how_to_get_info
type: string
- in: query
name: next_action
type: string
- in: query
name: status_id
type: integer
- in: query
name: ticket_number
type: string
- in: query
name: count
type: integer
- in: query
name: limit
type: integer
- in: query
name: nextPage
type: integer
- in: query
name: page
type: integer
- in: query
name: previousPage
type: integer
- in: query
name: sort
type: string
- in: query
name: sortBy
type: string
- in: query
name: totalPage
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: Get all RequestForInformations
tags:
- RequestForInformations
post:
description: API for create RequestForInformations
parameters:
- default: Bearer <Add access token here>
description: Insert your access token
in: header
name: Authorization
required: true
type: string
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.RequestForInformationsCreateRequest'
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: Create RequestForInformations
tags:
- RequestForInformations
/request-for-informations/:id:
delete:
description: API for delete RequestForInformations
parameters:
- description: RequestForInformations ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: delete RequestForInformations
tags:
- RequestForInformations
get:
description: API for getting one RequestForInformations
parameters:
- description: RequestForInformations 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 RequestForInformations
tags:
- RequestForInformations
put:
description: API for update RequestForInformations
parameters:
- description: Required payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/request.RequestForInformationsUpdateRequest'
- description: RequestForInformations ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.BadRequestError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.UnauthorizedError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.InternalServerError'
security:
- Bearer: []
summary: update RequestForInformations
tags:
- RequestForInformations
/user-levels:
get:
description: API for getting all UserLevels

View File

@ -19,6 +19,9 @@ import (
"go-humas-be/app/module/ppid_data_files"
"go-humas-be/app/module/ppid_datas"
"go-humas-be/app/module/provinces"
"go-humas-be/app/module/request_for_information_items"
"go-humas-be/app/module/request_for_information_replies"
"go-humas-be/app/module/request_for_informations"
"go-humas-be/app/module/user_levels"
"go-humas-be/app/module/user_role_accesses"
"go-humas-be/app/module/user_role_level_details"
@ -73,6 +76,9 @@ func main() {
user_role_accesses.NewUserRoleAccessesModule,
users.NewUsersModule,
user_role_level_details.NewUserRoleLevelDetailsModule,
request_for_informations.NewRequestForInformationsModule,
request_for_information_items.NewRequestForInformationItemsModule,
request_for_information_replies.NewRequestForInformationRepliesModule,
// start aplication
fx.Invoke(webserver.Start),