feat: fixing all request for information
This commit is contained in:
parent
11d0977d86
commit
e24c13367c
|
|
@ -3,14 +3,14 @@ package entity
|
||||||
import "time"
|
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"`
|
||||||
CreatedById uint `json:"created_by_id" gorm:"type:int4"`
|
CreatedById uint `json:"created_by_id" gorm:"type:int4"`
|
||||||
StatusId int `json:"status_id" gorm:"type:int4"`
|
StatusId int `json:"status_id" gorm:"type:int4"`
|
||||||
IsActive *bool `json:"is_active" gorm:"type:bool"`
|
IsActive *bool `json:"is_active" gorm:"type:bool"`
|
||||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||||
UpdatedAt time.Time `json:"updated_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{
|
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"),
|
||||||
CreatedById: c.Query("createdById"),
|
CreatedById: c.Query("createdById"),
|
||||||
StatusId: c.Query("statusId"),
|
StatusId: c.Query("statusId"),
|
||||||
}
|
}
|
||||||
req := reqContext.ToParamRequest()
|
req := reqContext.ToParamRequest()
|
||||||
req.Pagination = paginate
|
req.Pagination = paginate
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -12,72 +12,72 @@ 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"`
|
||||||
CreatedById *int `json:"createdById"`
|
CreatedById *int `json:"createdById"`
|
||||||
StatusId *int `json:"statusId"`
|
StatusId *int `json:"statusId"`
|
||||||
Pagination *paginator.Pagination `json:"pagination"`
|
Pagination *paginator.Pagination `json:"pagination"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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"`
|
||||||
StatusId int `json:"statusId" validate:"required"`
|
StatusId int `json:"statusId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
StatusId: req.StatusId,
|
StatusId: req.StatusId,
|
||||||
IsActive: func() *bool { b := true; return &b }(),
|
IsActive: func() *bool { b := true; return &b }(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"`
|
||||||
StatusId int `json:"statusId" validate:"required"`
|
StatusId int `json:"statusId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
StatusId: req.StatusId,
|
StatusId: req.StatusId,
|
||||||
UpdatedAt: time.Now(),
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"`
|
||||||
CreatedById string `json:"createdById"`
|
CreatedById string `json:"createdById"`
|
||||||
StatusId string `json:"statusId"`
|
StatusId string `json:"statusId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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 != "" {
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ package response
|
||||||
import "time"
|
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"`
|
||||||
CreatedById uint `json:"createdById"`
|
CreatedById uint `json:"createdById"`
|
||||||
StatusId int `json:"statusId"`
|
StatusId int `json:"statusId"`
|
||||||
IsActive *bool `json:"isActive"`
|
IsActive *bool `json:"isActive"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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": {
|
||||||
|
|
|
||||||
|
|
@ -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": {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue