Implement Company Search and Update API Documentation
- Introduced a new search functionality for companies, allowing advanced filtering capabilities including tags, business criteria, and location. - Updated the API documentation to reflect changes in the search endpoint, enhancing clarity for API consumers. - Refactored existing company-related API endpoints for consistency, including renaming and restructuring routes. - Enhanced response structures to return company entities directly, simplifying the response handling in API endpoints. - Removed unused query parameters and handlers, streamlining the company management functionality.
This commit is contained in:
@@ -62,7 +62,7 @@ func (s *customerService) Register(ctx context.Context, form *CreateCustomerForm
|
||||
var companyIDs []string
|
||||
if len(form.CompanyIDs) > 0 {
|
||||
for _, companyID := range form.CompanyIDs {
|
||||
_, err := s.companyService.GetCompanyByID(ctx, companyID)
|
||||
_, err := s.companyService.GetByID(ctx, companyID)
|
||||
if err != nil {
|
||||
s.logger.Error("Invalid company ID provided", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
@@ -210,7 +210,7 @@ func (s *customerService) Update(ctx context.Context, id string, form *UpdateCus
|
||||
// Verify that all company IDs exist
|
||||
var validCompanyIDs []string
|
||||
for _, companyID := range form.CompanyIDs {
|
||||
_, err := s.companyService.GetCompanyByID(ctx, companyID)
|
||||
_, err := s.companyService.GetByID(ctx, companyID)
|
||||
if err != nil {
|
||||
s.logger.Error("Invalid company ID provided in update", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
@@ -317,7 +317,7 @@ func (s *customerService) AssignCompanies(ctx context.Context, customerID string
|
||||
// Verify companies exist and update customer's company IDs
|
||||
var validCompanyIDs []string
|
||||
for _, companyID := range companyIDs {
|
||||
_, err = s.companyService.GetCompanyByID(ctx, companyID)
|
||||
_, err = s.companyService.GetByID(ctx, companyID)
|
||||
if err != nil {
|
||||
s.logger.Error("Company not found during assignment", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
@@ -695,7 +695,7 @@ func (s *customerService) loadCompaniesForCustomer(ctx context.Context, customer
|
||||
}
|
||||
|
||||
// Load companies in batch using the new GetCompaniesByIDs method
|
||||
companies, err := s.companyService.GetCompaniesByIDs(ctx, customer.CompanyIDs)
|
||||
companies, err := s.companyService.GetByIDs(ctx, customer.CompanyIDs)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to load companies for customer", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
@@ -709,7 +709,7 @@ func (s *customerService) loadCompaniesForCustomer(ctx context.Context, customer
|
||||
var companySummaries []*CompanySummary
|
||||
for _, company := range companies {
|
||||
companySummaries = append(companySummaries, &CompanySummary{
|
||||
ID: company.ID.Hex(),
|
||||
ID: company.ID,
|
||||
Name: company.Name,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user