Multiple implementations of the same back-end application. The aim is to provide quick, side-by-side comparisons of different technologies (languages, frameworks, libraries) while preserving consistent business logic across all implementations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
981 B

package specifications
import (
"autostore/internal/domain/entities"
"time"
)
type ItemExpirationSpec struct{}
func NewItemExpirationSpec() *ItemExpirationSpec {
return &ItemExpirationSpec{}
}
// IsExpired checks if an item is expired using the new condition-based specification
func (s *ItemExpirationSpec) IsExpired(item *entities.ItemEntity, currentTime time.Time) bool {
return s.GetSpec(currentTime).IsSatisfiedBy(item)
}
// GetSpec returns a condition-based specification for checking item expiration
func (s *ItemExpirationSpec) GetSpec(currentTime time.Time) Specification[*entities.ItemEntity] {
// Create a condition that checks if expirationDate <= currentTime
spec := Lte("expirationDate", currentTime)
return NewSimpleSpecification[*entities.ItemEntity](spec)
}
// GetConditionSpec returns the raw condition spec for query generation
func (s *ItemExpirationSpec) GetConditionSpec(currentTime time.Time) *Spec {
return Lte("expirationDate", currentTime)
}