Update API documentation to reflect customer authorization changes
- Changed tags from "Customers-Mobile" to "Customers-Authorization" in Swagger documentation for customer logout and profile retrieval endpoints. - Updated the Company entity to replace CustomerID with OwnerCustomerID to better represent ownership. - Removed obsolete customer assignment methods and related forms from the company domain, streamlining the codebase. - Adjusted customer forms to include CompanyID instead of CompanyName for better consistency in customer management. - Enhanced Swagger documentation to accurately reflect the new structure and authorization details for customer-related endpoints.
This commit is contained in:
@@ -30,8 +30,6 @@ type Repository interface {
|
||||
CountWithCustomer(ctx context.Context) (int64, error)
|
||||
UpdateStatus(ctx context.Context, id string, status CompanyStatus) error
|
||||
UpdateVerification(ctx context.Context, id string, isVerified, isCompliant bool, complianceNotes *string) error
|
||||
AssignCustomer(ctx context.Context, id string, customerID string) error
|
||||
UnassignCustomer(ctx context.Context, id string) error
|
||||
UpdateTags(ctx context.Context, id string, tags *CompanyTags) error
|
||||
AddTags(ctx context.Context, id string, cpvCodes []string, categories []string, keywords []string, specializations []string, certifications []string) error
|
||||
RemoveTags(ctx context.Context, id string, cpvCodes []string, categories []string, keywords []string, specializations []string, certifications []string) error
|
||||
@@ -591,66 +589,6 @@ func (r *companyRepository) UpdateVerification(ctx context.Context, id string, i
|
||||
return nil
|
||||
}
|
||||
|
||||
// AssignCustomer assigns a customer to a company
|
||||
func (r *companyRepository) AssignCustomer(ctx context.Context, id string, customerID string) error {
|
||||
// Get company first
|
||||
company, err := r.GetByID(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Assign customer
|
||||
company.CustomerID = &customerID
|
||||
company.SetUpdatedAt(time.Now().Unix())
|
||||
|
||||
// Update in database
|
||||
err = r.ormRepo.Update(ctx, company)
|
||||
if err != nil {
|
||||
r.logger.Error("Failed to assign customer to company", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"company_id": id,
|
||||
"customer_id": customerID,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
r.logger.Info("Customer assigned to company successfully", map[string]interface{}{
|
||||
"company_id": id,
|
||||
"customer_id": customerID,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnassignCustomer unassigns a customer from a company
|
||||
func (r *companyRepository) UnassignCustomer(ctx context.Context, id string) error {
|
||||
// Get company first
|
||||
company, err := r.GetByID(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Unassign customer
|
||||
company.CustomerID = nil
|
||||
company.SetUpdatedAt(time.Now().Unix())
|
||||
|
||||
// Update in database
|
||||
err = r.ormRepo.Update(ctx, company)
|
||||
if err != nil {
|
||||
r.logger.Error("Failed to unassign customer from company", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"company_id": id,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
r.logger.Info("Customer unassigned from company successfully", map[string]interface{}{
|
||||
"company_id": id,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateTags updates company tags
|
||||
func (r *companyRepository) UpdateTags(ctx context.Context, id string, tags *CompanyTags) error {
|
||||
// Get company first
|
||||
|
||||
Reference in New Issue
Block a user