Add Company Feedback Statistics Endpoint and Update API Documentation

- Introduced a new endpoint to retrieve comprehensive feedback statistics for the authenticated user's company, including total likes, dislikes, and percentage calculations.
- Implemented the GetCompanyFeedbackStats method in the feedback handler to handle requests, ensuring proper authentication and error handling.
- Updated Swagger JSON, YAML, and Go documentation to accurately reflect the new endpoint, including detailed descriptions, parameters, and response formats for the CompanyFeedbackStatsResponse.
- Enhanced the feedback repository and service layers to support the new statistics functionality, improving the overall data handling capabilities of the tender management system.
- These changes enhance the usability and functionality of the API, providing valuable insights into company feedback statistics.
This commit is contained in:
n.nakhostin
2025-08-25 13:39:35 +03:30
parent 488d43380b
commit 0e14a11daf
8 changed files with 477 additions and 76 deletions
+133 -28
View File
@@ -5418,6 +5418,109 @@ const docTemplate = `{
}
}
},
"/api/v1/feedback/stats/company": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Retrieve comprehensive feedback statistics for the authenticated user's company including total likes, dislikes, and percentage calculations.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Feedback"
],
"summary": "Get company feedback statistics",
"responses": {
"200": {
"description": "Company feedback statistics retrieved successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/feedback.CompanyFeedbackStatsResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Missing company association",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
]
}
},
"401": {
"description": "Unauthorized - User not authenticated",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
]
}
},
"500": {
"description": "Internal server error",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
]
}
}
}
}
},
"/api/v1/feedback/tender/{tender_id}": {
"get": {
"security": [
@@ -7592,6 +7695,27 @@ const docTemplate = `{
}
}
},
"feedback.CompanyFeedbackStatsResponse": {
"type": "object",
"properties": {
"company_id": {
"type": "string"
},
"last_updated": {
"description": "Unix timestamp",
"type": "integer"
},
"total_dislikes": {
"type": "integer"
},
"total_feedback": {
"type": "integer"
},
"total_likes": {
"type": "integer"
}
}
},
"feedback.FeedbackListResponse": {
"type": "object",
"properties": {
@@ -7759,6 +7883,9 @@ const docTemplate = `{
"tender.TenderResponse": {
"type": "object",
"properties": {
"application_deadline": {
"type": "integer"
},
"buyer_organization": {
"$ref": "#/definitions/tender.OrganizationResponse"
},
@@ -7801,9 +7928,15 @@ const docTemplate = `{
"submission_deadline": {
"type": "integer"
},
"submission_url": {
"type": "string"
},
"tender_deadline": {
"type": "integer"
},
"tender_id": {
"type": "string"
},
"title": {
"type": "string"
}
@@ -7875,20 +8008,6 @@ const docTemplate = `{
"tender_approval.CompanyTenderApprovalStatsResponse": {
"type": "object",
"properties": {
"approvals_by_status": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approvals_by_submission": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approved_tenders": {
"type": "integer"
},
@@ -8002,20 +8121,6 @@ const docTemplate = `{
"tender_approval.TenderApprovalStatsResponse": {
"type": "object",
"properties": {
"approvals_by_status": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approvals_by_submission": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approved_tenders": {
"type": "integer"
},
+133 -28
View File
@@ -5412,6 +5412,109 @@
}
}
},
"/api/v1/feedback/stats/company": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Retrieve comprehensive feedback statistics for the authenticated user's company including total likes, dislikes, and percentage calculations.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Feedback"
],
"summary": "Get company feedback statistics",
"responses": {
"200": {
"description": "Company feedback statistics retrieved successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/feedback.CompanyFeedbackStatsResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Missing company association",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
]
}
},
"401": {
"description": "Unauthorized - User not authenticated",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
]
}
},
"500": {
"description": "Internal server error",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
]
}
}
}
}
},
"/api/v1/feedback/tender/{tender_id}": {
"get": {
"security": [
@@ -7586,6 +7689,27 @@
}
}
},
"feedback.CompanyFeedbackStatsResponse": {
"type": "object",
"properties": {
"company_id": {
"type": "string"
},
"last_updated": {
"description": "Unix timestamp",
"type": "integer"
},
"total_dislikes": {
"type": "integer"
},
"total_feedback": {
"type": "integer"
},
"total_likes": {
"type": "integer"
}
}
},
"feedback.FeedbackListResponse": {
"type": "object",
"properties": {
@@ -7753,6 +7877,9 @@
"tender.TenderResponse": {
"type": "object",
"properties": {
"application_deadline": {
"type": "integer"
},
"buyer_organization": {
"$ref": "#/definitions/tender.OrganizationResponse"
},
@@ -7795,9 +7922,15 @@
"submission_deadline": {
"type": "integer"
},
"submission_url": {
"type": "string"
},
"tender_deadline": {
"type": "integer"
},
"tender_id": {
"type": "string"
},
"title": {
"type": "string"
}
@@ -7869,20 +8002,6 @@
"tender_approval.CompanyTenderApprovalStatsResponse": {
"type": "object",
"properties": {
"approvals_by_status": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approvals_by_submission": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approved_tenders": {
"type": "integer"
},
@@ -7996,20 +8115,6 @@
"tender_approval.TenderApprovalStatsResponse": {
"type": "object",
"properties": {
"approvals_by_status": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approvals_by_submission": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"approved_tenders": {
"type": "integer"
},
+76 -20
View File
@@ -748,6 +748,20 @@ definitions:
is_verified:
type: boolean
type: object
feedback.CompanyFeedbackStatsResponse:
properties:
company_id:
type: string
last_updated:
description: Unix timestamp
type: integer
total_dislikes:
type: integer
total_feedback:
type: integer
total_likes:
type: integer
type: object
feedback.FeedbackListResponse:
properties:
feedback:
@@ -860,6 +874,8 @@ definitions:
type: object
tender.TenderResponse:
properties:
application_deadline:
type: integer
buyer_organization:
$ref: '#/definitions/tender.OrganizationResponse'
country_code:
@@ -888,8 +904,12 @@ definitions:
$ref: '#/definitions/tender.TenderStatus'
submission_deadline:
type: integer
submission_url:
type: string
tender_deadline:
type: integer
tender_id:
type: string
title:
type: string
type: object
@@ -941,16 +961,6 @@ definitions:
- ApprovalStatusRejected
tender_approval.CompanyTenderApprovalStatsResponse:
properties:
approvals_by_status:
additionalProperties:
format: int64
type: integer
type: object
approvals_by_submission:
additionalProperties:
format: int64
type: integer
type: object
approved_tenders:
type: integer
company_id:
@@ -1026,16 +1036,6 @@ definitions:
type: object
tender_approval.TenderApprovalStatsResponse:
properties:
approvals_by_status:
additionalProperties:
format: int64
type: integer
type: object
approvals_by_submission:
additionalProperties:
format: int64
type: integer
type: object
approved_tenders:
type: integer
last_updated:
@@ -4786,6 +4786,62 @@ paths:
summary: Get feedback by ID
tags:
- Feedback
/api/v1/feedback/stats/company:
get:
consumes:
- application/json
description: Retrieve comprehensive feedback statistics for the authenticated
user's company including total likes, dislikes, and percentage calculations.
produces:
- application/json
responses:
"200":
description: Company feedback statistics retrieved successfully
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/feedback.CompanyFeedbackStatsResponse'
type: object
"400":
description: Bad request - Missing company association
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
error:
type: string
message:
type: string
type: object
"401":
description: Unauthorized - User not authenticated
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
error:
type: string
message:
type: string
type: object
"500":
description: Internal server error
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
error:
type: string
message:
type: string
type: object
security:
- BearerAuth: []
summary: Get company feedback statistics
tags:
- Feedback
/api/v1/feedback/tender/{tender_id}:
get:
consumes:
+1
View File
@@ -152,6 +152,7 @@ func RegisterPublicRoutes(e *echo.Echo, customerHandler *customer.Handler, tende
feedbackGP.GET("", feedbackHandler.PublicListFeedback)
feedbackGP.GET("/tender/:tender_id", feedbackHandler.PublicGetFeedbackByTenderID)
feedbackGP.GET("/:id", feedbackHandler.PublicGetFeedback)
feedbackGP.GET("/stats/company", feedbackHandler.GetCompanyFeedbackStats)
}
// Public Tender Approvals Routes