Documentation ¶
Index ¶
Constants ¶
const DeckSecretCodeLength = 10
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct { gorm.Model `swaggerignore:"true"` // Model from gorm package Question string `json:"question"` // The question on the card Answer string `json:"answer"` // The answer to the question on the card Mcq Mcq `json:"mcq" gorm:"foreignKey:McqID"` // The multiple choice question associated with the card DeckID uint `json:"deck_id"` // The ID of the deck the card belongs to McqID uint `json:"mcq_id"` // The ID of the multiple choice question associated with the card CardType CardType `json:"card_type"` // The type of the card }
Card represents a card in the domain model. It includes fields for the question, answer, multiple choice question (mcq), deck ID, mcq ID, and card type.
func (*Card) HasMcqType ¶
HasMcqType checks if the card is of a type that includes a multiple choice question.
func (*Card) IsBlankType ¶
IsBlankType checks if the card is of a blank type.
func (*Card) IsMcqType ¶
IsMcqType checks if the card is of a type that is only a multiple choice question.
func (*Card) IsProgressiveType ¶
IsProgressiveType checks if the card is of a progressive type.
func (*Card) IsQAOnlyType ¶
IsQAOnlyType checks if the card is of a type that is only a question and answer.
type CardType ¶
type CardType int32
CardType represents the type of card.
type CreateDeck ¶
type CreateDeck struct { Name string `json:"name" validate:"required"` Description string `json:"description" validate:"required"` Lang string `json:"lang" validate:"required,len=2,alpha"` Banner string `json:"banner" validate:"required,uri"` }
CreateDeck is a struct that contains the data needed to create a deck.
func (*CreateDeck) ToDeck ¶
func (c *CreateDeck) ToDeck() Deck
ToDeck converts the CreateDeck struct to a Deck struct.
func (*CreateDeck) Validate ¶
func (c *CreateDeck) Validate() error
Validate validates the CreateDeck struct.
type Deck ¶
type Deck struct { gorm.Model `swaggerignore:"true"` Name string `json:"name"` Description string `json:"description"` Lang string `json:"lang"` Key string `json:"key"` Banner string `json:"banner"` Learners []*User `json:"-" gorm:"many2many:user_decks;"` Cards []Card `json:"cards" gorm:"foreignKey:DeckID"` OwnerID uint `json:"owner_id"` Status DeckStatus `json:"status"` }
Deck is the domain model for a deck.
func (*Deck) ToPublicDeck ¶
func (d *Deck) ToPublicDeck() PublicDeck
ToPublicDeck converts the deck to a public deck.
type DeckIndex ¶
type DeckIndex map[string]interface{}
DeckIndex is the index of the deck for MeiliSearch search engine.
type DeckStatus ¶
type DeckStatus int64
DeckStatus is the status of the deck.
const ( DeckStatusPrivate DeckStatus = 0 // DeckStatusPrivate is the private status of the deck DeckStatusToReview DeckStatus = 1 // DeckStatusToReview is the to review status of the deck DeckStatusPublic DeckStatus = 2 // DeckStatusPublic is the public status of the deck )
type DiscordLogin ¶
type DiscordLogin struct { ID string `json:"id"` Username string `json:"username"` Avatar string `json:"avatar"` Email string `json:"email"` }
DiscordLogin is a struct that represents the Discord login response.
func (*DiscordLogin) ToUser ¶
func (d *DiscordLogin) ToUser() User
ToUser converts the DiscordLogin to a User.
type GithubLogin ¶
type GithubLogin struct { Login string `json:"login"` NodeID string `json:"node_id"` AvatarURL string `json:"avatar_url"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` Bio string `json:"bio"` Email string `json:"email"` ID int `json:"id"` }
GithubLogin is a struct that represents the Github login response.
func (*GithubLogin) ToUser ¶
func (g *GithubLogin) ToUser() User
ToUser converts the GithubLogin to a User.
type Login ¶
type Login struct { Email string `json:"email" validate:"email"` // Email of the user Password string `json:"password"` // Password of the user }
Login is the login model.
type Mcq ¶
type Mcq struct { gorm.Model `swaggerignore:"true"` Answers string `json:"answers"` Linked bool `json:"linked"` }
Mcq is the domain model for a mcq.
func (*Mcq) ExtractAnswers ¶
type Permission ¶
type Permission int64
Permission is the permission level of a user.
const ( PermissionNone Permission = iota // PermissionNone is the default permission level. PermissionUser // PermissionUser is the permission level of a user. PermissionVip // PermissionVip is the permission level of a vip. PermissionAdmin // PermissionAdmin is the permission level of an admin. )
func (Permission) IsValid ¶
func (p Permission) IsValid() bool
func (Permission) String ¶
func (p Permission) String() string
type PublicDeck ¶
type PublicDeck struct { Name string `json:"name"` // Name of the deck Description string `json:"description"` // Description of the deck Lang string `json:"lang"` // Lang of the deck Banner string `json:"banner"` // Banner of the deck ID uint `json:"id"` // ID of the deck }
PublicDeck is the public deck model.
type PublicUser ¶
type PublicUser struct { Username string `json:"username"` // Username of the user Email string `json:"email"` // Email of the user Avatar string `json:"avatar"` // Avatar of the user ID uint `json:"id"` // ID of the user Permission Permission `json:"permission"` // Permission of the user }
PublicUser is the public user model.
type Register ¶
type Register struct { Username string `json:"username" validate:"required"` // Username of the user Email string `json:"email" validate:"email"` // Email of the user Password string `json:"password" validate:"required"` // Password of the user }
Register is the register model.
type Route ¶
type Route struct { Handler func(c *fiber.Ctx) error // Handler is the handler function for the route. Method string // Method is the method of the route. Permission Permission // Permission is the permission level of the route. }
Route is a route for the API It contains the handler, method and permission level.
type User ¶
type User struct { gorm.Model `swaggerignore:"true"` Username string `json:"username"` Email string `json:"email" validate:"email" gorm:"unique"` Password string `json:"-"` Avatar string `json:"avatar"` OauthProvider string `json:"oauth_provider" ` OauthID string `json:"oauth_id" gorm:"unique"` Learning []*Deck `json:"learning" gorm:"many2many:user_decks;"` OwnDecks []Deck `json:"own_decks" gorm:"foreignKey:OwnerID"` Permission Permission `json:"permission"` Oauth bool `json:"oauth" gorm:"default:false"` }
User is the domain model for a user.
func (*User) HasPermission ¶
func (u *User) HasPermission(permission Permission) bool
HasPermission checks if the user has the given permission.
func (*User) ToPublicUser ¶
func (u *User) ToPublicUser() PublicUser
ToPublicUser converts the user to a public user.