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:
@@ -168,6 +168,9 @@ func (s *customerService) Register(ctx context.Context, form *CreateCustomerForm
|
||||
func (s *customerService) GetByID(ctx context.Context, id string) (*CustomerResponse, error) {
|
||||
customer, err := s.repository.GetByID(ctx, id)
|
||||
if err != nil {
|
||||
if err.Error() == "customer not found" {
|
||||
return nil, errors.New("customer not found")
|
||||
}
|
||||
s.logger.Error("Failed to get customer by ID", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"customer_id": id,
|
||||
|
||||
Reference in New Issue
Block a user