github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/systemssync/converter.go (about) 1 package systemssync 2 3 import ( 4 "github.com/kyma-incubator/compass/components/director/internal/model" 5 ) 6 7 type converter struct{} 8 9 // NewConverter returns a new Converter used for conversion between repository and service representation of system sync model 10 func NewConverter() *converter { 11 return &converter{} 12 } 13 14 // ToEntity converts the service model to repository entity 15 func (c *converter) ToEntity(in *model.SystemSynchronizationTimestamp) *Entity { 16 if in == nil { 17 return nil 18 } 19 20 return &Entity{ 21 ID: in.ID, 22 TenantID: in.TenantID, 23 ProductID: in.ProductID, 24 LastSyncTimestamp: in.LastSyncTimestamp, 25 } 26 } 27 28 // FromEntity converts the repository entity to service model 29 func (c *converter) FromEntity(entity *Entity) *model.SystemSynchronizationTimestamp { 30 if entity == nil { 31 return nil 32 } 33 34 return &model.SystemSynchronizationTimestamp{ 35 ID: entity.ID, 36 TenantID: entity.TenantID, 37 ProductID: entity.ProductID, 38 LastSyncTimestamp: entity.LastSyncTimestamp, 39 } 40 }