File size: 909 Bytes
fea99b3 | 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 | package entitydiff
import "github.com/samber/lo"
type NestedEntity[T Entity, P Entity] struct {
Entity T
Parent P
}
func (w NestedEntity[T, P]) GetID() string {
return w.Entity.GetID()
}
func (w NestedEntity[T, P]) IsDeleted() bool {
return w.Entity.IsDeleted()
}
type EqualerNestedEntity[T EqualerEntity[T], P Entity] struct {
Entity T
Parent P
}
func (w EqualerNestedEntity[T, P]) GetID() string {
return w.Entity.GetID()
}
func (w EqualerNestedEntity[T, P]) IsDeleted() bool {
return w.Entity.IsDeleted()
}
func (w EqualerNestedEntity[T, P]) Equal(other EqualerNestedEntity[T, P]) bool {
return w.Entity.Equal(other.Entity)
}
func NewEqualersWithParent[T EqualerEntity[T], P Entity](entity []T, parent P) []EqualerNestedEntity[T, P] {
return lo.Map(entity, func(item T, _ int) EqualerNestedEntity[T, P] {
return EqualerNestedEntity[T, P]{
Entity: item,
Parent: parent,
}
})
}
|