From e2088d737e5ade4bad55c77414d38f61656f8107 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 11 Jul 2024 00:16:47 +0700 Subject: [PATCH] feat: add RequestForInformationObjectionReplies --- ...or_information_objection_replies.entity.go | 14 + app/database/entity/users.entity.go | 44 +- app/database/index.database.go | 1 + .../controller/controller.go | 16 + ...nformation_objection_replies.controller.go | 193 +++++++++ ...or_information_objection_replies.mapper.go | 22 + ...nformation_objection_replies.repository.go | 98 +++++ ...r_information_objection_replies.request.go | 89 ++++ ...or_information_objection_replies.module.go | 53 +++ ..._information_objection_replies.response.go | 14 + ...r_information_objection_replies.service.go | 90 ++++ .../users/controller/users.controller.go | 20 +- .../users/repository/users.repository.go | 15 + app/module/users/request/users.request.go | 176 ++++---- app/router/api.go | 57 +-- config/toml/config.toml | 2 +- docs/swagger/docs.go | 401 ++++++++++++++++++ docs/swagger/swagger.json | 401 ++++++++++++++++++ docs/swagger/swagger.yaml | 257 +++++++++++ main.go | 2 + 20 files changed, 1837 insertions(+), 128 deletions(-) create mode 100644 app/database/entity/request_for_information_objection_replies.entity.go create mode 100644 app/module/request_for_information_objection_replies/controller/controller.go create mode 100644 app/module/request_for_information_objection_replies/controller/request_for_information_objection_replies.controller.go create mode 100644 app/module/request_for_information_objection_replies/mapper/request_for_information_objection_replies.mapper.go create mode 100644 app/module/request_for_information_objection_replies/repository/request_for_information_objection_replies.repository.go create mode 100644 app/module/request_for_information_objection_replies/request/request_for_information_objection_replies.request.go create mode 100644 app/module/request_for_information_objection_replies/request_for_information_objection_replies.module.go create mode 100644 app/module/request_for_information_objection_replies/response/request_for_information_objection_replies.response.go create mode 100644 app/module/request_for_information_objection_replies/service/request_for_information_objection_replies.service.go diff --git a/app/database/entity/request_for_information_objection_replies.entity.go b/app/database/entity/request_for_information_objection_replies.entity.go new file mode 100644 index 0000000..911b849 --- /dev/null +++ b/app/database/entity/request_for_information_objection_replies.entity.go @@ -0,0 +1,14 @@ +package entity + +import "time" + +type RequestForInformationObjectionReplies struct { + ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` + RequestForInformationObjectionId int `json:"request_for_information_objection_id" gorm:"type:int4"` + 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()"` +} diff --git a/app/database/entity/users.entity.go b/app/database/entity/users.entity.go index 06d2b7c..ddd3bb8 100644 --- a/app/database/entity/users.entity.go +++ b/app/database/entity/users.entity.go @@ -3,25 +3,27 @@ package entity import "time" type Users struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Username string `json:"username" gorm:"type:varchar"` - Email string `json:"email" gorm:"type:varchar"` - Fullname string `json:"fullname" gorm:"type:varchar"` - Address string `json:"address" gorm:"type:varchar"` - PhoneNumber string `json:"phone_number" gorm:"type:varchar"` - WorkType string `json:"work_type" gorm:"type:varchar"` - GenderType string `json:"gender_type" gorm:"type:varchar"` - IdentityType string `json:"identity_type" gorm:"type:varchar"` - IdentityNumber string `json:"identity_number" gorm:"type:varchar"` - DateOfBirth string `json:"date_of_birth" gorm:"type:varchar"` - LastEducation string `json:"last_education" gorm:"type:varchar"` - UserRoleId uint `json:"user_role_id" gorm:"type:int4"` - UserLevelId uint `json:"user_level_id" gorm:"type:int4"` - KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"` - StatusId *int `json:"status_id" gorm:"type:int4;default:1"` - CreatedById *uint `json:"created_by_id" gorm:"type:int4"` - ProfilePicturePath *string `json:"profile_picture_path" gorm:"type:varchar"` - 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()"` + ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` + Username string `json:"username" gorm:"type:varchar"` + Email string `json:"email" gorm:"type:varchar"` + Fullname string `json:"fullname" gorm:"type:varchar"` + Address string `json:"address" gorm:"type:varchar"` + PhoneNumber string `json:"phone_number" gorm:"type:varchar"` + WorkType string `json:"work_type" gorm:"type:varchar"` + GenderType string `json:"gender_type" gorm:"type:varchar"` + IdentityType string `json:"identity_type" gorm:"type:varchar"` + IdentityGroup string `json:"identity_group" gorm:"type:varchar"` + IdentityGroupNumber string `json:"identity_group_number" gorm:"type:varchar"` + IdentityNumber string `json:"identity_number" gorm:"type:varchar"` + DateOfBirth string `json:"date_of_birth" gorm:"type:varchar"` + LastEducation string `json:"last_education" gorm:"type:varchar"` + UserRoleId uint `json:"user_role_id" gorm:"type:int4"` + UserLevelId uint `json:"user_level_id" gorm:"type:int4"` + KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"` + StatusId *int `json:"status_id" gorm:"type:int4;default:1"` + CreatedById *uint `json:"created_by_id" gorm:"type:int4"` + ProfilePicturePath *string `json:"profile_picture_path" gorm:"type:varchar"` + 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()"` } diff --git a/app/database/index.database.go b/app/database/index.database.go index 652b741..34ea2f9 100644 --- a/app/database/index.database.go +++ b/app/database/index.database.go @@ -88,6 +88,7 @@ func Models() []interface{} { entity.RequestForInformationItems{}, entity.RequestForInformationReplies{}, entity.RequestForInformationObjection{}, + entity.RequestForInformationObjectionReplies{}, entity.UserLevels{}, entity.UserRoles{}, entity.UserRoleAccesses{}, diff --git a/app/module/request_for_information_objection_replies/controller/controller.go b/app/module/request_for_information_objection_replies/controller/controller.go new file mode 100644 index 0000000..68f2523 --- /dev/null +++ b/app/module/request_for_information_objection_replies/controller/controller.go @@ -0,0 +1,16 @@ +package controller + +import ( + "github.com/rs/zerolog" + "go-humas-be/app/module/request_for_information_objection_replies/service" +) + +type Controller struct { + RequestForInformationObjectionReplies RequestForInformationObjectionRepliesController +} + +func NewController(RequestForInformationObjectionRepliesService service.RequestForInformationObjectionRepliesService, log zerolog.Logger) *Controller { + return &Controller{ + RequestForInformationObjectionReplies: NewRequestForInformationObjectionRepliesController(RequestForInformationObjectionRepliesService, log), + } +} diff --git a/app/module/request_for_information_objection_replies/controller/request_for_information_objection_replies.controller.go b/app/module/request_for_information_objection_replies/controller/request_for_information_objection_replies.controller.go new file mode 100644 index 0000000..cc506d3 --- /dev/null +++ b/app/module/request_for_information_objection_replies/controller/request_for_information_objection_replies.controller.go @@ -0,0 +1,193 @@ +package controller + +import ( + "github.com/gofiber/fiber/v2" + "github.com/rs/zerolog" + "go-humas-be/app/module/request_for_information_objection_replies/request" + "go-humas-be/app/module/request_for_information_objection_replies/service" + "go-humas-be/utils/paginator" + utilRes "go-humas-be/utils/response" + utilVal "go-humas-be/utils/validator" + "strconv" +) + +type requestForInformationObjectionRepliesController struct { + requestForInformationObjectionRepliesService service.RequestForInformationObjectionRepliesService + Log zerolog.Logger +} + +type RequestForInformationObjectionRepliesController 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 NewRequestForInformationObjectionRepliesController(requestForInformationObjectionRepliesService service.RequestForInformationObjectionRepliesService, log zerolog.Logger) RequestForInformationObjectionRepliesController { + return &requestForInformationObjectionRepliesController{ + requestForInformationObjectionRepliesService: requestForInformationObjectionRepliesService, + Log: log, + } +} + +// All get all RequestForInformationObjectionReplies +// @Summary Get all RequestForInformationObjectionReplies +// @Description API for getting all RequestForInformationObjectionReplies +// @Tags RequestForInformationObjectionReplies +// @Security Bearer +// @Param req query request.RequestForInformationObjectionRepliesQueryRequest 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-objection-replies [get] +func (_i *requestForInformationObjectionRepliesController) All(c *fiber.Ctx) error { + paginate, err := paginator.Paginate(c) + if err != nil { + return err + } + + reqContext := request.RequestForInformationObjectionRepliesQueryRequestContext{ + RequestForInformationObjectionId: c.Query("requestForInformationObjectionId"), + Response: c.Query("response"), + StatusId: c.Query("statusId"), + } + req := reqContext.ToParamRequest() + req.Pagination = paginate + + requestForInformationObjectionRepliesData, paging, err := _i.requestForInformationObjectionRepliesService.All(req) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"RequestForInformationObjectionReplies list successfully retrieved"}, + Data: requestForInformationObjectionRepliesData, + Meta: paging, + }) +} + +// Show get one RequestForInformationObjectionReplies +// @Summary Get one RequestForInformationObjectionReplies +// @Description API for getting one RequestForInformationObjectionReplies +// @Tags RequestForInformationObjectionReplies +// @Security Bearer +// @Param id path int true "RequestForInformationObjectionReplies 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-objection-replies/{id} [get] +func (_i *requestForInformationObjectionRepliesController) Show(c *fiber.Ctx) error { + id, err := strconv.ParseUint(c.Params("id"), 10, 0) + if err != nil { + return err + } + + requestForInformationObjectionRepliesData, err := _i.requestForInformationObjectionRepliesService.Show(uint(id)) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"RequestForInformationObjectionReplies successfully retrieved"}, + Data: requestForInformationObjectionRepliesData, + }) +} + +// Save create RequestForInformationObjectionReplies +// @Summary Create RequestForInformationObjectionReplies +// @Description API for create RequestForInformationObjectionReplies +// @Tags RequestForInformationObjectionReplies +// @Security Bearer +// @Param Authorization header string true "Insert your access token" default(Bearer ) +// @Param payload body request.RequestForInformationObjectionRepliesCreateRequest 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-objection-replies [post] +func (_i *requestForInformationObjectionRepliesController) Save(c *fiber.Ctx) error { + req := new(request.RequestForInformationObjectionRepliesCreateRequest) + if err := utilVal.ParseAndValidate(c, req); err != nil { + return err + } + + authToken := c.Get("Authorization") + dataResult, err := _i.requestForInformationObjectionRepliesService.Save(*req, authToken) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"RequestForInformationObjectionReplies successfully created"}, + Data: dataResult, + }) +} + +// Update update RequestForInformationObjectionReplies +// @Summary update RequestForInformationObjectionReplies +// @Description API for update RequestForInformationObjectionReplies +// @Tags RequestForInformationObjectionReplies +// @Security Bearer +// @Param payload body request.RequestForInformationObjectionRepliesUpdateRequest true "Required payload" +// @Param id path int true "RequestForInformationObjectionReplies 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-objection-replies/{id} [put] +func (_i *requestForInformationObjectionRepliesController) Update(c *fiber.Ctx) error { + id, err := strconv.ParseUint(c.Params("id"), 10, 0) + if err != nil { + return err + } + + req := new(request.RequestForInformationObjectionRepliesUpdateRequest) + if err := utilVal.ParseAndValidate(c, req); err != nil { + return err + } + + err = _i.requestForInformationObjectionRepliesService.Update(uint(id), *req) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"RequestForInformationObjectionReplies successfully updated"}, + }) +} + +// Delete delete RequestForInformationObjectionReplies +// @Summary delete RequestForInformationObjectionReplies +// @Description API for delete RequestForInformationObjectionReplies +// @Tags RequestForInformationObjectionReplies +// @Security Bearer +// @Param id path int true "RequestForInformationObjectionReplies 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-objection-replies/{id} [delete] +func (_i *requestForInformationObjectionRepliesController) Delete(c *fiber.Ctx) error { + id, err := strconv.ParseUint(c.Params("id"), 10, 0) + if err != nil { + return err + } + + err = _i.requestForInformationObjectionRepliesService.Delete(uint(id)) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"RequestForInformationObjectionReplies successfully deleted"}, + }) +} diff --git a/app/module/request_for_information_objection_replies/mapper/request_for_information_objection_replies.mapper.go b/app/module/request_for_information_objection_replies/mapper/request_for_information_objection_replies.mapper.go new file mode 100644 index 0000000..1ba20ba --- /dev/null +++ b/app/module/request_for_information_objection_replies/mapper/request_for_information_objection_replies.mapper.go @@ -0,0 +1,22 @@ +package mapper + +import ( + "go-humas-be/app/database/entity" + res "go-humas-be/app/module/request_for_information_objection_replies/response" +) + +func RequestForInformationObjectionRepliesResponseMapper(requestForInformationObjectionRepliesReq *entity.RequestForInformationObjectionReplies) (requestForInformationObjectionRepliesRes *res.RequestForInformationObjectionRepliesResponse) { + if requestForInformationObjectionRepliesReq != nil { + requestForInformationObjectionRepliesRes = &res.RequestForInformationObjectionRepliesResponse{ + ID: requestForInformationObjectionRepliesReq.ID, + RequestForInformationObjectionId: requestForInformationObjectionRepliesReq.RequestForInformationObjectionId, + Response: requestForInformationObjectionRepliesReq.Response, + StatusId: requestForInformationObjectionRepliesReq.StatusId, + CreatedById: requestForInformationObjectionRepliesReq.CreatedById, + IsActive: requestForInformationObjectionRepliesReq.IsActive, + CreatedAt: requestForInformationObjectionRepliesReq.CreatedAt, + UpdatedAt: requestForInformationObjectionRepliesReq.UpdatedAt, + } + } + return requestForInformationObjectionRepliesRes +} diff --git a/app/module/request_for_information_objection_replies/repository/request_for_information_objection_replies.repository.go b/app/module/request_for_information_objection_replies/repository/request_for_information_objection_replies.repository.go new file mode 100644 index 0000000..9b9135d --- /dev/null +++ b/app/module/request_for_information_objection_replies/repository/request_for_information_objection_replies.repository.go @@ -0,0 +1,98 @@ +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_objection_replies/request" + "go-humas-be/utils/paginator" + "strings" +) + +type requestForInformationObjectionRepliesRepository struct { + DB *database.Database + Log zerolog.Logger +} + +// RequestForInformationObjectionRepliesRepository define interface of IRequestForInformationObjectionRepliesRepository +type RequestForInformationObjectionRepliesRepository interface { + GetAll(req request.RequestForInformationObjectionRepliesQueryRequest) (requestForInformationObjectionRepliess []*entity.RequestForInformationObjectionReplies, paging paginator.Pagination, err error) + FindOne(id uint) (requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies, err error) + Create(requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies) (requestForInformationObjectionRepliesReturn *entity.RequestForInformationObjectionReplies, err error) + Update(id uint, requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies) (err error) + Delete(id uint) (err error) +} + +func NewRequestForInformationObjectionRepliesRepository(db *database.Database, logger zerolog.Logger) RequestForInformationObjectionRepliesRepository { + return &requestForInformationObjectionRepliesRepository{ + DB: db, + Log: logger, + } +} + +// implement interface of IRequestForInformationObjectionRepliesRepository +func (_i *requestForInformationObjectionRepliesRepository) GetAll(req request.RequestForInformationObjectionRepliesQueryRequest) (requestForInformationObjectionRepliess []*entity.RequestForInformationObjectionReplies, paging paginator.Pagination, err error) { + var count int64 + + query := _i.DB.DB.Model(&entity.RequestForInformationObjectionReplies{}) + query = query.Where("is_active = ?", true) + + if req.RequestForInformationObjectionId != nil { + query = query.Where("request_for_information_objection_id = ?", req.RequestForInformationObjectionId) + } + 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) + } + if req.CreatedById != nil { + query = query.Where("created_by_id = ?", req.CreatedById) + } + 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(&requestForInformationObjectionRepliess).Error + if err != nil { + return + } + + paging = *req.Pagination + + return +} + +func (_i *requestForInformationObjectionRepliesRepository) FindOne(id uint) (requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies, err error) { + if err := _i.DB.DB.First(&requestForInformationObjectionReplies, id).Error; err != nil { + return nil, err + } + + return requestForInformationObjectionReplies, nil +} + +func (_i *requestForInformationObjectionRepliesRepository) Create(requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies) (requestForInformationObjectionRepliesReturn *entity.RequestForInformationObjectionReplies, err error) { + result := _i.DB.DB.Create(requestForInformationObjectionReplies) + return requestForInformationObjectionReplies, result.Error +} + +func (_i *requestForInformationObjectionRepliesRepository) Update(id uint, requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies) (err error) { + return _i.DB.DB.Model(&entity.RequestForInformationObjectionReplies{}). + Where(&entity.RequestForInformationObjectionReplies{ID: id}). + Updates(requestForInformationObjectionReplies).Error +} + +func (_i *requestForInformationObjectionRepliesRepository) Delete(id uint) error { + return _i.DB.DB.Delete(&entity.RequestForInformationObjectionReplies{}, id).Error +} diff --git a/app/module/request_for_information_objection_replies/request/request_for_information_objection_replies.request.go b/app/module/request_for_information_objection_replies/request/request_for_information_objection_replies.request.go new file mode 100644 index 0000000..632e6f5 --- /dev/null +++ b/app/module/request_for_information_objection_replies/request/request_for_information_objection_replies.request.go @@ -0,0 +1,89 @@ +package request + +import ( + "go-humas-be/app/database/entity" + "go-humas-be/utils/paginator" + "strconv" + "time" +) + +type RequestForInformationObjectionRepliesGeneric interface { + ToEntity() +} + +type RequestForInformationObjectionRepliesQueryRequest struct { + RequestForInformationObjectionId *int `json:"requestForInformationObjectionId"` + Response *string `json:"response"` + StatusId *int `json:"statusId"` + CreatedById *int `json:"createdById"` + Pagination *paginator.Pagination `json:"pagination"` +} + +type RequestForInformationObjectionRepliesCreateRequest struct { + RequestForInformationObjectionId int `json:"requestForInformationObjectionId" validate:"required"` + Response string `json:"response" validate:"required"` + StatusId int `json:"statusId" validate:"required"` + CreatedById int `json:"createdById" validate:"required"` +} + +func (req RequestForInformationObjectionRepliesCreateRequest) ToEntity() *entity.RequestForInformationObjectionReplies { + return &entity.RequestForInformationObjectionReplies{ + RequestForInformationObjectionId: req.RequestForInformationObjectionId, + Response: req.Response, + StatusId: req.StatusId, + IsActive: func() *bool { b := true; return &b }(), + } +} + +type RequestForInformationObjectionRepliesUpdateRequest struct { + ID uint `json:"id" validate:"required"` + RequestForInformationObjectionId int `json:"requestForInformationObjectionId" validate:"required"` + Response string `json:"response" validate:"required"` + StatusId int `json:"statusId" validate:"required"` + UpdatedAt time.Time `json:"updated_at"` +} + +func (req RequestForInformationObjectionRepliesUpdateRequest) ToEntity() *entity.RequestForInformationObjectionReplies { + return &entity.RequestForInformationObjectionReplies{ + ID: req.ID, + RequestForInformationObjectionId: req.RequestForInformationObjectionId, + Response: req.Response, + StatusId: req.StatusId, + UpdatedAt: time.Now(), + } +} + +type RequestForInformationObjectionRepliesQueryRequestContext struct { + RequestForInformationObjectionId string `json:"requestForInformationObjectionId"` + Response string `json:"response"` + StatusId string `json:"statusId"` + CreatedById string `json:"createdById"` +} + +func (req RequestForInformationObjectionRepliesQueryRequestContext) ToParamRequest() RequestForInformationObjectionRepliesQueryRequest { + var request RequestForInformationObjectionRepliesQueryRequest + + if requestForInformationObjectionIdStr := req.RequestForInformationObjectionId; requestForInformationObjectionIdStr != "" { + requestForInformationObjectionId, err := strconv.Atoi(requestForInformationObjectionIdStr) + if err == nil { + request.RequestForInformationObjectionId = &requestForInformationObjectionId + } + } + if response := req.Response; response != "" { + request.Response = &response + } + if statusIdStr := req.StatusId; statusIdStr != "" { + statusId, err := strconv.Atoi(statusIdStr) + if err == nil { + request.StatusId = &statusId + } + } + if createdByIdStr := req.CreatedById; createdByIdStr != "" { + createdById, err := strconv.Atoi(createdByIdStr) + if err == nil { + request.CreatedById = &createdById + } + } + + return request +} diff --git a/app/module/request_for_information_objection_replies/request_for_information_objection_replies.module.go b/app/module/request_for_information_objection_replies/request_for_information_objection_replies.module.go new file mode 100644 index 0000000..5d33a16 --- /dev/null +++ b/app/module/request_for_information_objection_replies/request_for_information_objection_replies.module.go @@ -0,0 +1,53 @@ +package request_for_information_objection_replies + +import ( + "github.com/gofiber/fiber/v2" + "go-humas-be/app/module/request_for_information_objection_replies/controller" + "go-humas-be/app/module/request_for_information_objection_replies/repository" + "go-humas-be/app/module/request_for_information_objection_replies/service" + "go.uber.org/fx" +) + +// struct of RequestForInformationObjectionRepliesRouter +type RequestForInformationObjectionRepliesRouter struct { + App fiber.Router + Controller *controller.Controller +} + +// register bulky of RequestForInformationObjectionReplies module +var NewRequestForInformationObjectionRepliesModule = fx.Options( + // register repository of RequestForInformationObjectionReplies module + fx.Provide(repository.NewRequestForInformationObjectionRepliesRepository), + + // register service of RequestForInformationObjectionReplies module + fx.Provide(service.NewRequestForInformationObjectionRepliesService), + + // register controller of RequestForInformationObjectionReplies module + fx.Provide(controller.NewController), + + // register router of RequestForInformationObjectionReplies module + fx.Provide(NewRequestForInformationObjectionRepliesRouter), +) + +// init RequestForInformationObjectionRepliesRouter +func NewRequestForInformationObjectionRepliesRouter(fiber *fiber.App, controller *controller.Controller) *RequestForInformationObjectionRepliesRouter { + return &RequestForInformationObjectionRepliesRouter{ + App: fiber, + Controller: controller, + } +} + +// register routes of RequestForInformationObjectionReplies module +func (_i *RequestForInformationObjectionRepliesRouter) RegisterRequestForInformationObjectionRepliesRoutes() { + // define controllers + requestForInformationObjectionRepliesController := _i.Controller.RequestForInformationObjectionReplies + + // define routes + _i.App.Route("/request-for-information-objection-replies", func(router fiber.Router) { + router.Get("/", requestForInformationObjectionRepliesController.All) + router.Get("/:id", requestForInformationObjectionRepliesController.Show) + router.Post("/", requestForInformationObjectionRepliesController.Save) + router.Put("/:id", requestForInformationObjectionRepliesController.Update) + router.Delete("/:id", requestForInformationObjectionRepliesController.Delete) + }) +} diff --git a/app/module/request_for_information_objection_replies/response/request_for_information_objection_replies.response.go b/app/module/request_for_information_objection_replies/response/request_for_information_objection_replies.response.go new file mode 100644 index 0000000..3dc6c5c --- /dev/null +++ b/app/module/request_for_information_objection_replies/response/request_for_information_objection_replies.response.go @@ -0,0 +1,14 @@ +package response + +import "time" + +type RequestForInformationObjectionRepliesResponse struct { + ID uint `json:"id"` + RequestForInformationObjectionId int `json:"requestForInformationObjectionId"` + Response string `json:"response"` + StatusId int `json:"statusId"` + CreatedById *uint `json:"createdById"` + IsActive *bool `json:"isActive"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` +} diff --git a/app/module/request_for_information_objection_replies/service/request_for_information_objection_replies.service.go b/app/module/request_for_information_objection_replies/service/request_for_information_objection_replies.service.go new file mode 100644 index 0000000..6cac856 --- /dev/null +++ b/app/module/request_for_information_objection_replies/service/request_for_information_objection_replies.service.go @@ -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_objection_replies/mapper" + "go-humas-be/app/module/request_for_information_objection_replies/repository" + "go-humas-be/app/module/request_for_information_objection_replies/request" + "go-humas-be/app/module/request_for_information_objection_replies/response" + usersRepository "go-humas-be/app/module/users/repository" + "go-humas-be/utils/paginator" + + utilSvc "go-humas-be/utils/service" +) + +// RequestForInformationObjectionRepliesService +type requestForInformationObjectionRepliesService struct { + Repo repository.RequestForInformationObjectionRepliesRepository + UsersRepo usersRepository.UsersRepository + Log zerolog.Logger +} + +// RequestForInformationObjectionRepliesService define interface of IRequestForInformationObjectionRepliesService +type RequestForInformationObjectionRepliesService interface { + All(req request.RequestForInformationObjectionRepliesQueryRequest) (requestForInformationObjectionReplies []*response.RequestForInformationObjectionRepliesResponse, paging paginator.Pagination, err error) + Show(id uint) (requestForInformationObjectionReplies *response.RequestForInformationObjectionRepliesResponse, err error) + Save(req request.RequestForInformationObjectionRepliesCreateRequest, authToken string) (requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies, err error) + Update(id uint, req request.RequestForInformationObjectionRepliesUpdateRequest) (err error) + Delete(id uint) error +} + +// NewRequestForInformationObjectionRepliesService init RequestForInformationObjectionRepliesService +func NewRequestForInformationObjectionRepliesService(repo repository.RequestForInformationObjectionRepliesRepository, log zerolog.Logger, usersRepo usersRepository.UsersRepository) RequestForInformationObjectionRepliesService { + + return &requestForInformationObjectionRepliesService{ + Repo: repo, + Log: log, + UsersRepo: usersRepo, + } +} + +// All implement interface of RequestForInformationObjectionRepliesService +func (_i *requestForInformationObjectionRepliesService) All(req request.RequestForInformationObjectionRepliesQueryRequest) (requestForInformationObjectionRepliess []*response.RequestForInformationObjectionRepliesResponse, paging paginator.Pagination, err error) { + results, paging, err := _i.Repo.GetAll(req) + if err != nil { + return + } + + for _, result := range results { + requestForInformationObjectionRepliess = append(requestForInformationObjectionRepliess, mapper.RequestForInformationObjectionRepliesResponseMapper(result)) + } + + return +} + +func (_i *requestForInformationObjectionRepliesService) Show(id uint) (requestForInformationObjectionReplies *response.RequestForInformationObjectionRepliesResponse, err error) { + result, err := _i.Repo.FindOne(id) + if err != nil { + return nil, err + } + + return mapper.RequestForInformationObjectionRepliesResponseMapper(result), nil +} + +func (_i *requestForInformationObjectionRepliesService) Save(req request.RequestForInformationObjectionRepliesCreateRequest, authToken string) (requestForInformationObjectionReplies *entity.RequestForInformationObjectionReplies, 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 *requestForInformationObjectionRepliesService) Update(id uint, req request.RequestForInformationObjectionRepliesUpdateRequest) (err error) { + _i.Log.Info().Interface("data", req).Msg("") + return _i.Repo.Update(id, req.ToEntity()) +} + +func (_i *requestForInformationObjectionRepliesService) 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) +} diff --git a/app/module/users/controller/users.controller.go b/app/module/users/controller/users.controller.go index 68ad14b..c786c02 100644 --- a/app/module/users/controller/users.controller.go +++ b/app/module/users/controller/users.controller.go @@ -50,14 +50,18 @@ func (_i *usersController) All(c *fiber.Ctx) error { } reqContext := request.UsersQueryRequestContext{ - Username: c.Query("username"), - Email: c.Query("email"), - Fullname: c.Query("fullname"), - Address: c.Query("address"), - PhoneNumber: c.Query("phoneNumber"), - IdentityNumber: c.Query("identityNumber"), - UserRoleId: c.Query("userRoleId"), - StatusId: c.Query("statusId"), + Username: c.Query("username"), + Email: c.Query("email"), + Fullname: c.Query("fullname"), + PhoneNumber: c.Query("phoneNumber"), + WorkType: c.Query("workType"), + GenderType: c.Query("genderType"), + IdentityType: c.Query("identityType"), + IdentityGroup: c.Query("identityGroup"), + IdentityGroupNumber: c.Query("identityGroupNumber"), + IdentityNumber: c.Query("identityNumber"), + UserRoleId: c.Query("userRoleId"), + StatusId: c.Query("statusId"), } req := reqContext.ToParamRequest() req.Pagination = paginate diff --git a/app/module/users/repository/users.repository.go b/app/module/users/repository/users.repository.go index bd1f073..da1de7e 100644 --- a/app/module/users/repository/users.repository.go +++ b/app/module/users/repository/users.repository.go @@ -53,6 +53,21 @@ func (_i *usersRepository) GetAll(req request.UsersQueryRequest) (userss []*enti if req.PhoneNumber != nil && *req.PhoneNumber != "" { query = query.Where("phone_number = ?", req.PhoneNumber) } + if req.WorkType != nil && *req.WorkType != "" { + query = query.Where("work_type = ?", req.WorkType) + } + if req.GenderType != nil && *req.GenderType != "" { + query = query.Where("gender_type = ?", req.GenderType) + } + if req.IdentityType != nil && *req.IdentityType != "" { + query = query.Where("identity_type = ?", req.IdentityType) + } + if req.IdentityGroup != nil && *req.IdentityGroup != "" { + query = query.Where("identity_group = ?", req.IdentityGroup) + } + if req.IdentityGroupNumber != nil && *req.IdentityGroupNumber != "" { + query = query.Where("identity_group_number = ?", req.IdentityGroupNumber) + } if req.IdentityNumber != nil && *req.IdentityNumber != "" { query = query.Where("identity_number = ?", req.IdentityNumber) } diff --git a/app/module/users/request/users.request.go b/app/module/users/request/users.request.go index 30054ca..54965fb 100644 --- a/app/module/users/request/users.request.go +++ b/app/module/users/request/users.request.go @@ -12,85 +12,98 @@ type UsersGeneric interface { } type UsersQueryRequest struct { - Username *string `json:"username"` - Email *string `json:"email"` - Fullname *string `json:"fullname"` - PhoneNumber *string `json:"phoneNumber"` - IdentityNumber *string `json:"identityNumber"` - UserRoleId *int `json:"userRoleId"` - StatusId *int `json:"statusId"` - Pagination *paginator.Pagination `json:"pagination"` + Username *string `json:"username"` + Email *string `json:"email"` + Fullname *string `json:"fullname"` + PhoneNumber *string `json:"phoneNumber"` + WorkType *string `json:"workType"` + GenderType *string `json:"genderType"` + IdentityType *string `json:"identityType"` + IdentityGroup *string `json:"identityGroup"` + IdentityGroupNumber *string `json:"identityGroupNumber"` + IdentityNumber *string `json:"identityNumber"` + UserRoleId *int `json:"userRoleId"` + StatusId *int `json:"statusId"` + Pagination *paginator.Pagination `json:"pagination"` } type UsersCreateRequest struct { - Username string `json:"username" validate:"required,lowercase"` - Email string `json:"email" validate:"required,email"` - Fullname string `json:"fullname" validate:"required"` - Address string `json:"address" validate:"required"` - PhoneNumber string `json:"phoneNumber" validate:"required"` - WorkType string `json:"workType" validate:"required"` - GenderType string `json:"genderType" validate:"required"` - IdentityType string `json:"identityType" validate:"required"` - IdentityNumber string `json:"identityNumber" validate:"required"` - DateOfBirth string `json:"dateOfBirth" validate:"required"` - LastEducation string `json:"lastEducation" validate:"required"` - UserRoleId uint `json:"userRoleId" validate:"required"` - UserLevelId uint `json:"userLevelId" validate:"required"` - Password string `json:"password" validate:"required"` + Username string `json:"username" validate:"required,lowercase"` + Email string `json:"email" validate:"required,email"` + Fullname string `json:"fullname" validate:"required"` + Address string `json:"address" validate:"required"` + PhoneNumber string `json:"phoneNumber" validate:"required"` + WorkType string `json:"workType" validate:"required"` + GenderType string `json:"genderType" validate:"required"` + IdentityType string `json:"identityType" validate:"required"` + IdentityGroup string `json:"identityGroup" validate:"required"` + IdentityGroupNumber string `json:"identityGroupNumber" validate:"required"` + IdentityNumber string `json:"identityNumber" validate:"required"` + DateOfBirth string `json:"dateOfBirth" validate:"required"` + LastEducation string `json:"lastEducation" validate:"required"` + UserRoleId uint `json:"userRoleId" validate:"required"` + UserLevelId uint `json:"userLevelId" validate:"required"` + Password string `json:"password" validate:"required"` } func (req UsersCreateRequest) ToEntity() *entity.Users { return &entity.Users{ - Username: req.Username, - Email: req.Email, - Fullname: req.Fullname, - Address: req.Address, - PhoneNumber: req.PhoneNumber, - WorkType: req.WorkType, - GenderType: req.GenderType, - IdentityType: req.IdentityType, - IdentityNumber: req.IdentityNumber, - DateOfBirth: req.DateOfBirth, - LastEducation: req.LastEducation, - UserRoleId: req.UserRoleId, - UserLevelId: req.UserLevelId, + Username: req.Username, + Email: req.Email, + Fullname: req.Fullname, + Address: req.Address, + PhoneNumber: req.PhoneNumber, + WorkType: req.WorkType, + GenderType: req.GenderType, + IdentityType: req.IdentityType, + IdentityGroup: req.IdentityGroup, + IdentityGroupNumber: req.IdentityGroupNumber, + IdentityNumber: req.IdentityNumber, + DateOfBirth: req.DateOfBirth, + LastEducation: req.LastEducation, + UserRoleId: req.UserRoleId, + UserLevelId: req.UserLevelId, } } type UsersUpdateRequest struct { - Username string `json:"username" validate:"required,lowercase"` - Email string `json:"email" validate:"required,email"` - Fullname string `json:"fullname" validate:"required"` - Address string `json:"address" validate:"required"` - PhoneNumber string `json:"phoneNumber" validate:"required"` - WorkType string `json:"workType" validate:"required"` - GenderType string `json:"genderType" validate:"required"` - IdentityType string `json:"identityType" validate:"required"` - IdentityNumber string `json:"identityNumber" validate:"required"` - DateOfBirth string `json:"dateOfBirth" validate:"required"` - LastEducation string `json:"lastEducation" validate:"required"` - UserRoleId uint `json:"userRoleId" validate:"required"` - UserLevelId uint `json:"userLevelId" validate:"required"` - StatusId *int `json:"statusId"` + Username string `json:"username" validate:"required,lowercase"` + Email string `json:"email" validate:"required,email"` + Fullname string `json:"fullname" validate:"required"` + Address string `json:"address" validate:"required"` + PhoneNumber string `json:"phoneNumber" validate:"required"` + WorkType string `json:"workType" validate:"required"` + GenderType string `json:"genderType" validate:"required"` + IdentityType string `json:"identityType" validate:"required"` + IdentityGroup string `json:"identityGroup" validate:"required"` + IdentityGroupNumber string `json:"identityGroupNumber" validate:"required"` + IdentityNumber string `json:"identityNumber" validate:"required"` + DateOfBirth string `json:"dateOfBirth" validate:"required"` + LastEducation string `json:"lastEducation" validate:"required"` + UserRoleId uint `json:"userRoleId" validate:"required"` + UserLevelId uint `json:"userLevelId" validate:"required"` + StatusId *int `json:"statusId"` } func (req UsersUpdateRequest) ToEntity() *entity.Users { return &entity.Users{ - Username: req.Username, - Email: req.Email, - Fullname: req.Fullname, - Address: req.Address, - PhoneNumber: req.PhoneNumber, - WorkType: req.WorkType, - GenderType: req.GenderType, - IdentityType: req.IdentityType, - IdentityNumber: req.IdentityNumber, - DateOfBirth: req.DateOfBirth, - LastEducation: req.LastEducation, - UserRoleId: req.UserRoleId, - StatusId: req.StatusId, - UserLevelId: req.UserLevelId, - UpdatedAt: time.Now(), + Username: req.Username, + Email: req.Email, + Fullname: req.Fullname, + Address: req.Address, + PhoneNumber: req.PhoneNumber, + WorkType: req.WorkType, + GenderType: req.GenderType, + IdentityType: req.IdentityType, + IdentityGroup: req.IdentityGroup, + IdentityGroupNumber: req.IdentityGroupNumber, + IdentityNumber: req.IdentityNumber, + DateOfBirth: req.DateOfBirth, + LastEducation: req.LastEducation, + UserRoleId: req.UserRoleId, + StatusId: req.StatusId, + UserLevelId: req.UserLevelId, + UpdatedAt: time.Now(), } } @@ -101,14 +114,18 @@ type UserLogin struct { } type UsersQueryRequestContext struct { - Username string `json:"username"` - Email string `json:"email"` - Fullname string `json:"fullname"` - Address string `json:"address"` - PhoneNumber string `json:"phoneNumber"` - IdentityNumber string `json:"identityNumber"` - UserRoleId string `json:"userRoleId"` - StatusId string `json:"statusId"` + Username string `json:"username"` + Email string `json:"email"` + Fullname string `json:"fullname"` + PhoneNumber string `json:"phoneNumber"` + WorkType string `json:"workType"` + GenderType string `json:"genderType"` + IdentityType string `json:"identityType"` + IdentityGroup string `json:"identityGroup"` + IdentityGroupNumber string `json:"identityGroupNumber"` + IdentityNumber string `json:"identityNumber"` + UserRoleId string `json:"userRoleId"` + StatusId string `json:"statusId"` } func (req UsersQueryRequestContext) ToParamRequest() UsersQueryRequest { @@ -126,6 +143,21 @@ func (req UsersQueryRequestContext) ToParamRequest() UsersQueryRequest { if phoneNumber := req.PhoneNumber; phoneNumber != "" { request.PhoneNumber = &phoneNumber } + if workType := req.WorkType; workType != "" { + request.WorkType = &workType + } + if genderType := req.GenderType; genderType != "" { + request.GenderType = &genderType + } + if identityType := req.IdentityType; identityType != "" { + request.IdentityType = &identityType + } + if identityGroup := req.IdentityGroup; identityGroup != "" { + request.IdentityGroup = &identityGroup + } + if identityGroupNumber := req.IdentityGroupNumber; identityGroupNumber != "" { + request.IdentityGroupNumber = &identityGroupNumber + } if identityNumber := req.IdentityNumber; identityNumber != "" { request.IdentityNumber = &identityNumber } diff --git a/app/router/api.go b/app/router/api.go index 379345d..b7c9b7b 100644 --- a/app/router/api.go +++ b/app/router/api.go @@ -19,6 +19,7 @@ import ( "go-humas-be/app/module/provinces" "go-humas-be/app/module/request_for_information_items" "go-humas-be/app/module/request_for_information_objection" + "go-humas-be/app/module/request_for_information_objection_replies" "go-humas-be/app/module/request_for_information_replies" "go-humas-be/app/module/request_for_informations" "go-humas-be/app/module/user_levels" @@ -33,28 +34,29 @@ 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 - PpidDatasRouter *ppid_datas.PpidDatasRouter - ProvincesRouter *provinces.ProvincesRouter - RequestForInformationsRouter *request_for_informations.RequestForInformationsRouter - RequestForInformationItemsRouter *request_for_information_items.RequestForInformationItemsRouter - RequestForInformationRepliesRouter *request_for_information_replies.RequestForInformationRepliesRouter - RequestForInformationObjectionRouter *request_for_information_objection.RequestForInformationObjectionRouter - 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 + RequestForInformationObjectionRouter *request_for_information_objection.RequestForInformationObjectionRouter + RequestForInformationObjectionRepliesRouter *request_for_information_objection_replies.RequestForInformationObjectionRepliesRouter + UserLevelsRouter *user_levels.UserLevelsRouter + UserRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter + UserRolesRouter *user_roles.UserRolesRouter + UsersRouter *users.UsersRouter } func NewRouter( @@ -79,6 +81,7 @@ func NewRouter( requestForInformationItemsRouter *request_for_information_items.RequestForInformationItemsRouter, requestForInformationRepliesRouter *request_for_information_replies.RequestForInformationRepliesRouter, requestForInformationObjectionRouter *request_for_information_objection.RequestForInformationObjectionRouter, + requestForInformationObjectionRepliesRouter *request_for_information_objection_replies.RequestForInformationObjectionRepliesRouter, userLevelsRouter *user_levels.UserLevelsRouter, userRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter, userRolesRouter *user_roles.UserRolesRouter, @@ -105,10 +108,11 @@ func NewRouter( RequestForInformationItemsRouter: requestForInformationItemsRouter, RequestForInformationRepliesRouter: requestForInformationRepliesRouter, RequestForInformationObjectionRouter: requestForInformationObjectionRouter, - UserLevelsRouter: userLevelsRouter, - UserRoleAccessesRouter: userRoleAccessesRouter, - UserRolesRouter: userRolesRouter, - UsersRouter: usersRouter, + RequestForInformationObjectionRepliesRouter: requestForInformationObjectionRepliesRouter, + UserLevelsRouter: userLevelsRouter, + UserRoleAccessesRouter: userRoleAccessesRouter, + UserRolesRouter: userRolesRouter, + UsersRouter: usersRouter, } } @@ -141,6 +145,7 @@ func (r *Router) Register() { r.RequestForInformationItemsRouter.RegisterRequestForInformationItemsRoutes() r.RequestForInformationRepliesRouter.RegisterRequestForInformationRepliesRoutes() r.RequestForInformationObjectionRouter.RegisterRequestForInformationObjectionRoutes() + r.RequestForInformationObjectionRepliesRouter.RegisterRequestForInformationObjectionRepliesRoutes() r.UserLevelsRouter.RegisterUserLevelsRoutes() r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes() r.UsersRouter.RegisterUsersRoutes() diff --git a/config/toml/config.toml b/config/toml/config.toml index 182f5b1..41b35ce 100644 --- a/config/toml/config.toml +++ b/config/toml/config.toml @@ -12,7 +12,7 @@ body-limit = 104857600 # "100 * 1024 * 1024" [db.postgres] dsn = "postgresql://humas_polri:P@ssw0rd.1@103.82.242.92:5432/humas_polri" # ://:@:/ -migrate = false +migrate = true seed = false [logger] diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index a38ea13..f52efe7 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -5768,6 +5768,317 @@ const docTemplate = `{ } } }, + "/request-for-information-objection-replies": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for getting all RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "Get all RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "integer", + "name": "createdById", + "in": "query" + }, + { + "type": "integer", + "name": "requestForInformationObjectionId", + "in": "query" + }, + { + "type": "string", + "name": "response", + "in": "query" + }, + { + "type": "integer", + "name": "statusId", + "in": "query" + }, + { + "type": "integer", + "name": "count", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "nextPage", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "previousPage", + "in": "query" + }, + { + "type": "string", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "name": "sortBy", + "in": "query" + }, + { + "type": "integer", + "name": "totalPage", + "in": "query" + } + ], + "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 RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "Create RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "string", + "default": "Bearer \u003cAdd access token here\u003e", + "description": "Insert your access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.RequestForInformationObjectionRepliesCreateRequest" + } + } + ], + "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" + } + } + } + } + }, + "/request-for-information-objection-replies/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for getting one RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "Get one RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "integer", + "description": "RequestForInformationObjectionReplies 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" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for update RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "update RequestForInformationObjectionReplies", + "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.RequestForInformationObjectionRepliesUpdateRequest" + } + }, + { + "type": "integer", + "description": "RequestForInformationObjectionReplies 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 RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "delete RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "integer", + "description": "RequestForInformationObjectionReplies 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" + } + } + } + } + }, "/request-for-information-objection/{id}": { "get": { "security": [ @@ -7741,11 +8052,31 @@ const docTemplate = `{ "name": "fullname", "in": "query" }, + { + "type": "string", + "name": "genderType", + "in": "query" + }, + { + "type": "string", + "name": "identityGroup", + "in": "query" + }, + { + "type": "string", + "name": "identityGroupNumber", + "in": "query" + }, { "type": "string", "name": "identityNumber", "in": "query" }, + { + "type": "string", + "name": "identityType", + "in": "query" + }, { "type": "string", "name": "phoneNumber", @@ -7766,6 +8097,11 @@ const docTemplate = `{ "name": "username", "in": "query" }, + { + "type": "string", + "name": "workType", + "in": "query" + }, { "type": "integer", "name": "count", @@ -8767,6 +9103,55 @@ const docTemplate = `{ } } }, + "request.RequestForInformationObjectionRepliesCreateRequest": { + "type": "object", + "required": [ + "createdById", + "requestForInformationObjectionId", + "response", + "statusId" + ], + "properties": { + "createdById": { + "type": "integer" + }, + "requestForInformationObjectionId": { + "type": "integer" + }, + "response": { + "type": "string" + }, + "statusId": { + "type": "integer" + } + } + }, + "request.RequestForInformationObjectionRepliesUpdateRequest": { + "type": "object", + "required": [ + "id", + "requestForInformationObjectionId", + "response", + "statusId" + ], + "properties": { + "id": { + "type": "integer" + }, + "requestForInformationObjectionId": { + "type": "integer" + }, + "response": { + "type": "string" + }, + "statusId": { + "type": "integer" + }, + "updated_at": { + "type": "string" + } + } + }, "request.RequestForInformationObjectionUpdateRequest": { "type": "object", "required": [ @@ -9128,6 +9513,8 @@ const docTemplate = `{ "email", "fullname", "genderType", + "identityGroup", + "identityGroupNumber", "identityNumber", "identityType", "lastEducation", @@ -9154,6 +9541,12 @@ const docTemplate = `{ "genderType": { "type": "string" }, + "identityGroup": { + "type": "string" + }, + "identityGroupNumber": { + "type": "string" + }, "identityNumber": { "type": "string" }, @@ -9191,6 +9584,8 @@ const docTemplate = `{ "email", "fullname", "genderType", + "identityGroup", + "identityGroupNumber", "identityNumber", "identityType", "lastEducation", @@ -9216,6 +9611,12 @@ const docTemplate = `{ "genderType": { "type": "string" }, + "identityGroup": { + "type": "string" + }, + "identityGroupNumber": { + "type": "string" + }, "identityNumber": { "type": "string" }, diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index d954cf6..5a7b9d0 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -5757,6 +5757,317 @@ } } }, + "/request-for-information-objection-replies": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for getting all RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "Get all RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "integer", + "name": "createdById", + "in": "query" + }, + { + "type": "integer", + "name": "requestForInformationObjectionId", + "in": "query" + }, + { + "type": "string", + "name": "response", + "in": "query" + }, + { + "type": "integer", + "name": "statusId", + "in": "query" + }, + { + "type": "integer", + "name": "count", + "in": "query" + }, + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "nextPage", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "previousPage", + "in": "query" + }, + { + "type": "string", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "name": "sortBy", + "in": "query" + }, + { + "type": "integer", + "name": "totalPage", + "in": "query" + } + ], + "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 RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "Create RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "string", + "default": "Bearer \u003cAdd access token here\u003e", + "description": "Insert your access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.RequestForInformationObjectionRepliesCreateRequest" + } + } + ], + "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" + } + } + } + } + }, + "/request-for-information-objection-replies/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for getting one RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "Get one RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "integer", + "description": "RequestForInformationObjectionReplies 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" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for update RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "update RequestForInformationObjectionReplies", + "parameters": [ + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.RequestForInformationObjectionRepliesUpdateRequest" + } + }, + { + "type": "integer", + "description": "RequestForInformationObjectionReplies 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 RequestForInformationObjectionReplies", + "tags": [ + "RequestForInformationObjectionReplies" + ], + "summary": "delete RequestForInformationObjectionReplies", + "parameters": [ + { + "type": "integer", + "description": "RequestForInformationObjectionReplies 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" + } + } + } + } + }, "/request-for-information-objection/{id}": { "get": { "security": [ @@ -7730,11 +8041,31 @@ "name": "fullname", "in": "query" }, + { + "type": "string", + "name": "genderType", + "in": "query" + }, + { + "type": "string", + "name": "identityGroup", + "in": "query" + }, + { + "type": "string", + "name": "identityGroupNumber", + "in": "query" + }, { "type": "string", "name": "identityNumber", "in": "query" }, + { + "type": "string", + "name": "identityType", + "in": "query" + }, { "type": "string", "name": "phoneNumber", @@ -7755,6 +8086,11 @@ "name": "username", "in": "query" }, + { + "type": "string", + "name": "workType", + "in": "query" + }, { "type": "integer", "name": "count", @@ -8756,6 +9092,55 @@ } } }, + "request.RequestForInformationObjectionRepliesCreateRequest": { + "type": "object", + "required": [ + "createdById", + "requestForInformationObjectionId", + "response", + "statusId" + ], + "properties": { + "createdById": { + "type": "integer" + }, + "requestForInformationObjectionId": { + "type": "integer" + }, + "response": { + "type": "string" + }, + "statusId": { + "type": "integer" + } + } + }, + "request.RequestForInformationObjectionRepliesUpdateRequest": { + "type": "object", + "required": [ + "id", + "requestForInformationObjectionId", + "response", + "statusId" + ], + "properties": { + "id": { + "type": "integer" + }, + "requestForInformationObjectionId": { + "type": "integer" + }, + "response": { + "type": "string" + }, + "statusId": { + "type": "integer" + }, + "updated_at": { + "type": "string" + } + } + }, "request.RequestForInformationObjectionUpdateRequest": { "type": "object", "required": [ @@ -9117,6 +9502,8 @@ "email", "fullname", "genderType", + "identityGroup", + "identityGroupNumber", "identityNumber", "identityType", "lastEducation", @@ -9143,6 +9530,12 @@ "genderType": { "type": "string" }, + "identityGroup": { + "type": "string" + }, + "identityGroupNumber": { + "type": "string" + }, "identityNumber": { "type": "string" }, @@ -9180,6 +9573,8 @@ "email", "fullname", "genderType", + "identityGroup", + "identityGroupNumber", "identityNumber", "identityType", "lastEducation", @@ -9205,6 +9600,12 @@ "genderType": { "type": "string" }, + "identityGroup": { + "type": "string" + }, + "identityGroupNumber": { + "type": "string" + }, "identityNumber": { "type": "string" }, diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 3a02fa2..9f509cb 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -423,6 +423,40 @@ definitions: - secondaryReason - statusId type: object + request.RequestForInformationObjectionRepliesCreateRequest: + properties: + createdById: + type: integer + requestForInformationObjectionId: + type: integer + response: + type: string + statusId: + type: integer + required: + - createdById + - requestForInformationObjectionId + - response + - statusId + type: object + request.RequestForInformationObjectionRepliesUpdateRequest: + properties: + id: + type: integer + requestForInformationObjectionId: + type: integer + response: + type: string + statusId: + type: integer + updated_at: + type: string + required: + - id + - requestForInformationObjectionId + - response + - statusId + type: object request.RequestForInformationObjectionUpdateRequest: properties: documentName: @@ -684,6 +718,10 @@ definitions: type: string genderType: type: string + identityGroup: + type: string + identityGroupNumber: + type: string identityNumber: type: string identityType: @@ -708,6 +746,8 @@ definitions: - email - fullname - genderType + - identityGroup + - identityGroupNumber - identityNumber - identityType - lastEducation @@ -730,6 +770,10 @@ definitions: type: string genderType: type: string + identityGroup: + type: string + identityGroupNumber: + type: string identityNumber: type: string identityType: @@ -754,6 +798,8 @@ definitions: - email - fullname - genderType + - identityGroup + - identityGroupNumber - identityNumber - identityType - lastEducation @@ -4453,6 +4499,202 @@ paths: summary: Create RequestForInformationObjection tags: - RequestForInformationObjection + /request-for-information-objection-replies: + get: + description: API for getting all RequestForInformationObjectionReplies + parameters: + - in: query + name: createdById + type: integer + - in: query + name: requestForInformationObjectionId + type: integer + - in: query + name: response + type: string + - in: query + name: statusId + 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 RequestForInformationObjectionReplies + tags: + - RequestForInformationObjectionReplies + post: + description: API for create RequestForInformationObjectionReplies + parameters: + - default: Bearer + 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.RequestForInformationObjectionRepliesCreateRequest' + 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 RequestForInformationObjectionReplies + tags: + - RequestForInformationObjectionReplies + /request-for-information-objection-replies/{id}: + delete: + description: API for delete RequestForInformationObjectionReplies + parameters: + - description: RequestForInformationObjectionReplies 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 RequestForInformationObjectionReplies + tags: + - RequestForInformationObjectionReplies + get: + description: API for getting one RequestForInformationObjectionReplies + parameters: + - description: RequestForInformationObjectionReplies 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 RequestForInformationObjectionReplies + tags: + - RequestForInformationObjectionReplies + put: + description: API for update RequestForInformationObjectionReplies + parameters: + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.RequestForInformationObjectionRepliesUpdateRequest' + - description: RequestForInformationObjectionReplies 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 RequestForInformationObjectionReplies + tags: + - RequestForInformationObjectionReplies /request-for-information-objection/{id}: delete: description: API for delete RequestForInformationObjection @@ -5698,9 +5940,21 @@ paths: - in: query name: fullname type: string + - in: query + name: genderType + type: string + - in: query + name: identityGroup + type: string + - in: query + name: identityGroupNumber + type: string - in: query name: identityNumber type: string + - in: query + name: identityType + type: string - in: query name: phoneNumber type: string @@ -5713,6 +5967,9 @@ paths: - in: query name: username type: string + - in: query + name: workType + type: string - in: query name: count type: integer diff --git a/main.go b/main.go index 07bfffc..ea2e939 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ import ( "go-humas-be/app/module/provinces" "go-humas-be/app/module/request_for_information_items" "go-humas-be/app/module/request_for_information_objection" + "go-humas-be/app/module/request_for_information_objection_replies" "go-humas-be/app/module/request_for_information_replies" "go-humas-be/app/module/request_for_informations" "go-humas-be/app/module/user_levels" @@ -81,6 +82,7 @@ func main() { request_for_information_items.NewRequestForInformationItemsModule, request_for_information_replies.NewRequestForInformationRepliesModule, request_for_information_objection.NewRequestForInformationObjectionModule, + request_for_information_objection_replies.NewRequestForInformationObjectionRepliesModule, // start aplication fx.Invoke(webserver.Start),