123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package admin
- import (
- "context"
- "time"
- "github.com/gofiber/fiber/v2"
- "github.com/golang-jwt/jwt/v4"
- "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
- )
- type (
- CacheService interface {
- Delete(key string)
- }
- TransactionManager interface {
- ReadCommitted(context.Context, func(ctx context.Context) error) error
- }
- ArticleRepository interface {
- GetAll(ctx context.Context) ([]models.Article, error)
- GetByURL(ctx context.Context, url string) (*models.Article, error)
- GetByID(ctx context.Context, id uint64) (*models.Article, error)
- Add(ctx context.Context, m models.Article) (uint64, error)
- Update(ctx context.Context, m models.Article) error
- Delete(ctx context.Context, id uint64) error
- }
- TagRepository interface {
- GetAll(ctx context.Context) ([]models.Tag, error)
- IsUsed(ctx context.Context, id uint64) (bool, error)
- GetByArticleID(ctx context.Context, id uint64) ([]models.Tag, error)
- GetByURL(ctx context.Context, tag string) (*models.Tag, error)
- GetByID(ctx context.Context, id uint64) (*models.Tag, error)
- Add(ctx context.Context, m models.Tag) error
- Update(ctx context.Context, m models.Tag) error
- Delete(ctx context.Context, id uint64) error
- }
- ArticleTagRepository interface {
- Add(ctx context.Context, id uint64, tagIDs []uint64) error
- Delete(ctx context.Context, id uint64, tagIDs []uint64) error
- DeleteByArticleID(ctx context.Context, id uint64) error
- }
- LanguageRepository interface {
- GetAll(ctx context.Context) ([]models.Language, error)
- }
- AuthService interface {
- GeneratePasswordHash(password string) (string, error)
- IsCorrectPassword(password string, hash string) bool
- GenerateToken(user models.User) (string, error)
- GetClaims(fctx *fiber.Ctx) jwt.MapClaims
- }
- ConfigService interface {
- JWTCookie() string
- JWTLifeTime() time.Duration
- }
- UserRepository interface {
- Get(ctx context.Context, username string) (*models.User, error)
- Add(ctx context.Context, username string, password string) (uint64, error)
- UpdatePassword(ctx context.Context, id uint64, newPassword string) error
- }
- )
|