common.go 915 B

123456789101112131415161718192021222324252627282930
  1. package handler
  2. //go:generate mkdir -p mocks
  3. //go:generate rm -rf ./mocks/*_minimock.go
  4. //go:generate minimock -i CacheService,ArticleRepository,TagRepository -o ./mocks/ -s "_minimock.go"
  5. import (
  6. "context"
  7. "time"
  8. "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
  9. )
  10. type (
  11. CacheService interface {
  12. Get(key string) (interface{}, bool)
  13. Set(key string, value interface{}, expiration *time.Duration)
  14. }
  15. ArticleRepository interface {
  16. GetByURL(ctx context.Context, url string) (*models.Article, error)
  17. GetAllPreview(ctx context.Context, lang models.LanguageID) ([]models.ArticlePreview, error)
  18. GetPreviewByTagID(ctx context.Context, tagID uint64, lang models.LanguageID) ([]models.ArticlePreview, error)
  19. }
  20. TagRepository interface {
  21. GetAllUsed(ctx context.Context, lang models.LanguageID) ([]models.Tag, error)
  22. GetByURL(ctx context.Context, tag string) (*models.Tag, error)
  23. }
  24. )