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
+79 -348
View File
@@ -1460,6 +1460,70 @@ const docTemplate = `{
}
}
},
"/admin/v1/customers/{id}/companies": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Assign companies to a customer",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Customers"
],
"summary": "Assign companies to a customer",
"parameters": [
{
"type": "string",
"description": "Customer ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Companies to assign",
"name": "companies",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/customer.AssignCompaniesForm"
}
}
],
"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"
}
}
}
}
},
"/admin/v1/customers/{id}/role": {
"patch": {
"security": [
@@ -2387,112 +2451,6 @@ const docTemplate = `{
}
},
"/admin/v1/notifications": {
"get": {
"description": "Retrieve notifications for a specific user with filtering and pagination",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get user notifications",
"parameters": [
{
"type": "string",
"description": "Recipient",
"name": "recipient",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Notification type (info, warning, alert, reject)",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Notification priority (low, medium, important)",
"name": "priority",
"in": "query"
},
{
"type": "string",
"description": "Delivery status (pending, sent, failed)",
"name": "status",
"in": "query"
},
{
"type": "boolean",
"description": "Read status",
"name": "is_read",
"in": "query"
},
{
"type": "integer",
"default": 1,
"description": "Page number",
"name": "page",
"in": "query"
},
{
"type": "integer",
"default": 20,
"description": "Items per page",
"name": "limit",
"in": "query"
},
{
"type": "string",
"default": "created_at",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"default": "desc",
"description": "Sort order (asc, desc)",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/notification.NotificationsResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
},
"post": {
"description": "Create a new notification with the provided information",
"consumes": [
@@ -2538,173 +2496,6 @@ const docTemplate = `{
}
}
},
"/admin/v1/notifications/{id}": {
"get": {
"description": "Retrieve a specific notification by its ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notification by ID",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationResponse"
}
}
}
]
}
},
"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"
}
}
}
},
"put": {
"description": "Update an existing notification",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Update notification",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Updated notification information",
"name": "notification",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_notification.NotificationRequest"
}
}
],
"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"
}
}
}
},
"delete": {
"description": "Delete a specific notification",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Delete notification",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/admin/v1/profile": {
"get": {
"security": [
@@ -6898,6 +6689,17 @@ const docTemplate = `{
}
}
},
"customer.AssignCompaniesForm": {
"type": "object",
"properties": {
"companies": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"customer.AssignRoleForm": {
"type": "object",
"properties": {
@@ -6951,7 +6753,7 @@ const docTemplate = `{
"customer.CreateCustomerForm": {
"type": "object",
"properties": {
"company_ids": {
"companies": {
"type": "array",
"items": {
"type": "string"
@@ -7007,12 +6809,6 @@ const docTemplate = `{
"$ref": "#/definitions/customer.CompanySummary"
}
},
"company_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"created_at": {
"type": "integer"
},
@@ -7124,7 +6920,7 @@ const docTemplate = `{
"customer.UpdateCustomerForm": {
"type": "object",
"properties": {
"company_ids": {
"companies": {
"type": "array",
"items": {
"type": "string"
@@ -7433,46 +7229,8 @@ const docTemplate = `{
"type": "string"
}
},
"schedule": {
"$ref": "#/definitions/notification.ScheduleRequest"
},
"target": {
"$ref": "#/definitions/notification.TargetAudienceType"
},
"tender": {
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"$ref": "#/definitions/notification.NotificationType"
}
}
},
"internal_notification.NotificationResponse": {
"type": "object",
"properties": {
"channels": {
"type": "array",
"items": {
"$ref": "#/definitions/notification.DeliveryChannel"
}
},
"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"
@@ -7527,33 +7285,6 @@ const docTemplate = `{
"NotificationTypeReject"
]
},
"notification.NotificationsResponse": {
"type": "object",
"properties": {
"notifications": {
"type": "array",
"items": {
"$ref": "#/definitions/internal_notification.NotificationResponse"
}
}
}
},
"notification.ScheduleRequest": {
"type": "object",
"properties": {
"time": {
"type": "integer"
}
}
},
"notification.ScheduleResponse": {
"type": "object",
"properties": {
"time": {
"type": "integer"
}
}
},
"notification.TargetAudienceType": {
"type": "string",
"enum": [