Enhance Customer Service with Notification Response Structures

- Introduced CustomerNotificationResponse struct to provide a detailed response format for customer notifications, improving the clarity of notification data.
- Updated the Customer service interface to include methods for searching and retrieving customers with notification-specific responses, enhancing the flexibility of customer data retrieval.
- Modified the Login method to accept a device token, allowing for better tracking of customer devices during login.
- Refactored existing methods to utilize the new notification response structure, ensuring consistency across customer-related API responses.
- Enhanced error handling and logging in the service layer for improved traceability during customer searches and logins.
This commit is contained in:
n.nakhostin
2025-09-22 11:47:31 +03:30
parent 733d726df6
commit ddf4d9abc4
4 changed files with 72 additions and 46 deletions
+24
View File
@@ -80,6 +80,30 @@ func (c *Customer) ToResponse(companies []*CompanySummary) *CustomerResponse {
}
}
type CustomerNotificationResponse struct {
ID string `json:"id"`
FullName *string `json:"full_name"`
Username string `json:"username"`
Email string `json:"email"`
Type string `json:"type"`
Role string `json:"role"`
Phone *string `json:"phone"`
DeviceToken []string `json:"device_token"`
}
func (c *Customer) ToNotificationResponse() *CustomerNotificationResponse {
return &CustomerNotificationResponse{
ID: c.ID.Hex(),
FullName: c.FullName,
Username: c.Username,
Email: c.Email,
Type: string(c.Type),
Role: string(c.Role),
Phone: c.Phone,
DeviceToken: c.DeviceToken,
}
}
// CustomerListResponse represents the response for listing customers
type CustomerListResponse struct {
Customers []*CustomerResponse `json:"customers"`