Refactor Notification Management and Enhance Customer Features

- Updated the notification handling logic to utilize a new SDK for sending notifications, improving the flexibility and scalability of the notification system.
- Introduced new methods in the notification service for sending notifications to users and customers based on various target audience types, enhancing the notification delivery capabilities.
- Added a new endpoint to assign companies to a customer, improving customer management functionalities.
- Refactored the customer entity and forms to replace 'CompanyIDs' with 'Companies', ensuring consistency across the data model.
- Enhanced API documentation with Swagger comments for the new endpoint and updated notification structures, ensuring clarity for API consumers.
This commit is contained in:
n.nakhostin
2025-09-20 16:54:51 +03:30
parent d2f7c6a1e5
commit 9037cb5917
18 changed files with 607 additions and 1471 deletions
+52 -227
View File
@@ -303,6 +303,13 @@ definitions:
updated_at:
type: integer
type: object
customer.AssignCompaniesForm:
properties:
companies:
items:
type: string
type: array
type: object
customer.AssignRoleForm:
properties:
role:
@@ -338,7 +345,7 @@ definitions:
type: object
customer.CreateCustomerForm:
properties:
company_ids:
companies:
items:
type: string
type: array
@@ -377,10 +384,6 @@ definitions:
items:
$ref: '#/definitions/customer.CompanySummary'
type: array
company_ids:
items:
type: string
type: array
created_at:
type: integer
email:
@@ -456,7 +459,7 @@ definitions:
type: object
customer.UpdateCustomerForm:
properties:
company_ids:
companies:
items:
type: string
type: array
@@ -667,33 +670,8 @@ definitions:
items:
type: string
type: array
schedule:
$ref: '#/definitions/notification.ScheduleRequest'
target:
$ref: '#/definitions/notification.TargetAudienceType'
tender:
type: string
title:
type: string
type:
$ref: '#/definitions/notification.NotificationType'
type: object
internal_notification.NotificationResponse:
properties:
channels:
items:
$ref: '#/definitions/notification.DeliveryChannel'
type: array
description:
type: string
id:
type: string
link:
type: string
priority:
$ref: '#/definitions/notification.NotificationPriority'
schedule:
$ref: '#/definitions/notification.ScheduleResponse'
schedule_at:
type: integer
target:
$ref: '#/definitions/notification.TargetAudienceType'
tender:
@@ -733,23 +711,6 @@ definitions:
- NotificationTypeWarning
- NotificationTypeAlert
- NotificationTypeReject
notification.NotificationsResponse:
properties:
notifications:
items:
$ref: '#/definitions/internal_notification.NotificationResponse'
type: array
type: object
notification.ScheduleRequest:
properties:
time:
type: integer
type: object
notification.ScheduleResponse:
properties:
time:
type: integer
type: object
notification.TargetAudienceType:
enum:
- all_users
@@ -2149,6 +2110,47 @@ paths:
summary: Update customer information
tags:
- Admin-Customers
/admin/v1/customers/{id}/companies:
patch:
consumes:
- application/json
description: Assign companies to a customer
parameters:
- description: Customer ID
in: path
name: id
required: true
type: string
- description: Companies to assign
in: body
name: companies
required: true
schema:
$ref: '#/definitions/customer.AssignCompaniesForm'
produces:
- application/json
responses:
"200":
description: Companies assigned successfully
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad request - Invalid input data
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: Assign companies to a customer
tags:
- Admin-Customers
/admin/v1/customers/{id}/role:
patch:
consumes:
@@ -2724,75 +2726,6 @@ paths:
tags:
- Admin-Inquiries
/admin/v1/notifications:
get:
consumes:
- application/json
description: Retrieve notifications for a specific user with filtering and pagination
parameters:
- description: Recipient
in: query
name: recipient
required: true
type: string
- description: Notification type (info, warning, alert, reject)
in: query
name: type
type: string
- description: Notification priority (low, medium, important)
in: query
name: priority
type: string
- description: Delivery status (pending, sent, failed)
in: query
name: status
type: string
- description: Read status
in: query
name: is_read
type: boolean
- default: 1
description: Page number
in: query
name: page
type: integer
- default: 20
description: Items per page
in: query
name: limit
type: integer
- default: created_at
description: Sort field
in: query
name: sort_by
type: string
- default: desc
description: Sort order (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/notification.NotificationsResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: Get user notifications
tags:
- Admin-Notification
post:
consumes:
- application/json
@@ -2822,114 +2755,6 @@ paths:
summary: Create a new notification
tags:
- Admin-Notification
/admin/v1/notifications/{id}:
delete:
consumes:
- application/json
description: Delete a specific notification
parameters:
- description: Notification ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Notification deleted successfully
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 notification
tags:
- Admin-Notification
get:
consumes:
- application/json
description: Retrieve a specific notification by its ID
parameters:
- description: Notification 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/internal_notification.NotificationResponse'
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 notification by ID
tags:
- Admin-Notification
put:
consumes:
- application/json
description: Update an existing notification
parameters:
- description: Notification ID
in: path
name: id
required: true
type: string
- description: Updated notification information
in: body
name: notification
required: true
schema:
$ref: '#/definitions/internal_notification.NotificationRequest'
produces:
- application/json
responses:
"200":
description: Notification updated successfully
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 notification
tags:
- Admin-Notification
/admin/v1/profile:
get:
consumes: