notification
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package transformer
|
||||
|
||||
import (
|
||||
"apskel-pos-be/internal/contract"
|
||||
"apskel-pos-be/internal/models"
|
||||
)
|
||||
|
||||
func NotificationModelResponseToContract(m *models.NotificationResponse) *contract.NotificationResponse {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
return &contract.NotificationResponse{
|
||||
ID: m.ID,
|
||||
Title: m.Title,
|
||||
Body: m.Body,
|
||||
Type: m.Type,
|
||||
Category: m.Category,
|
||||
Priority: m.Priority,
|
||||
ImageURL: m.ImageURL,
|
||||
ActionURL: m.ActionURL,
|
||||
NotifiableType: m.NotifiableType,
|
||||
NotifiableID: m.NotifiableID,
|
||||
Data: m.Data,
|
||||
ScheduledAt: m.ScheduledAt,
|
||||
SentAt: m.SentAt,
|
||||
ExpiredAt: m.ExpiredAt,
|
||||
CreatedBy: m.CreatedBy,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NotificationReceiverModelResponseToContract(m *models.NotificationReceiverResponse) *contract.NotificationReceiverResponse {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
resp := &contract.NotificationReceiverResponse{
|
||||
ID: m.ID,
|
||||
NotificationID: m.NotificationID,
|
||||
UserID: m.UserID,
|
||||
IsRead: m.IsRead,
|
||||
ReadAt: m.ReadAt,
|
||||
IsDeleted: m.IsDeleted,
|
||||
DeletedAt: m.DeletedAt,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
if m.Notification != nil {
|
||||
resp.Notification = NotificationModelResponseToContract(m.Notification)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
func NotificationReceiverModelResponsesToContracts(ms []*models.NotificationReceiverResponse) []*contract.NotificationReceiverResponse {
|
||||
if ms == nil {
|
||||
return nil
|
||||
}
|
||||
result := make([]*contract.NotificationReceiverResponse, len(ms))
|
||||
for i, m := range ms {
|
||||
result[i] = NotificationReceiverModelResponseToContract(m)
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user