github.com/soulteary/pocket-bookcase@v0.0.0-20240428065142-0b5a9a0fc98a/internal/model/domains.go (about)

     1  package model
     2  
     3  import (
     4  	"context"
     5  	"io/fs"
     6  	"os"
     7  	"time"
     8  
     9  	"github.com/go-shiori/warc"
    10  	"github.com/spf13/afero"
    11  )
    12  
    13  type BookmarksDomain interface {
    14  	HasEbook(b *BookmarkDTO) bool
    15  	HasArchive(b *BookmarkDTO) bool
    16  	HasThumbnail(b *BookmarkDTO) bool
    17  	GetBookmark(ctx context.Context, id DBID) (*BookmarkDTO, error)
    18  }
    19  
    20  type AccountsDomain interface {
    21  	CheckToken(ctx context.Context, userJWT string) (*Account, error)
    22  	GetAccountFromCredentials(ctx context.Context, username, password string) (*Account, error)
    23  	CreateTokenForAccount(account *Account, expiration time.Time) (string, error)
    24  }
    25  
    26  type ArchiverDomain interface {
    27  	DownloadBookmarkArchive(book BookmarkDTO) (*BookmarkDTO, error)
    28  	GetBookmarkArchive(book *BookmarkDTO) (*warc.Archive, error)
    29  }
    30  
    31  type StorageDomain interface {
    32  	Stat(name string) (fs.FileInfo, error)
    33  	FS() afero.Fs
    34  	FileExists(path string) bool
    35  	DirExists(path string) bool
    36  	WriteData(dst string, data []byte) error
    37  	WriteFile(dst string, src *os.File) error
    38  }