feat: fixing all request for information

This commit is contained in:
hanif salafi 2024-07-03 09:09:04 +07:00
parent b236258e25
commit f491e2e9b0
8 changed files with 82 additions and 82 deletions

View File

@ -4,7 +4,7 @@ import "time"
type RequestForInformationObjection struct { type RequestForInformationObjection struct {
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
RequestForInformationId uint `json:"request_for_information_id" gorm:"type:int4"` RequestForInformationItemId uint `json:"request_for_information_item_id" gorm:"type:int4"`
DocumentName string `json:"document_name" gorm:"type:varchar"` DocumentName string `json:"document_name" gorm:"type:varchar"`
MainReason string `json:"main_reason" gorm:"type:varchar"` MainReason string `json:"main_reason" gorm:"type:varchar"`
SecondaryReason string `json:"secondary_reason" gorm:"type:varchar"` SecondaryReason string `json:"secondary_reason" gorm:"type:varchar"`

View File

@ -51,7 +51,7 @@ func (_i *requestForInformationObjectionController) All(c *fiber.Ctx) error {
} }
reqContext := request.RequestForInformationObjectionQueryRequestContext{ reqContext := request.RequestForInformationObjectionQueryRequestContext{
RequestForInformationId: c.Query("requestForInformationId"), RequestForInformationItemId: c.Query("requestForInformationItemId"),
DocumentName: c.Query("documentName"), DocumentName: c.Query("documentName"),
MainReason: c.Query("mainReason"), MainReason: c.Query("mainReason"),
SecondaryReason: c.Query("secondaryReason"), SecondaryReason: c.Query("secondaryReason"),

View File

@ -38,8 +38,8 @@ func (_i *requestForInformationObjectionRepository) GetAll(req request.RequestFo
query := _i.DB.DB.Model(&entity.RequestForInformationObjection{}) query := _i.DB.DB.Model(&entity.RequestForInformationObjection{})
query = query.Where("is_active = ?", true) query = query.Where("is_active = ?", true)
if req.RequestForInformationId != nil { if req.RequestForInformationItemId != nil {
query = query.Where("request_for_information_id = ?", req.RequestForInformationId) query = query.Where("request_for_information_item_id = ?", req.RequestForInformationItemId)
} }
if req.DocumentName != nil && *req.DocumentName != "" { if req.DocumentName != nil && *req.DocumentName != "" {
documentName := strings.ToLower(*req.DocumentName) documentName := strings.ToLower(*req.DocumentName)

View File

@ -12,7 +12,7 @@ type RequestForInformationObjectionGeneric interface {
} }
type RequestForInformationObjectionQueryRequest struct { type RequestForInformationObjectionQueryRequest struct {
RequestForInformationId *uint `json:"requestForInformationId"` RequestForInformationItemId *uint `json:"requestForInformationItemId"`
DocumentName *string `json:"documentName"` DocumentName *string `json:"documentName"`
MainReason *string `json:"mainReason"` MainReason *string `json:"mainReason"`
SecondaryReason *string `json:"secondaryReason"` SecondaryReason *string `json:"secondaryReason"`
@ -22,7 +22,7 @@ type RequestForInformationObjectionQueryRequest struct {
} }
type RequestForInformationObjectionCreateRequest struct { type RequestForInformationObjectionCreateRequest struct {
RequestForInformationId uint `json:"requestForInformationId" validate:"required"` RequestForInformationItemId uint `json:"requestForInformationItemId" validate:"required"`
DocumentName string `json:"documentName" validate:"required"` DocumentName string `json:"documentName" validate:"required"`
MainReason string `json:"mainReason" validate:"required"` MainReason string `json:"mainReason" validate:"required"`
SecondaryReason string `json:"secondaryReason" validate:"required"` SecondaryReason string `json:"secondaryReason" validate:"required"`
@ -31,7 +31,7 @@ type RequestForInformationObjectionCreateRequest struct {
func (req RequestForInformationObjectionCreateRequest) ToEntity() *entity.RequestForInformationObjection { func (req RequestForInformationObjectionCreateRequest) ToEntity() *entity.RequestForInformationObjection {
return &entity.RequestForInformationObjection{ return &entity.RequestForInformationObjection{
RequestForInformationId: req.RequestForInformationId, RequestForInformationItemId: req.RequestForInformationItemId,
DocumentName: req.DocumentName, DocumentName: req.DocumentName,
MainReason: req.MainReason, MainReason: req.MainReason,
SecondaryReason: req.SecondaryReason, SecondaryReason: req.SecondaryReason,
@ -42,7 +42,7 @@ func (req RequestForInformationObjectionCreateRequest) ToEntity() *entity.Reques
type RequestForInformationObjectionUpdateRequest struct { type RequestForInformationObjectionUpdateRequest struct {
ID uint `json:"id" validate:"required"` ID uint `json:"id" validate:"required"`
RequestForInformationId uint `json:"requestForInformationId" validate:"required"` RequestForInformationItemId uint `json:"requestForInformationItemId" validate:"required"`
DocumentName string `json:"documentName" validate:"required"` DocumentName string `json:"documentName" validate:"required"`
MainReason string `json:"mainReason" validate:"required"` MainReason string `json:"mainReason" validate:"required"`
SecondaryReason string `json:"secondaryReason" validate:"required"` SecondaryReason string `json:"secondaryReason" validate:"required"`
@ -52,7 +52,7 @@ type RequestForInformationObjectionUpdateRequest struct {
func (req RequestForInformationObjectionUpdateRequest) ToEntity() *entity.RequestForInformationObjection { func (req RequestForInformationObjectionUpdateRequest) ToEntity() *entity.RequestForInformationObjection {
return &entity.RequestForInformationObjection{ return &entity.RequestForInformationObjection{
ID: req.ID, ID: req.ID,
RequestForInformationId: req.RequestForInformationId, RequestForInformationItemId: req.RequestForInformationItemId,
DocumentName: req.DocumentName, DocumentName: req.DocumentName,
MainReason: req.MainReason, MainReason: req.MainReason,
SecondaryReason: req.SecondaryReason, SecondaryReason: req.SecondaryReason,
@ -62,7 +62,7 @@ func (req RequestForInformationObjectionUpdateRequest) ToEntity() *entity.Reques
} }
type RequestForInformationObjectionQueryRequestContext struct { type RequestForInformationObjectionQueryRequestContext struct {
RequestForInformationId string `json:"requestForInformationId"` RequestForInformationItemId string `json:"requestForInformationItemId"`
DocumentName string `json:"documentName"` DocumentName string `json:"documentName"`
MainReason string `json:"mainReason"` MainReason string `json:"mainReason"`
SecondaryReason string `json:"secondaryReason"` SecondaryReason string `json:"secondaryReason"`
@ -73,11 +73,11 @@ type RequestForInformationObjectionQueryRequestContext struct {
func (req RequestForInformationObjectionQueryRequestContext) ToParamRequest() RequestForInformationObjectionQueryRequest { func (req RequestForInformationObjectionQueryRequestContext) ToParamRequest() RequestForInformationObjectionQueryRequest {
var request RequestForInformationObjectionQueryRequest var request RequestForInformationObjectionQueryRequest
if requestForInformationIdStr := req.RequestForInformationId; requestForInformationIdStr != "" { if requestForInformationIdStr := req.RequestForInformationItemId; requestForInformationIdStr != "" {
requestForInformationId, err := strconv.Atoi(requestForInformationIdStr) requestForInformationId, err := strconv.Atoi(requestForInformationIdStr)
if err == nil { if err == nil {
requestForInformationIdUint := uint(requestForInformationId) requestForInformationIdUint := uint(requestForInformationId)
request.RequestForInformationId = &requestForInformationIdUint request.RequestForInformationItemId = &requestForInformationIdUint
} }
} }
if documentName := req.DocumentName; documentName != "" { if documentName := req.DocumentName; documentName != "" {

View File

@ -4,7 +4,7 @@ import "time"
type RequestForInformationObjectionResponse struct { type RequestForInformationObjectionResponse struct {
ID uint `json:"id"` ID uint `json:"id"`
RequestForInformationId uint `json:"requestForInformationId"` RequestForInformationItemId uint `json:"requestForInformationItemId"`
DocumentName string `json:"documentName"` DocumentName string `json:"documentName"`
MainReason string `json:"mainReason"` MainReason string `json:"mainReason"`
SecondaryReason string `json:"secondaryReason"` SecondaryReason string `json:"secondaryReason"`

View File

@ -5629,7 +5629,7 @@ const docTemplate = `{
}, },
{ {
"type": "integer", "type": "integer",
"name": "requestForInformationId", "name": "requestForInformationItemId",
"in": "query" "in": "query"
}, },
{ {
@ -8745,7 +8745,7 @@ const docTemplate = `{
"required": [ "required": [
"documentName", "documentName",
"mainReason", "mainReason",
"requestForInformationId", "requestForInformationItemId",
"secondaryReason", "secondaryReason",
"statusId" "statusId"
], ],
@ -8756,7 +8756,7 @@ const docTemplate = `{
"mainReason": { "mainReason": {
"type": "string" "type": "string"
}, },
"requestForInformationId": { "requestForInformationItemId": {
"type": "integer" "type": "integer"
}, },
"secondaryReason": { "secondaryReason": {
@ -8773,7 +8773,7 @@ const docTemplate = `{
"documentName", "documentName",
"id", "id",
"mainReason", "mainReason",
"requestForInformationId", "requestForInformationItemId",
"secondaryReason", "secondaryReason",
"statusId" "statusId"
], ],
@ -8787,7 +8787,7 @@ const docTemplate = `{
"mainReason": { "mainReason": {
"type": "string" "type": "string"
}, },
"requestForInformationId": { "requestForInformationItemId": {
"type": "integer" "type": "integer"
}, },
"secondaryReason": { "secondaryReason": {

View File

@ -5618,7 +5618,7 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "requestForInformationId", "name": "requestForInformationItemId",
"in": "query" "in": "query"
}, },
{ {
@ -8734,7 +8734,7 @@
"required": [ "required": [
"documentName", "documentName",
"mainReason", "mainReason",
"requestForInformationId", "requestForInformationItemId",
"secondaryReason", "secondaryReason",
"statusId" "statusId"
], ],
@ -8745,7 +8745,7 @@
"mainReason": { "mainReason": {
"type": "string" "type": "string"
}, },
"requestForInformationId": { "requestForInformationItemId": {
"type": "integer" "type": "integer"
}, },
"secondaryReason": { "secondaryReason": {
@ -8762,7 +8762,7 @@
"documentName", "documentName",
"id", "id",
"mainReason", "mainReason",
"requestForInformationId", "requestForInformationItemId",
"secondaryReason", "secondaryReason",
"statusId" "statusId"
], ],
@ -8776,7 +8776,7 @@
"mainReason": { "mainReason": {
"type": "string" "type": "string"
}, },
"requestForInformationId": { "requestForInformationItemId": {
"type": "integer" "type": "integer"
}, },
"secondaryReason": { "secondaryReason": {

View File

@ -410,7 +410,7 @@ definitions:
type: string type: string
mainReason: mainReason:
type: string type: string
requestForInformationId: requestForInformationItemId:
type: integer type: integer
secondaryReason: secondaryReason:
type: string type: string
@ -419,7 +419,7 @@ definitions:
required: required:
- documentName - documentName
- mainReason - mainReason
- requestForInformationId - requestForInformationItemId
- secondaryReason - secondaryReason
- statusId - statusId
type: object type: object
@ -431,7 +431,7 @@ definitions:
type: integer type: integer
mainReason: mainReason:
type: string type: string
requestForInformationId: requestForInformationItemId:
type: integer type: integer
secondaryReason: secondaryReason:
type: string type: string
@ -441,7 +441,7 @@ definitions:
- documentName - documentName
- id - id
- mainReason - mainReason
- requestForInformationId - requestForInformationItemId
- secondaryReason - secondaryReason
- statusId - statusId
type: object type: object
@ -4362,7 +4362,7 @@ paths:
name: mainReason name: mainReason
type: string type: string
- in: query - in: query
name: requestForInformationId name: requestForInformationItemId
type: integer type: integer
- in: query - in: query
name: secondaryReason name: secondaryReason