feat: fixing all request for information
This commit is contained in:
parent
11d0977d86
commit
e24c13367c
|
|
@ -3,14 +3,14 @@ package entity
|
|||
import "time"
|
||||
|
||||
type RequestForInformationObjection struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
||||
RequestForInformationId uint `json:"request_for_information_id" gorm:"type:int4"`
|
||||
DocumentName string `json:"document_name" gorm:"type:varchar"`
|
||||
MainReason string `json:"main_reason" gorm:"type:varchar"`
|
||||
SecondaryReason string `json:"secondary_reason" gorm:"type:varchar"`
|
||||
CreatedById uint `json:"created_by_id" gorm:"type:int4"`
|
||||
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()"`
|
||||
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
||||
RequestForInformationItemId uint `json:"request_for_information_item_id" gorm:"type:int4"`
|
||||
DocumentName string `json:"document_name" gorm:"type:varchar"`
|
||||
MainReason string `json:"main_reason" gorm:"type:varchar"`
|
||||
SecondaryReason string `json:"secondary_reason" gorm:"type:varchar"`
|
||||
CreatedById uint `json:"created_by_id" gorm:"type:int4"`
|
||||
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()"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@ func (_i *requestForInformationObjectionController) All(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
reqContext := request.RequestForInformationObjectionQueryRequestContext{
|
||||
RequestForInformationId: c.Query("requestForInformationId"),
|
||||
DocumentName: c.Query("documentName"),
|
||||
MainReason: c.Query("mainReason"),
|
||||
SecondaryReason: c.Query("secondaryReason"),
|
||||
CreatedById: c.Query("createdById"),
|
||||
StatusId: c.Query("statusId"),
|
||||
RequestForInformationItemId: c.Query("requestForInformationItemId"),
|
||||
DocumentName: c.Query("documentName"),
|
||||
MainReason: c.Query("mainReason"),
|
||||
SecondaryReason: c.Query("secondaryReason"),
|
||||
CreatedById: c.Query("createdById"),
|
||||
StatusId: c.Query("statusId"),
|
||||
}
|
||||
req := reqContext.ToParamRequest()
|
||||
req.Pagination = paginate
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ func (_i *requestForInformationObjectionRepository) GetAll(req request.RequestFo
|
|||
query := _i.DB.DB.Model(&entity.RequestForInformationObjection{})
|
||||
query = query.Where("is_active = ?", true)
|
||||
|
||||
if req.RequestForInformationId != nil {
|
||||
query = query.Where("request_for_information_id = ?", req.RequestForInformationId)
|
||||
if req.RequestForInformationItemId != nil {
|
||||
query = query.Where("request_for_information_item_id = ?", req.RequestForInformationItemId)
|
||||
}
|
||||
if req.DocumentName != nil && *req.DocumentName != "" {
|
||||
documentName := strings.ToLower(*req.DocumentName)
|
||||
|
|
|
|||
|
|
@ -12,72 +12,72 @@ type RequestForInformationObjectionGeneric interface {
|
|||
}
|
||||
|
||||
type RequestForInformationObjectionQueryRequest struct {
|
||||
RequestForInformationId *uint `json:"requestForInformationId"`
|
||||
DocumentName *string `json:"documentName"`
|
||||
MainReason *string `json:"mainReason"`
|
||||
SecondaryReason *string `json:"secondaryReason"`
|
||||
CreatedById *int `json:"createdById"`
|
||||
StatusId *int `json:"statusId"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
RequestForInformationItemId *uint `json:"requestForInformationItemId"`
|
||||
DocumentName *string `json:"documentName"`
|
||||
MainReason *string `json:"mainReason"`
|
||||
SecondaryReason *string `json:"secondaryReason"`
|
||||
CreatedById *int `json:"createdById"`
|
||||
StatusId *int `json:"statusId"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type RequestForInformationObjectionCreateRequest struct {
|
||||
RequestForInformationId uint `json:"requestForInformationId" validate:"required"`
|
||||
DocumentName string `json:"documentName" validate:"required"`
|
||||
MainReason string `json:"mainReason" validate:"required"`
|
||||
SecondaryReason string `json:"secondaryReason" validate:"required"`
|
||||
StatusId int `json:"statusId" validate:"required"`
|
||||
RequestForInformationItemId uint `json:"requestForInformationItemId" validate:"required"`
|
||||
DocumentName string `json:"documentName" validate:"required"`
|
||||
MainReason string `json:"mainReason" validate:"required"`
|
||||
SecondaryReason string `json:"secondaryReason" validate:"required"`
|
||||
StatusId int `json:"statusId" validate:"required"`
|
||||
}
|
||||
|
||||
func (req RequestForInformationObjectionCreateRequest) ToEntity() *entity.RequestForInformationObjection {
|
||||
return &entity.RequestForInformationObjection{
|
||||
RequestForInformationId: req.RequestForInformationId,
|
||||
DocumentName: req.DocumentName,
|
||||
MainReason: req.MainReason,
|
||||
SecondaryReason: req.SecondaryReason,
|
||||
StatusId: req.StatusId,
|
||||
IsActive: func() *bool { b := true; return &b }(),
|
||||
RequestForInformationItemId: req.RequestForInformationItemId,
|
||||
DocumentName: req.DocumentName,
|
||||
MainReason: req.MainReason,
|
||||
SecondaryReason: req.SecondaryReason,
|
||||
StatusId: req.StatusId,
|
||||
IsActive: func() *bool { b := true; return &b }(),
|
||||
}
|
||||
}
|
||||
|
||||
type RequestForInformationObjectionUpdateRequest struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
RequestForInformationId uint `json:"requestForInformationId" validate:"required"`
|
||||
DocumentName string `json:"documentName" validate:"required"`
|
||||
MainReason string `json:"mainReason" validate:"required"`
|
||||
SecondaryReason string `json:"secondaryReason" validate:"required"`
|
||||
StatusId int `json:"statusId" validate:"required"`
|
||||
ID uint `json:"id" validate:"required"`
|
||||
RequestForInformationItemId uint `json:"requestForInformationItemId" validate:"required"`
|
||||
DocumentName string `json:"documentName" validate:"required"`
|
||||
MainReason string `json:"mainReason" validate:"required"`
|
||||
SecondaryReason string `json:"secondaryReason" validate:"required"`
|
||||
StatusId int `json:"statusId" validate:"required"`
|
||||
}
|
||||
|
||||
func (req RequestForInformationObjectionUpdateRequest) ToEntity() *entity.RequestForInformationObjection {
|
||||
return &entity.RequestForInformationObjection{
|
||||
ID: req.ID,
|
||||
RequestForInformationId: req.RequestForInformationId,
|
||||
DocumentName: req.DocumentName,
|
||||
MainReason: req.MainReason,
|
||||
SecondaryReason: req.SecondaryReason,
|
||||
StatusId: req.StatusId,
|
||||
UpdatedAt: time.Now(),
|
||||
ID: req.ID,
|
||||
RequestForInformationItemId: req.RequestForInformationItemId,
|
||||
DocumentName: req.DocumentName,
|
||||
MainReason: req.MainReason,
|
||||
SecondaryReason: req.SecondaryReason,
|
||||
StatusId: req.StatusId,
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
type RequestForInformationObjectionQueryRequestContext struct {
|
||||
RequestForInformationId string `json:"requestForInformationId"`
|
||||
DocumentName string `json:"documentName"`
|
||||
MainReason string `json:"mainReason"`
|
||||
SecondaryReason string `json:"secondaryReason"`
|
||||
CreatedById string `json:"createdById"`
|
||||
StatusId string `json:"statusId"`
|
||||
RequestForInformationItemId string `json:"requestForInformationItemId"`
|
||||
DocumentName string `json:"documentName"`
|
||||
MainReason string `json:"mainReason"`
|
||||
SecondaryReason string `json:"secondaryReason"`
|
||||
CreatedById string `json:"createdById"`
|
||||
StatusId string `json:"statusId"`
|
||||
}
|
||||
|
||||
func (req RequestForInformationObjectionQueryRequestContext) ToParamRequest() RequestForInformationObjectionQueryRequest {
|
||||
var request RequestForInformationObjectionQueryRequest
|
||||
|
||||
if requestForInformationIdStr := req.RequestForInformationId; requestForInformationIdStr != "" {
|
||||
if requestForInformationIdStr := req.RequestForInformationItemId; requestForInformationIdStr != "" {
|
||||
requestForInformationId, err := strconv.Atoi(requestForInformationIdStr)
|
||||
if err == nil {
|
||||
requestForInformationIdUint := uint(requestForInformationId)
|
||||
request.RequestForInformationId = &requestForInformationIdUint
|
||||
request.RequestForInformationItemId = &requestForInformationIdUint
|
||||
}
|
||||
}
|
||||
if documentName := req.DocumentName; documentName != "" {
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package response
|
|||
import "time"
|
||||
|
||||
type RequestForInformationObjectionResponse struct {
|
||||
ID uint `json:"id"`
|
||||
RequestForInformationId uint `json:"requestForInformationId"`
|
||||
DocumentName string `json:"documentName"`
|
||||
MainReason string `json:"mainReason"`
|
||||
SecondaryReason string `json:"secondaryReason"`
|
||||
CreatedById uint `json:"createdById"`
|
||||
StatusId int `json:"statusId"`
|
||||
IsActive *bool `json:"isActive"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID uint `json:"id"`
|
||||
RequestForInformationItemId uint `json:"requestForInformationItemId"`
|
||||
DocumentName string `json:"documentName"`
|
||||
MainReason string `json:"mainReason"`
|
||||
SecondaryReason string `json:"secondaryReason"`
|
||||
CreatedById uint `json:"createdById"`
|
||||
StatusId int `json:"statusId"`
|
||||
IsActive *bool `json:"isActive"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5629,7 +5629,7 @@ const docTemplate = `{
|
|||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "requestForInformationId",
|
||||
"name": "requestForInformationItemId",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
|
|
@ -8745,7 +8745,7 @@ const docTemplate = `{
|
|||
"required": [
|
||||
"documentName",
|
||||
"mainReason",
|
||||
"requestForInformationId",
|
||||
"requestForInformationItemId",
|
||||
"secondaryReason",
|
||||
"statusId"
|
||||
],
|
||||
|
|
@ -8756,7 +8756,7 @@ const docTemplate = `{
|
|||
"mainReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"requestForInformationId": {
|
||||
"requestForInformationItemId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"secondaryReason": {
|
||||
|
|
@ -8773,7 +8773,7 @@ const docTemplate = `{
|
|||
"documentName",
|
||||
"id",
|
||||
"mainReason",
|
||||
"requestForInformationId",
|
||||
"requestForInformationItemId",
|
||||
"secondaryReason",
|
||||
"statusId"
|
||||
],
|
||||
|
|
@ -8787,7 +8787,7 @@ const docTemplate = `{
|
|||
"mainReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"requestForInformationId": {
|
||||
"requestForInformationItemId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"secondaryReason": {
|
||||
|
|
|
|||
|
|
@ -5618,7 +5618,7 @@
|
|||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "requestForInformationId",
|
||||
"name": "requestForInformationItemId",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
|
|
@ -8734,7 +8734,7 @@
|
|||
"required": [
|
||||
"documentName",
|
||||
"mainReason",
|
||||
"requestForInformationId",
|
||||
"requestForInformationItemId",
|
||||
"secondaryReason",
|
||||
"statusId"
|
||||
],
|
||||
|
|
@ -8745,7 +8745,7 @@
|
|||
"mainReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"requestForInformationId": {
|
||||
"requestForInformationItemId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"secondaryReason": {
|
||||
|
|
@ -8762,7 +8762,7 @@
|
|||
"documentName",
|
||||
"id",
|
||||
"mainReason",
|
||||
"requestForInformationId",
|
||||
"requestForInformationItemId",
|
||||
"secondaryReason",
|
||||
"statusId"
|
||||
],
|
||||
|
|
@ -8776,7 +8776,7 @@
|
|||
"mainReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"requestForInformationId": {
|
||||
"requestForInformationItemId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"secondaryReason": {
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ definitions:
|
|||
type: string
|
||||
mainReason:
|
||||
type: string
|
||||
requestForInformationId:
|
||||
requestForInformationItemId:
|
||||
type: integer
|
||||
secondaryReason:
|
||||
type: string
|
||||
|
|
@ -419,7 +419,7 @@ definitions:
|
|||
required:
|
||||
- documentName
|
||||
- mainReason
|
||||
- requestForInformationId
|
||||
- requestForInformationItemId
|
||||
- secondaryReason
|
||||
- statusId
|
||||
type: object
|
||||
|
|
@ -431,7 +431,7 @@ definitions:
|
|||
type: integer
|
||||
mainReason:
|
||||
type: string
|
||||
requestForInformationId:
|
||||
requestForInformationItemId:
|
||||
type: integer
|
||||
secondaryReason:
|
||||
type: string
|
||||
|
|
@ -441,7 +441,7 @@ definitions:
|
|||
- documentName
|
||||
- id
|
||||
- mainReason
|
||||
- requestForInformationId
|
||||
- requestForInformationItemId
|
||||
- secondaryReason
|
||||
- statusId
|
||||
type: object
|
||||
|
|
@ -4362,7 +4362,7 @@ paths:
|
|||
name: mainReason
|
||||
type: string
|
||||
- in: query
|
||||
name: requestForInformationId
|
||||
name: requestForInformationItemId
|
||||
type: integer
|
||||
- in: query
|
||||
name: secondaryReason
|
||||
|
|
|
|||
Loading…
Reference in New Issue