service

package
v0.0.0-...-71e9963 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelsNotFound         = errors.New("channels not found")
	ErrChannelNotFound          = errors.New("channel not found")
	ErrChannelExists            = errors.New("channel is exist")
	ErrChannelStatisticNotFound = errors.New("channel statistic not found")
)
View Source
var (
	ErrMessagesCountNotFound = errors.New("message count not found")
	ErrMessagesNotFound      = errors.New("messages not found")
	ErrMessageNotFound       = errors.New("messages not found")
	ErrMessageExists         = errors.New("message is exist")
)
View Source
var (
	ErrSavedMessagesNotFound = errors.New("saved messages not found")
	ErrSavedMessageNotFound  = errors.New("saved message not found")
)
View Source
var (
	ErrIncorrectPassword = errors.New("incorrect password")
	ErrWebUserIsExist    = errors.New("web user is exist")
)
View Source
var ErrRepliesNotFound = errors.New("replies not found")
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var ErrWebUserNotFound = errors.New("web user not found")

Functions

func NewAuthService

func NewAuthService(webUserService WebUserService, logger *logger.Logger) *authService

func NewChannelService

func NewChannelService(store *store.Store, logger *logger.Logger, messageService MessageService) *channelService

func NewMessageService

func NewMessageService(store *store.Store, logger *logger.Logger, replyService ReplyService) *messageService

func NewReplyService

func NewReplyService(store *store.Store, logger *logger.Logger) *replyService

func NewSavedService

func NewSavedService(store *store.Store, logger *logger.Logger, messageService MessageService) *savedService

func NewUserService

func NewUserService(store *store.Store, logger *logger.Logger, message MessageService) *userService

func NewWebUserService

func NewWebUserService(store *store.Store, logger *logger.Logger) *webUserService

Types

type AuthService

type AuthService interface {
	Login(email string, userPassword string) (string, error)
	Register(user *model.WebUser) error
}

type ChannelService

type ChannelService interface {
	CreateChannel(channel *model.DBChannel) error
	GetChannels() ([]model.Channel, error)
	GetChannelsByPage(page int) ([]model.Channel, error)
	GetChannelByName(name string) (*model.Channel, error)
	GetChannelStats(channelID int) (*model.Stat, error)
	ProcessChannelPage(channelName string, page int) (*LoadChannelOutput, error)
	ProcessChannelsPage(page int) (*LoadChannelsOutput, error)
}

type LoadChannelOutput

type LoadChannelOutput struct {
	Channel       model.Channel
	Messages      []model.FullMessage
	MessagesCount int
}

type LoadChannelsOutput

type LoadChannelsOutput struct {
	Channels []model.Channel
}

type LoadHomeOutput

type LoadHomeOutput struct {
	Messages      []model.FullMessage
	MessagesCount int
}

type LoadMessageOutput

type LoadMessageOutput struct {
	Message *model.FullMessage
}

type LoadSavedMessagesOutput

type LoadSavedMessagesOutput struct {
	SavedMessages      []model.FullMessage
	SavedMessagesCount int
}

type LoadUserOutput

type LoadUserOutput struct {
	TgUser        *model.User
	Messages      []model.FullMessage
	MessagesCount int
}

type Manager

type Manager struct {
	Channel ChannelService
	Message MessageService
	Reply   ReplyService
	User    UserService
	WebUser WebUserService
	Saved   SavedService
	Auth    AuthService
}

func NewManager

func NewManager(store *store.Store, logger *logger.Logger) (*Manager, error)

type MessageService

type MessageService interface {
	CreateMessage(message *model.DBMessage) (int, error)
	GetMessagesCount() (int, error)
	GetMessagesCountByChannelID(ID int) (int, error)
	GetFullMessagesByChannelIDAndPage(ID, page int) ([]model.FullMessage, error)
	GetFullMessagesByUserID(ID int) ([]model.FullMessage, error)
	GetFullMessageByMessageID(id int) (*model.FullMessage, error)
	ProcessMessagePage(messageID int) (*LoadMessageOutput, error)
	ProcessHomePage(page int) (*LoadHomeOutput, error)
}

type ReplyService

type ReplyService interface {
	CreateReply(reply *model.DBReply) error
	GetFullRepliesByMessageID(ID int) ([]model.FullReply, error)
}

type SavedService

type SavedService interface {
	GetSavedMessageByMessageID(id int) (*model.Saved, error)
	CreateSavedMessage(saved *model.Saved) error
	DeleteSavedMessage(ID int) error
	ProcessSavedMessages(userID int) (*LoadSavedMessagesOutput, error)
}

type UserService

type UserService interface {
	CreateUser(user *model.User) (int, error)
	ProcessUserPage(userID int) (*LoadUserOutput, error)
}

type WebUserService

type WebUserService interface {
	GetWebUserByEmail(email string) (*model.WebUser, error)
	CreateWebUser(user *model.WebUser) error
}

Jump to

Keyboard shortcuts

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