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
+47 -41
View File
@@ -5625,6 +5625,17 @@ const docTemplate = `{
}
}
},
"company.CategoryResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"company.CompanyForm": {
"type": "object",
"properties": {
@@ -5801,7 +5812,7 @@ const docTemplate = `{
"type": "string"
},
"tags": {
"$ref": "#/definitions/company.CompanyTags"
"$ref": "#/definitions/company.CompanyTagsResponse"
},
"tax_id": {
"type": "string"
@@ -5820,46 +5831,6 @@ const docTemplate = `{
}
}
},
"company.CompanyTags": {
"type": "object",
"properties": {
"categories": {
"description": "Categories",
"type": "array",
"items": {
"type": "string"
}
},
"certifications": {
"description": "Certifications",
"type": "array",
"items": {
"type": "string"
}
},
"cpv_codes": {
"description": "CPV codes (Common Procurement Vocabulary)",
"type": "array",
"items": {
"type": "string"
}
},
"keywords": {
"description": "Keywords for search and matching",
"type": "array",
"items": {
"type": "string"
}
},
"specializations": {
"description": "Specializations",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"company.CompanyTagsForm": {
"type": "object",
"properties": {
@@ -5910,6 +5881,41 @@ const docTemplate = `{
}
}
},
"company.CompanyTagsResponse": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"$ref": "#/definitions/company.CategoryResponse"
}
},
"certifications": {
"type": "array",
"items": {
"type": "string"
}
},
"cpv_codes": {
"type": "array",
"items": {
"type": "string"
}
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"specializations": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"company.StatusForm": {
"type": "object",
"properties": {
+47 -41
View File
@@ -5619,6 +5619,17 @@
}
}
},
"company.CategoryResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"company.CompanyForm": {
"type": "object",
"properties": {
@@ -5795,7 +5806,7 @@
"type": "string"
},
"tags": {
"$ref": "#/definitions/company.CompanyTags"
"$ref": "#/definitions/company.CompanyTagsResponse"
},
"tax_id": {
"type": "string"
@@ -5814,46 +5825,6 @@
}
}
},
"company.CompanyTags": {
"type": "object",
"properties": {
"categories": {
"description": "Categories",
"type": "array",
"items": {
"type": "string"
}
},
"certifications": {
"description": "Certifications",
"type": "array",
"items": {
"type": "string"
}
},
"cpv_codes": {
"description": "CPV codes (Common Procurement Vocabulary)",
"type": "array",
"items": {
"type": "string"
}
},
"keywords": {
"description": "Keywords for search and matching",
"type": "array",
"items": {
"type": "string"
}
},
"specializations": {
"description": "Specializations",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"company.CompanyTagsForm": {
"type": "object",
"properties": {
@@ -5904,6 +5875,41 @@
}
}
},
"company.CompanyTagsResponse": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"$ref": "#/definitions/company.CategoryResponse"
}
},
"certifications": {
"type": "array",
"items": {
"type": "string"
}
},
"cpv_codes": {
"type": "array",
"items": {
"type": "string"
}
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"specializations": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"company.StatusForm": {
"type": "object",
"properties": {
+31 -29
View File
@@ -54,6 +54,13 @@ definitions:
example: 123 Main St
type: string
type: object
company.CategoryResponse:
properties:
id:
type: string
name:
type: string
type: object
company.CompanyForm:
properties:
address:
@@ -174,7 +181,7 @@ definitions:
status:
type: string
tags:
$ref: '#/definitions/company.CompanyTags'
$ref: '#/definitions/company.CompanyTagsResponse'
tax_id:
type: string
timezone:
@@ -186,34 +193,6 @@ definitions:
website:
type: string
type: object
company.CompanyTags:
properties:
categories:
description: Categories
items:
type: string
type: array
certifications:
description: Certifications
items:
type: string
type: array
cpv_codes:
description: CPV codes (Common Procurement Vocabulary)
items:
type: string
type: array
keywords:
description: Keywords for search and matching
items:
type: string
type: array
specializations:
description: Specializations
items:
type: string
type: array
type: object
company.CompanyTagsForm:
properties:
categories:
@@ -247,6 +226,29 @@ definitions:
type: string
type: array
type: object
company.CompanyTagsResponse:
properties:
categories:
items:
$ref: '#/definitions/company.CategoryResponse'
type: array
certifications:
items:
type: string
type: array
cpv_codes:
items:
type: string
type: array
keywords:
items:
type: string
type: array
specializations:
items:
type: string
type: array
type: object
company.StatusForm:
properties:
reason:
+1 -1
View File
@@ -137,8 +137,8 @@ func main() {
// Initialize services with repositories
userService := user.NewUserService(userRepository, logger, userAuthService, userValidator)
companyService := company.NewCompanyService(companyRepository, logger)
categoryService := company_category.NewCategoryService(categoryRepository, logger)
companyService := company.NewCompanyService(companyRepository, categoryService, logger)
customerService := customer.NewCustomerService(customerRepository, logger, customerAuthService, companyService)
tenderService := tender.NewTenderService(tenderRepository, companyService, logger)
feedbackService := feedback.NewFeedbackService(feedbackRepo, tenderService, logger)