Enhance Company Management with Category Integration and API Documentation Updates

- Updated the Company service to include category validation during creation and updates, ensuring that only valid categories are associated with companies.
- Introduced a new CategoryResponse structure to encapsulate category details in API responses, improving the clarity of the data returned.
- Enhanced the CompanyResponse structure to include category details, providing more comprehensive information in API responses.
- Updated Swagger and YAML documentation to reflect the new category integration, including detailed descriptions and examples for the updated response structures.
- Improved error handling for invalid category data during company creation and updates, enhancing the robustness of the API.
- Refactored existing API handlers to accommodate the new category-related changes, ensuring a seamless user experience across the application.
This commit is contained in:
n.nakhostin
2025-09-08 13:01:45 +03:30
parent 991771ee19
commit 8670b3272d
8 changed files with 297 additions and 151 deletions
+8
View File
@@ -80,6 +80,10 @@ func (h *Handler) Create(c echo.Context) error {
err.Error() == "company with this tax ID already exists" {
return response.Conflict(c, err.Error())
}
if err.Error() == "one or more categories are invalid" ||
err.Error() == "failed to validate categories" {
return response.BadRequest(c, err.Error(), "Invalid category data")
}
return response.InternalServerError(c, "Failed to create company")
}
@@ -146,6 +150,10 @@ func (h *Handler) Update(c echo.Context) error {
err.Error() == "company with this tax ID already exists" {
return response.Conflict(c, err.Error())
}
if err.Error() == "one or more categories are invalid" ||
err.Error() == "failed to validate categories" {
return response.BadRequest(c, err.Error(), "Invalid category data")
}
return response.InternalServerError(c, "Failed to update company")
}