company feedback performance update
This commit is contained in:
@@ -16,6 +16,7 @@ type Service interface {
|
||||
Update(ctx context.Context, id string, form *CompanyForm) (*CompanyResponse, error)
|
||||
GetByID(ctx context.Context, id string) (*CompanyResponse, error)
|
||||
GetByIDs(ctx context.Context, ids []string) ([]*CompanyResponse, error)
|
||||
GetNamesByIDs(ctx context.Context, ids []string) (map[string]*CompanyResponse, error)
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// Company listing and search
|
||||
@@ -389,6 +390,30 @@ func (s *companyService) GetByIDs(ctx context.Context, ids []string) ([]*Company
|
||||
return companyResponses, nil
|
||||
}
|
||||
|
||||
// GetNamesByIDs returns company id and name keyed by company ID without loading categories.
|
||||
func (s *companyService) GetNamesByIDs(ctx context.Context, ids []string) (map[string]*CompanyResponse, error) {
|
||||
if len(ids) == 0 {
|
||||
return map[string]*CompanyResponse{}, nil
|
||||
}
|
||||
|
||||
companies, err := s.repository.GetByIDs(ctx, ids)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get companies by IDs for names", map[string]interface{}{
|
||||
"count": len(ids),
|
||||
"error": err.Error(),
|
||||
})
|
||||
return nil, errors.New("failed to get companies by IDs")
|
||||
}
|
||||
|
||||
out := make(map[string]*CompanyResponse, len(companies))
|
||||
for _, c := range companies {
|
||||
id := c.ID.Hex()
|
||||
out[id] = &CompanyResponse{ID: id, Name: c.Name}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// UpdateCompanyStatus updates company status
|
||||
func (s *companyService) UpdateStatus(ctx context.Context, id string, form *StatusForm) error {
|
||||
// Get company to check if exists
|
||||
|
||||
Reference in New Issue
Block a user