helpers

package
v0.0.0-...-16d05a1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminHelper

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

AdminHelper well it's written on the box :)

func NewAdminHelper

func NewAdminHelper(repo data.CRUDRepo[models.Admin], orgRepo data.CRUDRepo[models.Organizer], userRepo data.CRUDRepo[models.User]) *AdminHelper

NewAdminHelper returns a new AdminHelper instance

func (*AdminHelper) AddDirector

func (a *AdminHelper) AddDirector(director models.Organizer, baseUser models.User) error

AddDirector adds a director, much wow

func (*AdminHelper) DeleteDirector

func (a *AdminHelper) DeleteDirector(director models.Organizer) error

DeleteDirector deletes a director, much wow

func (*AdminHelper) GetDirectors

func (a *AdminHelper) GetDirectors() (dirs []models.Organizer, err error)

GetDirectors returns all directors registered, and an occurring error

func (*AdminHelper) GetProfile

func (a *AdminHelper) GetProfile(user models.User) (models.Admin, error)

GetProfile returns contestant's for the given user

func (*AdminHelper) GetUserProfileUsingEmail

func (a *AdminHelper) GetUserProfileUsingEmail(userEmail string) (models.User, error)

GetUserProfileUsingEmail returns user's profile for the given user email

type ContestantHelper

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

ContestantHelper holds contestants underlying operations

func NewContestantHelper

func NewContestantHelper(b *ContestantHelperBuilder) *ContestantHelper

NewContestantHelper returns a new ContestantHelper instance

func (*ContestantHelper) AcceptJoinRequest

func (c *ContestantHelper) AcceptJoinRequest(notification models.Notification) error

AcceptJoinRequest adds the requester to the requested team and deletes the other requests & notifications and sends a success notification to the requester

func (*ContestantHelper) CheckJoinedContest

func (c *ContestantHelper) CheckJoinedContest(contest models.Contest, contestant models.Contestant) error

CheckJoinedContest reports whether the contestant is in the given contest or not

func (*ContestantHelper) CheckJoinedTeam

func (c *ContestantHelper) CheckJoinedTeam(cont models.Contestant, team models.Team) bool

CheckJoinedTeam reports whether the given contestant is in the given team, or any team at all

func (*ContestantHelper) CreateTeam

func (c *ContestantHelper) CreateTeam(contestant models.Contestant, team models.Team) error

CreateTeam creates a team and adds the given contestant to it as its leader

func (*ContestantHelper) DeleteTeam

func (c *ContestantHelper) DeleteTeam(team models.Team) error

DeleteTeam kicks every member out of it and deletes it

func (*ContestantHelper) GetProfile

func (c *ContestantHelper) GetProfile(user models.User) (models.Contestant, error)

GetProfile returns contestant's for the given user

func (*ContestantHelper) GetTeam

func (c *ContestantHelper) GetTeam(contestant models.Contestant) (models.Team, error)

GetTeam returns a team using the given id

func (*ContestantHelper) LeaveTeam

func (c *ContestantHelper) LeaveTeam(contestant models.Contestant) error

LeaveTeam removes the given contestant from their team in a super safe way

func (*ContestantHelper) Register

func (c *ContestantHelper) Register(cont models.Contestant) error

Register creates a new contestant

func (*ContestantHelper) RegisterAsTeamless

func (c *ContestantHelper) RegisterAsTeamless(contestant models.Contestant, contest models.Contest) error

RegisterAsTeamless adds the given contestant as teamless for the given contest

func (*ContestantHelper) RegisterInContest

func (c *ContestantHelper) RegisterInContest(contest models.Contest, contestant models.Contestant) error

RegisterInContest adds the given contestant's team to the given contest

func (*ContestantHelper) RejectJoinRequest

func (c *ContestantHelper) RejectJoinRequest(noti models.Notification) error

RejectJoinRequest rejects the requester to join the team and deletes the leader's notification

func (*ContestantHelper) RequestJoinTeam

func (c *ContestantHelper) RequestJoinTeam(jr models.JoinRequest, cont models.Contestant) error

RequestJoinTeam sends a notification to the requested team leader

type ContestantHelperBuilder

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

func NewContestantHelperBuilder

func NewContestantHelperBuilder() *ContestantHelperBuilder

func (*ContestantHelperBuilder) ContestRepo

func (*ContestantHelperBuilder) ContestantRepo

func (*ContestantHelperBuilder) GetContestantManager

func (b *ContestantHelperBuilder) GetContestantManager() *ContestantHelper

func (*ContestantHelperBuilder) JoinRequestMgr

func (*ContestantHelperBuilder) NotificationRepo

func (*ContestantHelperBuilder) TeamMgr

func (*ContestantHelperBuilder) UserRepo

type JoinRequestHelper

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

JoinRequestHelper manages teams join requests

func NewJoinRequestHelper

func NewJoinRequestHelper(repo data.CRUDRepo[models.JoinRequest], nRepo data.CRUDRepo[models.Notification],
	contestRepo data.GetterRepo[models.Contest], teamManager *TeamHelper) *JoinRequestHelper

NewJoinRequestHelper returns a new JoinRequestHelper instance

func (*JoinRequestHelper) AcceptJoinRequest

func (j *JoinRequestHelper) AcceptJoinRequest(noti models.Notification) error

AcceptJoinRequest adds the requester to the requested team and deletes the other requests & notifications and sends a success notification to the requester

func (*JoinRequestHelper) CheckContestantTeamRequests

func (j *JoinRequestHelper) CheckContestantTeamRequests(cont models.Contestant, team models.Team) bool

CheckContestantTeamRequests reports whether the given contestant has requested to join the given team

func (*JoinRequestHelper) DeleteRequests

func (j *JoinRequestHelper) DeleteRequests(contID, notiID uint) error

DeleteRequests deletes all join requests done by a contestant used when a contestant is approved to a team, or if a contestant creates a team

func (*JoinRequestHelper) RejectJoinRequest

func (j *JoinRequestHelper) RejectJoinRequest(noti models.Notification) error

RejectJoinRequest rejects the requester to join the team and deletes the leader's notification

func (*JoinRequestHelper) RequestJoinTeam

func (j *JoinRequestHelper) RequestJoinTeam(jr models.JoinRequest, cont models.Contestant) error

RequestJoinTeam sends a notification to the requested team leader

type NotificationHelper

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

NotificationHelper well it's written on the box :)

func NewNotificationHelper

func NewNotificationHelper(repo data.CRUDRepo[models.Notification]) *NotificationHelper

NewNotificationHelper returns a new NotificationHelper instance

func (*NotificationHelper) CheckNotifications

func (n *NotificationHelper) CheckNotifications(session models.Session) bool

CheckNotifications reports whether a user has notifications or not

func (*NotificationHelper) ClearNotifications

func (n *NotificationHelper) ClearNotifications(session models.Session) error

ClearNotifications deletes all notifications for user base on the given session

func (*NotificationHelper) GetNotifications

func (n *NotificationHelper) GetNotifications(session models.Session) ([]models.Notification, error)

GetNotifications returns user's notifications based on the given session

func (*NotificationHelper) SendMany

func (n *NotificationHelper) SendMany(notifications []*models.Notification) error

func (*NotificationHelper) SendManyOnTime

func (n *NotificationHelper) SendManyOnTime(notifications []*models.Notification, t time.Time) error

type OrganizerHelper

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

OrganizerHelper well hmm

func NewOrganizerHelper

func NewOrganizerHelper(b *OrganizerHelperBuilder) *OrganizerHelper

NewOrganizerHelper returns a new OrganizerHelper instance

func (*OrganizerHelper) AddOrganizer

func (o *OrganizerHelper) AddOrganizer(newOrg, director models.Organizer, baseUser models.User, contest models.Contest, roles enums.OrganizerRole) error

AddOrganizer adds the given organizer

func (*OrganizerHelper) CheckOrgRole

func (o *OrganizerHelper) CheckOrgRole(role enums.OrganizerRole, contestID, organizerID uint) bool

CheckOrgRole reports whether the given organizer has the given role over the given contest

func (*OrganizerHelper) CreateContest

func (o *OrganizerHelper) CreateContest(contest models.Contest, org models.Organizer) error

CreateContest creates a new contest, much wow!

func (*OrganizerHelper) CreateUpdateTeams

func (o *OrganizerHelper) CreateUpdateTeams(teams []models.Team, removedConts []models.Contestant, contest models.Contest, org models.Organizer) error

CreateUpdateTeams creates/updates the given teams :)

func (*OrganizerHelper) DeleteContest

func (o *OrganizerHelper) DeleteContest(contest models.Contest) error

DeleteContest deletes contest, much wow!

func (*OrganizerHelper) DeleteOrganizer

func (o *OrganizerHelper) DeleteOrganizer(org models.Organizer, contest models.Contest) error

DeleteOrganizer deletes the given organizer

func (*OrganizerHelper) FinishProfile

func (o *OrganizerHelper) FinishProfile(org models.Organizer) error

FinishProfile sets the organizer's profile after the first sign in after the promotion

func (*OrganizerHelper) GenerateTeams

func (o *OrganizerHelper) GenerateTeams(contest models.Contest, genType string, names []string) ([]models.Team, []models.Contestant, error)

GenerateTeams generates teams for the teamless contestants of the given contest

func (*OrganizerHelper) GetContest

func (o *OrganizerHelper) GetContest(contest models.Contest) (models.Contest, error)

GetContest well lol

func (*OrganizerHelper) GetContests

func (o *OrganizerHelper) GetContests(org models.Organizer) ([]models.Contest, error)

GetContests returns the contests of the given organizer, and an occurring error

func (*OrganizerHelper) GetNonOrgUsers

func (o *OrganizerHelper) GetNonOrgUsers() ([]models.User, error)

GetNonOrgUsers returns all contestants or newly signed-up users so that a director can make some of them as organizers

func (*OrganizerHelper) GetOrgRoles

func (o *OrganizerHelper) GetOrgRoles(orgID, contestID uint) (roles enums.OrganizerRole, rolesNames []string, err error)

func (*OrganizerHelper) GetOrganizers

func (o *OrganizerHelper) GetOrganizers(org models.Organizer, contest models.Contest) ([]models.Organizer, error)

GetOrganizers returns all organizers that are under the given organizer

func (*OrganizerHelper) GetParticipants

func (o *OrganizerHelper) GetParticipants(contest models.Contest, org models.Organizer) (parts []models.User, err error)

func (*OrganizerHelper) GetParticipantsCSV

func (o *OrganizerHelper) GetParticipantsCSV(contest models.Contest) (string, error)

GetParticipantsCSV returns a string with the participated contestants and organizers

func (*OrganizerHelper) GetProfile

func (o *OrganizerHelper) GetProfile(user models.User) (models.Organizer, error)

GetProfile returns organizer's profile for the given user

func (*OrganizerHelper) GetTeamsCSV

func (o *OrganizerHelper) GetTeamsCSV(contest models.Contest) (string, error)

func (*OrganizerHelper) GetUserProfileUsingEmail

func (o *OrganizerHelper) GetUserProfileUsingEmail(userEmail string) (models.User, error)

GetUserProfileUsingEmail returns user's profile for the given user email

func (*OrganizerHelper) MarkAttendance

func (o *OrganizerHelper) MarkAttendance(user models.User, contest models.Contest) error

func (*OrganizerHelper) SendSheevNotifications

func (o *OrganizerHelper) SendSheevNotifications(contest models.Contest) error

func (*OrganizerHelper) UpdateContest

func (o *OrganizerHelper) UpdateContest(contest models.Contest) error

UpdateContest you guessed it, much wow!

func (*OrganizerHelper) UpdateOrganizer

func (o *OrganizerHelper) UpdateOrganizer(newOrg, director models.Organizer, baseUser models.User, contest models.Contest, roles enums.OrganizerRole) error

UpdateOrganizer updates the given organizer

func (*OrganizerHelper) UpdateTeam

func (o *OrganizerHelper) UpdateTeam(team models.Team, org models.Organizer) error

UpdateTeam updates the given team after checking that the given organizer is a director on one of the contest that the team is in

type OrganizerHelperBuilder

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

func NewOrganizerHelperBuilder

func NewOrganizerHelperBuilder() *OrganizerHelperBuilder

func (*OrganizerHelperBuilder) ContestRepo

func (*OrganizerHelperBuilder) GetOrganizerManager

func (b *OrganizerHelperBuilder) GetOrganizerManager() *OrganizerHelper

func (*OrganizerHelperBuilder) NotificationMgr

func (*OrganizerHelperBuilder) OrganizeContestRepo

func (*OrganizerHelperBuilder) OrganizerRepo

func (*OrganizerHelperBuilder) TeamMgr

func (*OrganizerHelperBuilder) UserRepo

type SessionHelper

type SessionHelper[T models.Session] struct {
	// contains filtered or unexported fields
}

func NewSessionHelper

func NewSessionHelper[T models.Session](sessionRepo data.CRUDRepo[models.Session]) *SessionHelper[T]

func (*SessionHelper[T]) CreateSession

func (s *SessionHelper[T]) CreateSession(userID uint) (models.Session, error)

func (*SessionHelper[T]) DeleteAllSessions

func (s *SessionHelper[T]) DeleteAllSessions(userID uint) error

func (*SessionHelper[T]) DeleteSession

func (s *SessionHelper[T]) DeleteSession(token string) error

func (*SessionHelper[T]) GetSession

func (s *SessionHelper[T]) GetSession(token string) (models.Session, error)

type TeamHelper

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

TeamHelper manages teams and stuff

func NewTeamHelper

func NewTeamHelper(teamRepo data.Many2ManyCRUDRepo[models.Team, any], contRepo data.CRUDRepo[models.Contestant]) *TeamHelper

NewTeamHelper returns a new TeamHelper instance

func (*TeamHelper) AddContestantToTeam

func (t *TeamHelper) AddContestantToTeam(contID, teamID uint) (team models.Team, err error)

AddContestantToTeam adds the given contestant to the given team

func (*TeamHelper) CreateTeam

func (t *TeamHelper) CreateTeam(contestant models.Contestant, team *models.Team) error

CreateTeam creates a team and adds the given contestant to it as its leader

func (*TeamHelper) CreateTeams

func (t *TeamHelper) CreateTeams(teams []*models.Team) error

CreateTeams creates the given teams :)

func (*TeamHelper) CreateUpdateTeams

func (t *TeamHelper) CreateUpdateTeams(teams []models.Team, removedContestants []models.Contestant, contest models.Contest, org models.Organizer) error

func (*TeamHelper) DeleteTeam

func (t *TeamHelper) DeleteTeam(team models.Team) error

DeleteTeam kicks every member out of it and deletes it

func (*TeamHelper) GetTeam

func (t *TeamHelper) GetTeam(id uint) (models.Team, error)

GetTeam returns a team using the given id

func (*TeamHelper) GetTeamByJoinID

func (t *TeamHelper) GetTeamByJoinID(joinID string) (models.Team, error)

GetTeamByJoinID returns a team using the given join id

func (*TeamHelper) LeaveTeam

func (t *TeamHelper) LeaveTeam(cont models.Contestant) error

LeaveTeam removes the given contestant from their team in a super safe way

func (*TeamHelper) UpdateTeam

func (t *TeamHelper) UpdateTeam(team models.Team, org models.Organizer) error

UpdateTeam updates the given team after checking that the given organizer is a director on one of the contest that the team is in

type UserHelper

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

func NewUserHelper

func NewUserHelper(repo data.CRUDRepo[models.User], contRepo data.CRUDRepo[models.Contestant], sessMgr *SessionHelper[models.Session]) *UserHelper

func (*UserHelper) Login

func (u *UserHelper) Login(user *models.User) (sess models.Session, err error)

func (*UserHelper) LoginUsingSession

func (u *UserHelper) LoginUsingSession(sessionToken string) (user models.User, err error)

func (*UserHelper) Logout

func (u *UserHelper) Logout(user models.User, sessionToken string) error

func (*UserHelper) Signup

func (u *UserHelper) Signup(user *models.User) error

func (*UserHelper) UpdateUser

func (u *UserHelper) UpdateUser(user *models.User) error

Jump to

Keyboard shortcuts

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