Add Company Category Management Functionality and Update API Documentation

- Introduced a new company category management feature, including CRUD operations for categories in both admin and public API endpoints.
- Implemented category entity, service, repository, and handler layers following clean architecture principles.
- Added new API routes for searching, retrieving, updating, deleting, and toggling publish status of categories, enhancing the overall functionality of the system.
- Updated Swagger and YAML documentation to include detailed descriptions and examples for the new category endpoints, ensuring clarity for API consumers.
- Enhanced error handling for duplicate categories and validation, improving the robustness of the category management process.
- Updated existing routes to integrate category handling, ensuring a seamless user experience across the application.
This commit is contained in:
n.nakhostin
2025-09-08 12:31:49 +03:30
parent 617547def8
commit 991771ee19
10 changed files with 2156 additions and 7 deletions
+321
View File
@@ -263,6 +263,44 @@ definitions:
is_verified:
type: boolean
type: object
company_category.CategoryForm:
properties:
description:
example: Technology related companies
type: string
name:
example: Technology
type: string
thumbnail:
example: https://example.com/thumbnail.jpg
type: string
type: object
company_category.CategoryListResponse:
properties:
categories:
items:
$ref: '#/definitions/company_category.CategoryResponse'
type: array
type: object
company_category.CategoryResponse:
properties:
created_at:
type: integer
description:
type: string
id:
type: string
name:
type: string
published:
type: boolean
published_at:
type: integer
thumbnail:
type: string
updated_at:
type: integer
type: object
customer.AuthResponse:
properties:
access_token:
@@ -1545,6 +1583,285 @@ paths:
summary: Update company verification status
tags:
- Admin-Companies
/admin/v1/company-categories:
get:
consumes:
- application/json
description: Search categories with filtering capabilities
parameters:
- description: Search query
in: query
name: q
type: string
- description: Published status filter
in: query
name: published
type: boolean
- default: 20
description: Limit
in: query
name: limit
type: integer
- default: 0
description: Offset
in: query
name: offset
type: integer
- description: Sort by field
enum:
- name
- created_at
- updated_at
- published_at
in: query
name: sort_by
type: string
- description: Sort order
enum:
- asc
- desc
in: query
name: sort_order
type: string
produces:
- application/json
responses:
"200":
description: Categories search completed
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/company_category.CategoryListResponse'
type: object
"400":
description: Bad request - Invalid query parameters
schema:
$ref: '#/definitions/response.APIResponse'
"422":
description: Validation error - Invalid query parameters
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Search categories
tags:
- Admin-Company-Categories
post:
consumes:
- application/json
description: Create a new category with name, description, and thumbnail
parameters:
- description: Category information
in: body
name: category
required: true
schema:
$ref: '#/definitions/company_category.CategoryForm'
produces:
- application/json
responses:
"201":
description: Category created successfully
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/company_category.CategoryResponse'
type: object
"400":
description: Bad request - Invalid input data
schema:
$ref: '#/definitions/response.APIResponse'
"409":
description: Conflict - Category with this name already exists
schema:
$ref: '#/definitions/response.APIResponse'
"422":
description: Validation error - Invalid request data
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Create a new category
tags:
- Admin-Company-Categories
/admin/v1/company-categories/{id}:
delete:
consumes:
- application/json
description: Delete a category permanently
parameters:
- description: Category ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Category deleted successfully
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad request - Invalid category ID
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not found - Category not found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Delete category
tags:
- Admin-Company-Categories
get:
consumes:
- application/json
description: Retrieve detailed category information by category ID
parameters:
- description: Category ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Category retrieved successfully
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/company_category.CategoryResponse'
type: object
"400":
description: Bad request - Invalid category ID
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not found - Category not found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get category by ID
tags:
- Admin-Company-Categories
put:
consumes:
- application/json
description: Update category information including name, description, and thumbnail
parameters:
- description: Category ID
in: path
name: id
required: true
type: string
- description: Category update information
in: body
name: category
required: true
schema:
$ref: '#/definitions/company_category.CategoryForm'
produces:
- application/json
responses:
"200":
description: Category updated successfully
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/company_category.CategoryResponse'
type: object
"400":
description: Bad request - Invalid input data
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not found - Category not found
schema:
$ref: '#/definitions/response.APIResponse'
"409":
description: Conflict - Category with this name already exists
schema:
$ref: '#/definitions/response.APIResponse'
"422":
description: Validation error - Invalid request data
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Update category information
tags:
- Admin-Company-Categories
/admin/v1/company-categories/{id}/publish:
patch:
consumes:
- application/json
description: Toggle category publish/unpublish status
parameters:
- description: Category ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Category publish status updated successfully
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad request - Invalid input data
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not found - Category not found
schema:
$ref: '#/definitions/response.APIResponse'
"422":
description: Validation error - Invalid request data
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Toggle category publish status
tags:
- Admin-Company-Categories
/admin/v1/customers:
get:
consumes:
@@ -4185,6 +4502,10 @@ tags:
CRUD operations, tag management, verification, status updates, comprehensive search
and filtering, and statistical reporting
name: Admin-Companies
- description: Administrative company category management operations for web panel
including CRUD operations, publish/unpublish status, and comprehensive filtering
with pagination
name: Admin-Company-Categories
- description: Administrative tender management operations for web panel including
CRUD operations, search, statistics, and comprehensive filtering with pagination
name: Admin-Tenders