domain

package
v0.0.0-...-704a905 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLoginOrPassword = errors.New("invalid login or password")
	ErrUserAlreadyExist       = errors.New("user already exist")
	ErrUserDoesNotExist       = errors.New("user does not exist")

	ErrInsert             = errors.New("insertion error")
	ErrDatabaseUnexpected = errors.New("database unexpected error")

	ErrWhileSetNewSession       = errors.New("error while set new session")
	ErrWhileChangeSession       = errors.New("error while change session")
	ErrSessionStorageUnexpected = errors.New("session storage unexpected error")
	ErrSessionDoesNotExist      = errors.New("session does not exist")

	ErrGetSession    = errors.New("error while get session")
	ErrSetSession    = errors.New("error while set session")
	ErrDeleteSession = errors.New("error while delete session")
)

Functions

This section is empty.

Types

type AlbumAgent

type AlbumAgent interface {
	GetAll() ([]*albumProto.Album, error)
	GetAllCovers() ([]*albumProto.AlbumCover, error)
	GetLastId() (int64, error)
	GetLastCoverId() (int64, error)
	Create(*albumProto.Album) error
	CreateCover(*albumProto.AlbumCover) error
	Update(*albumProto.Album) error
	UpdateCover(*albumProto.AlbumCover) error
	Delete(int64) error
	DeleteCover(int64) error
	GetById(int64) (*albumProto.Album, error)
	GetCoverById(int64) (*albumProto.AlbumCover, error)
	GetPopular() ([]*albumProto.Album, error)
	GetAlbumsFromArtist(int64) ([]*albumProto.Album, error)
	GetSize() (int64, error)
	SearchByTitle(title string) ([]*albumProto.Album, error)
	GetFavorites(userId int64) ([]*albumProto.Album, error)
	AddToFavorites(userId int64, albumId int64) error
	RemoveFromFavorites(userId int64, albumId int64) error
	Like(userId int64, albumId int64) error
	LikeCheckByUser(userId int64, albumId int64) (bool, error)
	GetPopularAlbumOfWeekTop20() ([]*albumProto.Album, error)
}

type AlbumCoverRepo

type AlbumCoverRepo interface {
	Create(*albumProto.AlbumCover) error
	Update(*albumProto.AlbumCover) error
	Delete(int64) error
	SelectByID(int64) (*albumProto.AlbumCover, error)
	GetAll() ([]*albumProto.AlbumCover, error)
	GetLastId() (id int64, err error)
	GetSize() (int64, error)
}

type AlbumRepo

type AlbumRepo interface {
	Create(*albumProto.Album) error
	Update(*albumProto.Album) error
	Delete(int64) error
	SelectByID(int64) (*albumProto.Album, error)
	GetAll() ([]*albumProto.Album, error)
	GetPopular() ([]*albumProto.Album, error)
	GetLastId() (id int64, err error)
	GetSize() (int64, error)
	GetAlbumsFromArtist(artist int64) ([]*albumProto.Album, error)
	SearchByTitle(title string) ([]*albumProto.Album, error)
	Like(id int64, userId int64) error
	LikeCheckByUser(id int64, userId int64) (bool, error)
	Listen(id int64) error
	GetFavorites(userId int64) ([]*albumProto.Album, error)
	AddToFavorites(id int64, userId int64) error
	RemoveFromFavorites(albumId int64, userId int64) error
	GetPopularAlbumOfWeekTop20() ([]*albumProto.Album, error)
	CountPopularAlbumOfWeek() (bool, error)
}

type ArtistAgent

type ArtistAgent interface {
	GetAll() ([]*artistProto.Artist, error)
	GetLastId() (int64, error)
	Create(*artistProto.Artist) error
	Update(*artistProto.Artist) error
	Delete(int64) error
	GetById(int64) (*artistProto.Artist, error)
	GetPopular() ([]*artistProto.Artist, error)
	GetSize() (int64, error)
	SearchByName(name string) ([]*artistProto.Artist, error)
	GetFavorites(int64) ([]*artistProto.Artist, error)
	AddToFavorites(userId int64, artistId int64) error
	RemoveFromFavorites(userId int64, artistId int64) error
	Like(userId int64, artistId int64) error
	LikeCheckByUser(userId int64, artistId int64) (bool, error)
}

type ArtistRepo

type ArtistRepo interface {
	Create(*artistProto.Artist) error
	Update(*artistProto.Artist) error
	Delete(int64) error
	SelectByID(int64) (*artistProto.Artist, error)
	GetAll() ([]*artistProto.Artist, error)
	GetPopular() ([]*artistProto.Artist, error)
	GetLastId() (id int64, err error)
	GetSize() (int64, error)
	SearchByName(string) ([]*artistProto.Artist, error)
	Like(id int64, userId int64) error
	LikeCheckByUser(id int64, userId int64) (bool, error)
	Listen(id int64) error
	GetFavorites(userId int64) ([]*artistProto.Artist, error)
	AddToFavorites(id int64, userId int64) error
	RemoveFromFavorites(artistId int64, userId int64) error
}

type AuthUseCase

type AuthUseCase interface {
	Login(login string, password string, sessionId string) error
	Logout(sessionId string) error
	SignUp(user *User, sessionId string) error
	GetUnauthorizedSession() (sessionId string, err error)
	IsSession(sessionId string) bool
	IsAuthSession(sessionId string) bool
}

type GlobalStorageInterface

type GlobalStorageInterface interface {
	GetAlbumRepo() AlbumRepo
	GetAlbumCoverRepo() AlbumCoverRepo
	GetArtistRepo() ArtistRepo
	GetTrackRepo() TrackRepo
	GetSessionRepo() auth_domain.AuthRepo
	GetUserRepo() user_microservice_domain.UserRepo
	GetPlaylistRepo() PlaylistRepo
}

type LinkerAgent

type LinkerAgent interface {
	Get(hash string) (string, error)
	Create(url string) (string, error)
	Count(hash string) (int64, error)
}

type LinkerRepo

type LinkerRepo interface {
	Get(hash string) (string, error)
	Create(url string) (string, error)
	Count(hash string) (int64, error)
}

type PlaylistAgent

type PlaylistAgent interface {
	GetAll() ([]*playlistProto.Playlist, error)
	GetAllOfCurrentUser(userId int64) ([]*playlistProto.Playlist, error)
	GetLastId() (int64, error)
	GetLastIdOfCurrentUser(userId int64) (int64, error)
	Create(userId int64, playlist *playlistProto.Playlist) error
	Update(userId int64, playlist *playlistProto.Playlist) error
	Delete(userId int64, playlistId int64) error
	GetById(playlistId int64) (*playlistProto.Playlist, error)
	GetByIdOfCurrentUser(userId int64, playlistId int64) (*playlistProto.Playlist, error)
	GetSizeOfCurrentUser(userId int64) (int64, error)
	GetSize() (int64, error)
	AddToPlaylist(userId int64, playlistId int64, trackId int64) error
	RemoveFromPlaylist(userId int64, playlistId int64, trackId int64) error
}

type PlaylistRepo

type PlaylistRepo interface {
	Create(userId int64, playlist *playlistProto.Playlist) error
	Update(userId int64, playlist *playlistProto.Playlist) error
	Delete(userId int64, playlistId int64) error
	SelectByIDOfCurrentUser(userId int64, playlistId int64) (*playlistProto.Playlist, error)
	SelectById(playlistId int64) (*playlistProto.Playlist, error)
	GetAllOfCurrentUser(userId int64) ([]*playlistProto.Playlist, error)
	GetAll() ([]*playlistProto.Playlist, error)
	GetLastIdOfCurrentUser(userId int64) (id int64, err error)
	GetLastId() (id int64, err error)
	GetSizeOfCurrentUser(userId int64) (int64, error)
	GetSize() (int64, error)
	AddToPlaylist(userId int64, playlistId int64, trackId int64) error
	RemoveFromPlaylist(userId int64, playlistId int64, trackId int64) error
}

type Session

type Session struct {
	UserId       uint `json:"user_id"`
	IsAuthorized bool `json:"is_authorized"`
}

type SessionRepo

type SessionRepo interface {
	GetSession(sessionId string) (*Session, error)
	SetNewUnauthorizedSession(expires time.Duration) (sessionId string, err error)
	MakeSessionAuthorized(sessionId string, userId uint) error
	MakeSessionUnauthorized(sessionId string) error
	DeleteSession(sessionId string) error
	GetSize() (int, error)
}

type TrackAgent

type TrackAgent interface {
	GetAll() ([]*trackProto.Track, error)
	GetLastId() (int64, error)
	Create(*trackProto.Track) error
	Update(*trackProto.Track) error
	Delete(int64) error
	GetById(int64) (*trackProto.Track, error)
	GetPopular() ([]*trackProto.Track, error)
	GetTracksFromAlbum(int64) ([]*trackProto.Track, error)
	GetPopularTracksFromArtist(int64) ([]*trackProto.Track, error)
	GetSize() (int64, error)
	Like(userId int64, trackId int64) error
	LikeCheckByUser(userId int64, trackId int64) (bool, error)
	Listen(int64) error
	SearchByTitle(title string) ([]*trackProto.Track, error)
	GetFavorites(int64) ([]*trackProto.Track, error)
	AddToFavorites(userId int64, trackId int64) error
	RemoveFromFavorites(userId int64, artistId int64) error
	GetTracksFromPlaylist(playlistId int64) ([]*trackProto.Track, error)
	GetPopularTrackOfWeekTop20() ([]*trackProto.Track, error)
}

type TrackRepo

type TrackRepo interface {
	Create(*trackProto.Track) error
	Update(*trackProto.Track) error
	Delete(int64) error
	SelectByID(int64) (*trackProto.Track, error)
	GetAll() ([]*trackProto.Track, error)
	GetPopular() ([]*trackProto.Track, error)
	GetLastId() (id int64, err error)
	GetSize() (int64, error)
	GetTracksFromAlbum(albumId int64) ([]*trackProto.Track, error)
	GetTracksFromPlaylist(playlistId int64) ([]*trackProto.Track, error)
	GetPopularTracksFromArtist(artistId int64) ([]*trackProto.Track, error)
	Like(id int64, userId int64) error
	LikeCheckByUser(id int64, userId int64) (bool, error)
	Listen(id int64) error
	SearchByTitle(title string) ([]*trackProto.Track, error)
	GetFavorites(userId int64) ([]*trackProto.Track, error)
	AddToFavorites(id int64, userId int64) error
	RemoveFromFavorites(trackId int64, userId int64) error
	GetPopularTrackOfWeekTop20() ([]*trackProto.Track, error)
	CountPopularTrackOfWeek() (bool, error)
}

type User

type User struct {
	ID             uint   `json:"id,omitempty" db:"id"`
	Username       string `json:"username,omitempty" db:"username"`
	Email          string `json:"email,omitempty" db:"email"`
	Avatar         string `json:"avatar,omitempty" db:"avatar"`
	Password       string `json:"password,omitempty" db:"password_hash"`
	CountFollowing int    `json:"count_following,omitempty" db:"count_following"`
}

type UserRepo

type UserRepo interface {
	Insert(user *User) error
	Update(id uint, user *User) error
	Delete(id uint) error
	SelectByID(id uint) (*User, error)
	SelectByUsername(username string) (*User, error)
	SelectByEmail(email string) (*User, error)
	GetSize() (int, error)
}

type UserUseCase

type UserUseCase interface {
	GetById(userId uint) (*User, error)
	GetByUsername(username string) (*User, error)
	GetByEmail(email string) (*User, error)
	GetBySessionId(sessionId string) (*User, error)
	Update(id uint, user *User) error
	DeleteById(userId uint) error
	DeleteByUsername(username string) error
	DeleteByEmail(email string) error
	DeleteBySessionId(sessionId string) error
	CheckUsernameAndPassword(username string, password string) bool
	CheckEmailAndPassword(email string, password string) bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL