Add Contact Management Functionality

- Introduced a new contact management feature, including the ability to create, retrieve, search, update, and delete contact messages.
- Implemented the Contact entity, repository, service, and handler layers following Clean Architecture principles.
- Added API endpoints for contact operations in Swagger documentation, ensuring comprehensive API specifications.
- Enhanced error handling and validation for contact data, improving robustness and user experience.
- Updated the main application to initialize the contact repository and service, integrating them into the existing system.
This commit is contained in:
n.nakhostin
2025-10-25 18:15:39 +03:30
parent 889a56a9f9
commit 875447ac58
11 changed files with 2151 additions and 10 deletions
+319
View File
@@ -302,6 +302,75 @@ definitions:
updated_at:
type: integer
type: object
contact.ContactListResponse:
properties:
contacts:
items:
$ref: '#/definitions/contact.ContactResponse'
type: array
type: object
contact.ContactResponse:
properties:
admin_notes:
type: string
created_at:
type: integer
email:
type: string
full_name:
type: string
id:
type: string
message:
type: string
phone:
type: string
resolved_at:
type: integer
resolved_by:
type: string
status:
type: string
updated_at:
type: integer
type: object
contact.ContactStats:
properties:
closed:
type: integer
in_progress:
type: integer
pending:
type: integer
resolved:
type: integer
total:
type: integer
type: object
contact.CreateContactForm:
properties:
email:
example: john.doe@example.com
type: string
full_name:
example: John Doe
type: string
message:
example: I have a question about your services
type: string
phone:
example: "+1234567890"
type: string
type: object
contact.UpdateContactStatusForm:
properties:
admin_notes:
example: Customer inquiry handled
type: string
status:
example: in_progress
type: string
type: object
customer.AssignCompaniesForm:
properties:
companies:
@@ -1999,6 +2068,221 @@ paths:
summary: Toggle category publish status
tags:
- Admin-Company-Categories
/admin/v1/contacts:
get:
consumes:
- application/json
description: Search contacts with filters and pagination (admin only)
parameters:
- description: Search query
in: query
name: q
type: string
- description: Contact status
enum:
- pending
- in_progress
- resolved
- closed
in: query
name: status
type: string
- description: Date from (Unix timestamp)
in: query
name: date_from
type: integer
- description: Date to (Unix timestamp)
in: query
name: date_to
type: integer
- default: 20
description: Number of contacts per page (1-100)
in: query
maximum: 100
minimum: 1
name: limit
type: integer
- default: 0
description: Number of contacts to skip for pagination
in: query
minimum: 0
name: offset
type: integer
- default: created_at
description: Field to sort by
enum:
- full_name
- email
- created_at
- updated_at
- status
in: query
name: sort_by
type: string
- default: desc
description: Sort order
enum:
- asc
- desc
in: query
name: sort_order
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/contact.ContactListResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Search contacts
tags:
- contacts
/admin/v1/contacts/{id}:
delete:
consumes:
- application/json
description: Delete a contact message by ID (admin only)
parameters:
- description: Contact ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Delete contact
tags:
- contacts
get:
consumes:
- application/json
description: Retrieve a contact message by its ID (admin only)
parameters:
- description: Contact ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/contact.ContactResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Get contact by ID
tags:
- contacts
/admin/v1/contacts/{id}/status:
put:
consumes:
- application/json
description: Update the status of a contact message (admin only)
parameters:
- description: Contact ID
in: path
name: id
required: true
type: string
- description: Status update information
in: body
name: status
required: true
schema:
$ref: '#/definitions/contact.UpdateContactStatusForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Update contact status
tags:
- contacts
/admin/v1/contacts/stats:
get:
consumes:
- application/json
description: Get contact statistics by status (admin only)
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/contact.ContactStats'
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Get contact statistics
tags:
- contacts
/admin/v1/customers:
get:
consumes:
@@ -4314,6 +4598,41 @@ paths:
summary: Get my company profile
tags:
- Company
/api/v1/contacts:
post:
consumes:
- application/json
description: Create a new contact message from a user
parameters:
- description: Contact information
in: body
name: contact
required: true
schema:
$ref: '#/definitions/contact.CreateContactForm'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/contact.ContactResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Create a new contact message
tags:
- contacts
/api/v1/feedback:
get:
consumes: