feat: update request for informations, ..items, ..replies
This commit is contained in:
parent
2d4462df11
commit
d689403fd7
|
|
@ -4,6 +4,7 @@ import "time"
|
|||
|
||||
type RequestForInformationItems struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
||||
RequestForInformationId int `json:"request_for_information_id" gorm:"type:int4"`
|
||||
RequestedInfo string `json:"requested_info" gorm:"type:varchar"`
|
||||
Reason string `json:"reason" gorm:"type:varchar"`
|
||||
StatusId int `json:"status_id" gorm:"type:int4"`
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ func (_i *requestForInformationItemsController) All(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
reqContext := request.RequestForInformationItemsQueryRequestContext{
|
||||
RequestForInformationId: c.Query("request_for_information_id"),
|
||||
RequestedInfo: c.Query("requested_info"),
|
||||
Reason: c.Query("reason"),
|
||||
StatusId: c.Query("status_id"),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ func RequestForInformationItemsResponseMapper(requestForInformationItemsReq *ent
|
|||
if requestForInformationItemsReq != nil {
|
||||
requestForInformationItemsRes = &res.RequestForInformationItemsResponse{
|
||||
ID: requestForInformationItemsReq.ID,
|
||||
RequestForInformationId: requestForInformationItemsReq.RequestForInformationId,
|
||||
RequestedInfo: requestForInformationItemsReq.RequestedInfo,
|
||||
Reason: requestForInformationItemsReq.Reason,
|
||||
StatusId: requestForInformationItemsReq.StatusId,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ func (_i *requestForInformationItemsRepository) GetAll(req request.RequestForInf
|
|||
query := _i.DB.DB.Model(&entity.RequestForInformationItems{})
|
||||
query = query.Where("is_active = ?", true)
|
||||
|
||||
if req.RequestForInformationId != nil {
|
||||
query = query.Where("request_for_information_id = ?", req.RequestForInformationId)
|
||||
}
|
||||
if req.RequestedInfo != nil && *req.RequestedInfo != "" {
|
||||
requestedInfo := strings.ToLower(*req.RequestedInfo)
|
||||
query = query.Where("LOWER(requested_info) LIKE ?", "%"+strings.ToLower(requestedInfo)+"%")
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ type RequestForInformationItemsGeneric interface {
|
|||
}
|
||||
|
||||
type RequestForInformationItemsQueryRequest struct {
|
||||
RequestForInformationId *int `json:"request_for_information_id"`
|
||||
RequestedInfo *string `json:"requested_info"`
|
||||
Reason *string `json:"reason"`
|
||||
StatusId *int `json:"status_id"`
|
||||
|
|
@ -19,6 +20,7 @@ type RequestForInformationItemsQueryRequest struct {
|
|||
}
|
||||
|
||||
type RequestForInformationItemsCreateRequest struct {
|
||||
RequestForInformationId int `json:"request_for_information_id" validate:"required"`
|
||||
RequestedInfo string `json:"requested_info" validate:"required"`
|
||||
Reason string `json:"reason" validate:"required"`
|
||||
StatusId int `json:"status_id" validate:"required"`
|
||||
|
|
@ -26,31 +28,35 @@ type RequestForInformationItemsCreateRequest struct {
|
|||
|
||||
func (req RequestForInformationItemsCreateRequest) ToEntity() *entity.RequestForInformationItems {
|
||||
return &entity.RequestForInformationItems{
|
||||
RequestForInformationId: req.RequestForInformationId,
|
||||
RequestedInfo: req.RequestedInfo,
|
||||
Reason: req.Reason,
|
||||
StatusId: req.StatusId,
|
||||
IsActive: func() *bool { b := true; return &b }(),
|
||||
}
|
||||
}
|
||||
|
||||
type RequestForInformationItemsUpdateRequest struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
RequestForInformationId int `json:"request_for_information_id" validate:"required"`
|
||||
RequestedInfo string `json:"requested_info" validate:"required"`
|
||||
Reason string `json:"reason" validate:"required"`
|
||||
StatusId int `json:"status_id" validate:"required"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (req RequestForInformationItemsUpdateRequest) ToEntity() *entity.RequestForInformationItems {
|
||||
return &entity.RequestForInformationItems{
|
||||
ID: req.ID,
|
||||
RequestForInformationId: req.RequestForInformationId,
|
||||
RequestedInfo: req.RequestedInfo,
|
||||
Reason: req.Reason,
|
||||
StatusId: req.StatusId,
|
||||
UpdatedAt: req.UpdatedAt,
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
type RequestForInformationItemsQueryRequestContext struct {
|
||||
RequestForInformationId string `json:"request_for_information_id"`
|
||||
RequestedInfo string `json:"requested_info"`
|
||||
Reason string `json:"reason"`
|
||||
StatusId string `json:"status_id"`
|
||||
|
|
@ -59,6 +65,12 @@ type RequestForInformationItemsQueryRequestContext struct {
|
|||
func (req RequestForInformationItemsQueryRequestContext) ToParamRequest() RequestForInformationItemsQueryRequest {
|
||||
var request RequestForInformationItemsQueryRequest
|
||||
|
||||
if requestForInformationIdStr := req.RequestForInformationId; requestForInformationIdStr != "" {
|
||||
requestForInformationId, err := strconv.Atoi(requestForInformationIdStr)
|
||||
if err == nil {
|
||||
request.RequestForInformationId = &requestForInformationId
|
||||
}
|
||||
}
|
||||
if requestedInfo := req.RequestedInfo; requestedInfo != "" {
|
||||
request.RequestedInfo = &requestedInfo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import "time"
|
|||
|
||||
type RequestForInformationItemsResponse struct {
|
||||
ID uint `json:"id"`
|
||||
RequestForInformationId int `json:"request_for_information_id"`
|
||||
RequestedInfo string `json:"requested_info"`
|
||||
Reason string `json:"reason"`
|
||||
StatusId int `json:"status_id"`
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ func (_i *requestForInformationRepliesController) Show(c *fiber.Ctx) error {
|
|||
// @Description API for create RequestForInformationReplies
|
||||
// @Tags RequestForInformationReplies
|
||||
// @Security Bearer
|
||||
// @Param Authorization header string true "Insert your access token" default(Bearer <Add access token here>)
|
||||
// @Param payload body request.RequestForInformationRepliesCreateRequest true "Required payload"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
|
|
@ -135,6 +136,7 @@ func (_i *requestForInformationRepliesController) Save(c *fiber.Ctx) error {
|
|||
// @Description API for update RequestForInformationReplies
|
||||
// @Tags RequestForInformationReplies
|
||||
// @Security Bearer
|
||||
// @Param Authorization header string true "Insert your access token" default(Bearer <Add access token here>)
|
||||
// @Param payload body request.RequestForInformationRepliesUpdateRequest true "Required payload"
|
||||
// @Param id path int true "RequestForInformationReplies ID"
|
||||
// @Success 200 {object} response.Response
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ func (req RequestForInformationRepliesCreateRequest) ToEntity() *entity.RequestF
|
|||
FileUrl: req.FileUrl,
|
||||
Response: req.Response,
|
||||
StatusId: req.StatusId,
|
||||
IsActive: func() *bool { b := true; return &b }(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5308,6 +5308,11 @@ const docTemplate = `{
|
|||
"name": "reason",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "request_for_information_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "requested_info",
|
||||
|
|
@ -5701,6 +5706,14 @@ const docTemplate = `{
|
|||
],
|
||||
"summary": "Create RequestForInformationReplies",
|
||||
"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",
|
||||
|
|
@ -5799,6 +5812,14 @@ const docTemplate = `{
|
|||
],
|
||||
"summary": "update RequestForInformationReplies",
|
||||
"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",
|
||||
|
|
@ -6120,6 +6141,14 @@ const docTemplate = `{
|
|||
],
|
||||
"summary": "update RequestForInformations",
|
||||
"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",
|
||||
|
|
@ -8273,6 +8302,7 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"required": [
|
||||
"reason",
|
||||
"request_for_information_id",
|
||||
"requested_info",
|
||||
"status_id"
|
||||
],
|
||||
|
|
@ -8280,6 +8310,9 @@ const docTemplate = `{
|
|||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"request_for_information_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"requested_info": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -8293,6 +8326,7 @@ const docTemplate = `{
|
|||
"required": [
|
||||
"id",
|
||||
"reason",
|
||||
"request_for_information_id",
|
||||
"requested_info",
|
||||
"status_id"
|
||||
],
|
||||
|
|
@ -8303,14 +8337,14 @@ const docTemplate = `{
|
|||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"request_for_information_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"requested_info": {
|
||||
"type": "string"
|
||||
},
|
||||
"status_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5297,6 +5297,11 @@
|
|||
"name": "reason",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "request_for_information_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "requested_info",
|
||||
|
|
@ -5690,6 +5695,14 @@
|
|||
],
|
||||
"summary": "Create RequestForInformationReplies",
|
||||
"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",
|
||||
|
|
@ -5788,6 +5801,14 @@
|
|||
],
|
||||
"summary": "update RequestForInformationReplies",
|
||||
"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",
|
||||
|
|
@ -6109,6 +6130,14 @@
|
|||
],
|
||||
"summary": "update RequestForInformations",
|
||||
"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",
|
||||
|
|
@ -8262,6 +8291,7 @@
|
|||
"type": "object",
|
||||
"required": [
|
||||
"reason",
|
||||
"request_for_information_id",
|
||||
"requested_info",
|
||||
"status_id"
|
||||
],
|
||||
|
|
@ -8269,6 +8299,9 @@
|
|||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"request_for_information_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"requested_info": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -8282,6 +8315,7 @@
|
|||
"required": [
|
||||
"id",
|
||||
"reason",
|
||||
"request_for_information_id",
|
||||
"requested_info",
|
||||
"status_id"
|
||||
],
|
||||
|
|
@ -8292,14 +8326,14 @@
|
|||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"request_for_information_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"requested_info": {
|
||||
"type": "string"
|
||||
},
|
||||
"status_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -373,12 +373,15 @@ definitions:
|
|||
properties:
|
||||
reason:
|
||||
type: string
|
||||
request_for_information_id:
|
||||
type: integer
|
||||
requested_info:
|
||||
type: string
|
||||
status_id:
|
||||
type: integer
|
||||
required:
|
||||
- reason
|
||||
- request_for_information_id
|
||||
- requested_info
|
||||
- status_id
|
||||
type: object
|
||||
|
|
@ -388,15 +391,16 @@ definitions:
|
|||
type: integer
|
||||
reason:
|
||||
type: string
|
||||
request_for_information_id:
|
||||
type: integer
|
||||
requested_info:
|
||||
type: string
|
||||
status_id:
|
||||
type: integer
|
||||
updated_at:
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- reason
|
||||
- request_for_information_id
|
||||
- requested_info
|
||||
- status_id
|
||||
type: object
|
||||
|
|
@ -4118,6 +4122,9 @@ paths:
|
|||
- in: query
|
||||
name: reason
|
||||
type: string
|
||||
- in: query
|
||||
name: request_for_information_id
|
||||
type: integer
|
||||
- in: query
|
||||
name: requested_info
|
||||
type: string
|
||||
|
|
@ -4363,6 +4370,12 @@ paths:
|
|||
post:
|
||||
description: API for create RequestForInformationReplies
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
|
|
@ -4455,6 +4468,12 @@ paths:
|
|||
put:
|
||||
description: API for update RequestForInformationReplies
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
|
|
@ -4657,6 +4676,12 @@ paths:
|
|||
put:
|
||||
description: API for update RequestForInformations
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
|
|
|
|||
Loading…
Reference in New Issue