Enhance Notification and User Services with Improved Error Handling and Data Consistency

- Updated GetByID methods in user and customer services to return specific "not found" errors for better clarity in error responses.
- Modified NotificationResponse structure to include a new Recipient field, allowing for more flexible recipient handling.
- Changed CreatedAt and UpdatedAt fields in NotificationResponse to use Unix timestamps (int64) for consistency across the application.
- Improved notification retrieval logic to handle potential nil values for user and customer lookups, ensuring robust data handling.
This commit is contained in:
n.nakhostin
2025-09-27 11:40:17 +03:30
parent 7110e55cf5
commit ac7eb0385d
4 changed files with 57 additions and 13 deletions
+3 -3
View File
@@ -1,7 +1,6 @@
package notification
import (
"time"
"tm/pkg/response"
)
@@ -38,6 +37,7 @@ type NotificationListResponse struct {
type NotificationResponse struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Recipient any `json:"recipient"`
Title string `json:"title"`
Message string `json:"message"`
Link *string `json:"link"`
@@ -49,8 +49,8 @@ type NotificationResponse struct {
Methods map[string]string `json:"methods"`
Metadata map[string]any `json:"metadata"`
ScheduleAt int64 `json:"schedule_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Seen bool `json:"seen"`
SeenAt int64 `json:"seen_at"`
IsScheduled bool `json:"is_scheduled"`