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:
@@ -9,6 +9,7 @@ import (
|
||||
"tm/pkg/response"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// Repository defines the interface for category data operations
|
||||
@@ -98,7 +99,16 @@ func (r *categoryRepository) GetByID(ctx context.Context, id string) (*Category,
|
||||
|
||||
// GetByIDs retrieves categories by IDs
|
||||
func (r *categoryRepository) GetByIDs(ctx context.Context, ids []string) ([]Category, error) {
|
||||
filter := bson.M{"_id": bson.M{"$in": ids}}
|
||||
objectIDs := make([]primitive.ObjectID, len(ids))
|
||||
for i, id := range ids {
|
||||
objectID, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
objectIDs[i] = objectID
|
||||
}
|
||||
|
||||
filter := bson.M{"_id": bson.M{"$in": objectIDs}}
|
||||
|
||||
paginationBuilder := orm.NewPaginationBuilder().
|
||||
Build()
|
||||
|
||||
Reference in New Issue
Block a user