Refactor Tender Approval Management and Update API Documentation

- Replaced the existing tender approval update and delete endpoints with a new toggle functionality, allowing for more streamlined management of tender approvals.
- Introduced the `ToggleTenderApproval` method in the service layer to handle both approval and rejection actions based on the current state of the tender approval.
- Updated the API documentation to reflect the new endpoint structure and response formats, including the `TenderApprovalWithTenderResponse`.
- Enhanced Swagger documentation to ensure accurate representation of the updated tender approval operations.
- Removed obsolete methods and routes to maintain a clean and efficient codebase, adhering to Clean Architecture principles.
This commit is contained in:
n.nakhostin
2025-08-19 11:01:49 +03:30
parent dd2573a308
commit 392b31626d
10 changed files with 298 additions and 532 deletions
+81 -142
View File
@@ -4264,7 +4264,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"TenderApprovals"
"Admin-TenderApprovals"
],
"summary": "Get tender approval by ID",
"parameters": [
@@ -5886,7 +5886,7 @@ const docTemplate = `{
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/tender_approval.TenderApprovalResponse"
"$ref": "#/definitions/tender_approval.TenderApprovalWithTenderResponse"
}
}
}
@@ -6114,139 +6114,6 @@ const docTemplate = `{
}
}
}
},
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update tender approval information",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenderApprovals"
],
"summary": "Update tender approval",
"parameters": [
{
"type": "string",
"description": "Tender Approval ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Tender approval update information",
"name": "tender_approval",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/tender_approval.UpdateTenderApprovalForm"
}
}
],
"responses": {
"200": {
"description": "Tender approval updated successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/tender_approval.TenderApprovalResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Invalid input data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not found - Tender approval not found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"422": {
"description": "Validation error - Invalid request data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "Delete a tender approval",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenderApprovals"
],
"summary": "Delete tender approval",
"parameters": [
{
"type": "string",
"description": "Tender Approval ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Tender approval deleted successfully",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"400": {
"description": "Bad request - Invalid tender approval ID",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not found - Tender approval not found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/tenders": {
@@ -7642,15 +7509,11 @@ const docTemplate = `{
"type": "string",
"enum": [
"like",
"dislike",
"unlike",
"undislike"
"dislike"
],
"x-enum-varnames": [
"FeedbackTypeLike",
"FeedbackTypeDislike",
"FeedbackTypeUnLike",
"FeedbackTypeUnDislike"
"FeedbackTypeDislike"
]
},
"feedback.ToggleFeedbackForm": {
@@ -7896,6 +7759,14 @@ const docTemplate = `{
}
}
},
"tender_approval.OrganizationResponse": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"tender_approval.SubmissionMode": {
"type": "string",
"enum": [
@@ -7992,14 +7863,82 @@ const docTemplate = `{
}
}
},
"tender_approval.UpdateTenderApprovalForm": {
"tender_approval.TenderApprovalWithTenderResponse": {
"type": "object",
"properties": {
"company_id": {
"type": "string"
},
"created_at": {
"type": "integer"
},
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"submission_mode": {
"type": "string"
},
"tender": {
"$ref": "#/definitions/tender_approval.TenderDetails"
},
"tender_id": {
"type": "string"
}
}
},
"tender_approval.TenderDetails": {
"type": "object",
"properties": {
"buyer_organization": {
"$ref": "#/definitions/tender_approval.OrganizationResponse"
},
"country_code": {
"type": "string"
},
"currency": {
"type": "string"
},
"description": {
"type": "string"
},
"duration": {
"type": "string"
},
"duration_unit": {
"type": "string"
},
"estimated_value": {
"type": "number"
},
"id": {
"type": "string"
},
"notice_publication_id": {
"type": "string"
},
"procedure_code": {
"type": "string"
},
"procurement_type_code": {
"type": "string"
},
"publication_date": {
"type": "integer"
},
"status": {
"type": "string"
},
"submission_deadline": {
"type": "integer"
},
"tender_deadline": {
"type": "integer"
},
"title": {
"type": "string"
}
}
},
+81 -142
View File
@@ -4258,7 +4258,7 @@
"application/json"
],
"tags": [
"TenderApprovals"
"Admin-TenderApprovals"
],
"summary": "Get tender approval by ID",
"parameters": [
@@ -5880,7 +5880,7 @@
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/tender_approval.TenderApprovalResponse"
"$ref": "#/definitions/tender_approval.TenderApprovalWithTenderResponse"
}
}
}
@@ -6108,139 +6108,6 @@
}
}
}
},
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update tender approval information",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenderApprovals"
],
"summary": "Update tender approval",
"parameters": [
{
"type": "string",
"description": "Tender Approval ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Tender approval update information",
"name": "tender_approval",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/tender_approval.UpdateTenderApprovalForm"
}
}
],
"responses": {
"200": {
"description": "Tender approval updated successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/tender_approval.TenderApprovalResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Invalid input data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not found - Tender approval not found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"422": {
"description": "Validation error - Invalid request data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "Delete a tender approval",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenderApprovals"
],
"summary": "Delete tender approval",
"parameters": [
{
"type": "string",
"description": "Tender Approval ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Tender approval deleted successfully",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"400": {
"description": "Bad request - Invalid tender approval ID",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not found - Tender approval not found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/tenders": {
@@ -7636,15 +7503,11 @@
"type": "string",
"enum": [
"like",
"dislike",
"unlike",
"undislike"
"dislike"
],
"x-enum-varnames": [
"FeedbackTypeLike",
"FeedbackTypeDislike",
"FeedbackTypeUnLike",
"FeedbackTypeUnDislike"
"FeedbackTypeDislike"
]
},
"feedback.ToggleFeedbackForm": {
@@ -7890,6 +7753,14 @@
}
}
},
"tender_approval.OrganizationResponse": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"tender_approval.SubmissionMode": {
"type": "string",
"enum": [
@@ -7986,14 +7857,82 @@
}
}
},
"tender_approval.UpdateTenderApprovalForm": {
"tender_approval.TenderApprovalWithTenderResponse": {
"type": "object",
"properties": {
"company_id": {
"type": "string"
},
"created_at": {
"type": "integer"
},
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"submission_mode": {
"type": "string"
},
"tender": {
"$ref": "#/definitions/tender_approval.TenderDetails"
},
"tender_id": {
"type": "string"
}
}
},
"tender_approval.TenderDetails": {
"type": "object",
"properties": {
"buyer_organization": {
"$ref": "#/definitions/tender_approval.OrganizationResponse"
},
"country_code": {
"type": "string"
},
"currency": {
"type": "string"
},
"description": {
"type": "string"
},
"duration": {
"type": "string"
},
"duration_unit": {
"type": "string"
},
"estimated_value": {
"type": "number"
},
"id": {
"type": "string"
},
"notice_publication_id": {
"type": "string"
},
"procedure_code": {
"type": "string"
},
"procurement_type_code": {
"type": "string"
},
"publication_date": {
"type": "integer"
},
"status": {
"type": "string"
},
"submission_deadline": {
"type": "integer"
},
"tender_deadline": {
"type": "integer"
},
"title": {
"type": "string"
}
}
},
+53 -90
View File
@@ -763,14 +763,10 @@ definitions:
enum:
- like
- dislike
- unlike
- undislike
type: string
x-enum-varnames:
- FeedbackTypeLike
- FeedbackTypeDislike
- FeedbackTypeUnLike
- FeedbackTypeUnDislike
feedback.ToggleFeedbackForm:
properties:
feedback_type:
@@ -937,6 +933,11 @@ definitions:
tender_id:
type: string
type: object
tender_approval.OrganizationResponse:
properties:
name:
type: string
type: object
tender_approval.SubmissionMode:
enum:
- self-apply
@@ -1002,12 +1003,57 @@ definitions:
total_approvals:
type: integer
type: object
tender_approval.UpdateTenderApprovalForm:
tender_approval.TenderApprovalWithTenderResponse:
properties:
company_id:
type: string
created_at:
type: integer
id:
type: string
status:
type: string
submission_mode:
type: string
tender:
$ref: '#/definitions/tender_approval.TenderDetails'
tender_id:
type: string
type: object
tender_approval.TenderDetails:
properties:
buyer_organization:
$ref: '#/definitions/tender_approval.OrganizationResponse'
country_code:
type: string
currency:
type: string
description:
type: string
duration:
type: string
duration_unit:
type: string
estimated_value:
type: number
id:
type: string
notice_publication_id:
type: string
procedure_code:
type: string
procurement_type_code:
type: string
publication_date:
type: integer
status:
type: string
submission_deadline:
type: integer
tender_deadline:
type: integer
title:
type: string
type: object
user.AuthResponse:
properties:
@@ -3814,7 +3860,7 @@ paths:
- BearerAuth: []
summary: Get tender approval by ID
tags:
- TenderApprovals
- Admin-TenderApprovals
/admin/v1/tender-approvals/stats:
get:
consumes:
@@ -4910,7 +4956,7 @@ paths:
- properties:
data:
items:
$ref: '#/definitions/tender_approval.TenderApprovalResponse'
$ref: '#/definitions/tender_approval.TenderApprovalWithTenderResponse'
type: array
type: object
"400":
@@ -4973,40 +5019,6 @@ paths:
tags:
- TenderApprovals
/api/v1/tender-approvals/{id}:
delete:
consumes:
- application/json
description: Delete a tender approval
parameters:
- description: Tender Approval ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Tender approval deleted successfully
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad request - Invalid tender approval ID
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not found - Tender approval not found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Delete tender approval
tags:
- TenderApprovals
get:
consumes:
- application/json
@@ -5046,55 +5058,6 @@ paths:
summary: Get tender approval by ID
tags:
- TenderApprovals
put:
consumes:
- application/json
description: Update tender approval information
parameters:
- description: Tender Approval ID
in: path
name: id
required: true
type: string
- description: Tender approval update information
in: body
name: tender_approval
required: true
schema:
$ref: '#/definitions/tender_approval.UpdateTenderApprovalForm'
produces:
- application/json
responses:
"200":
description: Tender approval updated successfully
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/tender_approval.TenderApprovalResponse'
type: object
"400":
description: Bad request - Invalid input data
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not found - Tender approval not found
schema:
$ref: '#/definitions/response.APIResponse'
"422":
description: Validation error - Invalid request data
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Update tender approval
tags:
- TenderApprovals
/api/v1/tender-approvals/tender/{tender_id}:
get:
consumes:
+1 -4
View File
@@ -115,7 +115,6 @@ func RegisterAdminRoutes(e *echo.Echo, userHandler *user.Handler, companyHandler
tenderApprovalGP.Use(userHandler.AuthMiddleware())
tenderApprovalGP.GET("", tenderApprovalHandler.ListTenderApprovals)
tenderApprovalGP.GET("/:id", tenderApprovalHandler.GetTenderApproval)
tenderApprovalGP.PUT("/:id", tenderApprovalHandler.UpdateTenderApproval)
tenderApprovalGP.GET("/stats", tenderApprovalHandler.GetTenderApprovalStats)
tenderApprovalGP.GET("/submission-mode/:submission_mode", tenderApprovalHandler.GetTenderApprovalsBySubmissionMode)
tenderApprovalGP.GET("/status/:status", tenderApprovalHandler.GetTenderApprovalsByStatus)
@@ -159,11 +158,9 @@ func RegisterPublicRoutes(e *echo.Echo, customerHandler *customer.Handler, tende
tenderApprovalGP := v1.Group("/tender-approvals")
{
tenderApprovalGP.Use(customerHandler.AuthMiddleware())
tenderApprovalGP.POST("", tenderApprovalHandler.CreateTenderApproval)
tenderApprovalGP.PUT("/:id", tenderApprovalHandler.UpdateTenderApproval)
tenderApprovalGP.POST("", tenderApprovalHandler.ToggleTenderApproval)
tenderApprovalGP.GET("", tenderApprovalHandler.PublicGetTenderApprovals)
tenderApprovalGP.GET("/:id", tenderApprovalHandler.GetPublicTenderApproval)
tenderApprovalGP.GET("/tender/:tender_id", tenderApprovalHandler.GetTenderApprovalByTenderAndCompany)
tenderApprovalGP.DELETE("/:id", tenderApprovalHandler.DeleteTenderApproval)
}
}