forked from raystack/siren
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscription_receiver.go
46 lines (40 loc) · 1.27 KB
/
subscription_receiver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package model
import (
"database/sql"
"time"
"github.com/goto/siren/core/subscriptionreceiver"
"github.com/goto/siren/pkg/pgc"
)
type SubscriptionReceiverRelation struct {
ID uint64 `db:"id"`
SubscriptionID uint64 `db:"subscription_id"`
ReceiverID uint64 `db:"receiver_id"`
Labels pgc.StringStringMap `db:"labels"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DeletedAt sql.NullTime `db:"deleted_at"`
}
func (s *SubscriptionReceiverRelation) FromDomain(rel subscriptionreceiver.Relation) {
s.ID = rel.ID
s.SubscriptionID = rel.SubscriptionID
s.ReceiverID = rel.ReceiverID
s.Labels = rel.Labels
s.CreatedAt = rel.CreatedAt
s.UpdatedAt = rel.UpdatedAt
if rel.DeletedAt.IsZero() {
s.DeletedAt = sql.NullTime{Valid: false}
} else {
s.DeletedAt = sql.NullTime{Time: rel.DeletedAt, Valid: true}
}
}
func (s *SubscriptionReceiverRelation) ToDomain() *subscriptionreceiver.Relation {
return &subscriptionreceiver.Relation{
ID: s.ID,
SubscriptionID: s.SubscriptionID,
ReceiverID: s.ReceiverID,
Labels: s.Labels,
CreatedAt: s.CreatedAt,
UpdatedAt: s.UpdatedAt,
DeletedAt: s.DeletedAt.Time,
}
}