services

package
v0.0.0-...-aef9128 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateOTP

func GenerateOTP(maxDigits uint32) string

Types

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

AuthService handles the business logic for authentication

func (*AuthService) DeleteAccount

func (as *AuthService) DeleteAccount(email string, otp string) error

func (*AuthService) ForgotPasswordRequest

func (as *AuthService) ForgotPasswordRequest(email string) error

func (*AuthService) LoginUser

func (as *AuthService) LoginUser(email, password string) (string, models.User, error)

LoginUser handles user login.

func (*AuthService) RegisterUser

func (as *AuthService) RegisterUser(email, name, profileImage, password string) (models.User, error)

func (*AuthService) RequestDeletion

func (as *AuthService) RequestDeletion(user models.User) error

func (*AuthService) RequestVerificationAgain

func (as *AuthService) RequestVerificationAgain(email string) error

RequestVerificationAgain handles resending verification email.

func (*AuthService) ResetPassword

func (as *AuthService) ResetPassword(user models.User, oldPassword string, newPassword string) error

func (*AuthService) SetNewPassword

func (as *AuthService) SetNewPassword(email string, otp string, newPassword string) error

func (*AuthService) VerifyEmail

func (as *AuthService) VerifyEmail(email string, otp string) error

type AuthServiceInterface

type AuthServiceInterface interface {
	RegisterUser(email, name, profileImage, password string) (models.User, error)
	LoginUser(email, password string) (string, models.User, error)
	RequestVerificationAgain(email string) error
	VerifyEmail(email, otp string) error
	ForgotPasswordRequest(email string) error
	SetNewPassword(email string, otp string, newPassword string) error
	ResetPassword(user models.User, oldPassword string, newPassword string) error
	RequestDeletion(user models.User) error
	DeleteAccount(email string, otp string) error
}

type EmailAddress

type EmailAddress struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

type EmailService

type EmailService struct {
}

EmailService handles sending email notifications.

func NewEmailService

func NewEmailService(userRepo repository.UserRepositoryInterface) *EmailService

NewEmailService creates a new EmailService.

func (*EmailService) GenericSendMail

func (es *EmailService) GenericSendMail(subject string, content string, toEmail string, userName string) error

GenericSendMail sends a generic email.

func (EmailService) SendDeletionMail

func (es EmailService) SendDeletionMail(toEmail string, userName string) error

func (*EmailService) SendForgotPasswordMail

func (es *EmailService) SendForgotPasswordMail(toEmail string, userName string) error

func (*EmailService) SendRegistrationMail

func (es *EmailService) SendRegistrationMail(subject string, content string, toEmail string, userName string, newUser bool) error

type EmailServiceInterface

type EmailServiceInterface interface {
	GenericSendMail(subject string, content string, toEmail string, userName string) error
	SendRegistrationMail(subject string, content string, toEmail string, userName string, newUser bool) error
	SendForgotPasswordMail(toEmail string, userName string) error
	SendDeletionMail(toEmail string, userName string) error
}

type GenericEmail

type GenericEmail struct {
	Subject  string         `json:"subject"`
	From     EmailAddress   `json:"from"`
	To       []EmailAddress `json:"to"`
	Category string         `json:"category"`
	Text     string         `json:"text"`
}

type MoodService

type MoodService struct {
	// contains filtered or unexported fields
}

func NewMoodService

func NewMoodService(moodRepo repository.MoodRepositoryInterface) *MoodService

func (*MoodService) CreateMoodEntry

func (ms *MoodService) CreateMoodEntry(moodType models.MoodType, notes string, userID uint, attributes []string) (models.MoodResponse, error)

CreateMoodEntry creates a new mood entry in the database.

func (*MoodService) CreateNewAttribute

func (ms *MoodService) CreateNewAttribute(attribute string, userID uint) error

CreateNewAttribute creates a new attribute in the database which can now be associated with mood entries.

func (*MoodService) DeleteMoodEntry

func (ms *MoodService) DeleteMoodEntry(userID, moodID uint) error

DeleteMoodEntry deletes a single mood entry for a specific user, as well as all associated mood attributes.

func (*MoodService) GetGenericAttributes

func (ms *MoodService) GetGenericAttributes(userID uint) ([]models.Attribute, error)

GetGenericAttributes gets all the generic attributes that can be associated with mood entries.

func (*MoodService) GetSingleUserMoodEntry

func (ms *MoodService) GetSingleUserMoodEntry(userID, moodID uint) (models.MoodResponse, error)

GetSingleUserMoodEntry gets a single mood entry for a specific user.

func (*MoodService) GetUserMoodEntries

func (ms *MoodService) GetUserMoodEntries(userID uint, moodType *models.MoodType, startDate, endDate *string) ([]models.MoodResponse, error)

GetUsersMoodEntries gets all the mood entries for a specific user. Filters by mood type and date range if provided.

func (*MoodService) UpdateUserMoodEntry

func (ms *MoodService) UpdateUserMoodEntry(moodID uint, moodType models.MoodType, notes string, attributes []string) error

UpdateUserMoodEntry updates a single mood entry for a specific user, as well as all associated mood attributes.

type MoodServiceInterface

type MoodServiceInterface interface {
	CreateMoodEntry(moodType models.MoodType, notes string, userID uint, attributes []string) (models.MoodResponse, error)
	GetUserMoodEntries(userID uint, moodType *models.MoodType, startDate, endDate *string) ([]models.MoodResponse, error)
	GetSingleUserMoodEntry(userID, moodID uint) (models.MoodResponse, error)
	DeleteMoodEntry(userID, moodID uint) error
	CreateNewAttribute(attribute string, userID uint) error
	UpdateUserMoodEntry(moodID uint, moodType models.MoodType, notes string, attributes []string) error
	GetGenericAttributes(userID uint) ([]models.Attribute, error)
}

type ResourceService

type ResourceService struct {
	// contains filtered or unexported fields
}

func (*ResourceService) AddReview

func (rs *ResourceService) AddReview(resourceID, userID uint, content string, rating models.Rating) error

AddReview adds a review to a resource.

func (*ResourceService) CreateResourceEntry

func (rs *ResourceService) CreateResourceEntry(userID uint, title, content, url string, external, adminPost bool) (models.ResourceResponse, error)

CreateResourceEntry creates a new resource entry in the database.

func (*ResourceService) DeleteResource

func (rs *ResourceService) DeleteResource(userID, resourceID uint) error

DeleteResource deletes a resource by its ID.

func (*ResourceService) GetAdminResources

func (rs *ResourceService) GetAdminResources() ([]models.ResourceResponse, error)

GetAdminResources gets all the resources for an admin.

func (*ResourceService) GetAllResources

func (rs *ResourceService) GetAllResources() ([]models.ResourceResponse, error)

GetAllResources gets all the resources in the database.

func (*ResourceService) GetResourceByID

func (rs *ResourceService) GetResourceByID(resourceID uint) (models.ResourceResponse, error)

GetResourceByID gets a resource by its ID.

func (*ResourceService) UpdateResource

func (rs *ResourceService) UpdateResource(resourceID uint, userID uint, title, content, url string, external, adminPost bool) (models.ResourceResponse, error)

UpdateResource updates a resource in the database.

type ResourceServiceInterface

type ResourceServiceInterface interface {
	CreateResourceEntry(userID uint, title, content, url string, external, adminPost bool) (models.ResourceResponse, error)
	GetAllResources() ([]models.ResourceResponse, error)
	GetResourceByID(resourceID uint) (models.ResourceResponse, error)
	DeleteResource(userID, resourceID uint) error
	UpdateResource(resourceID uint, userID uint, title, content, url string, external, adminPost bool) (models.ResourceResponse, error)
	GetAdminResources() ([]models.ResourceResponse, error)
	AddReview(resourceID, userID uint, content string, rating models.Rating) error
}

Jump to

Keyboard shortcuts

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