Documentation ¶
Overview ¶
internal/adapters/controller/auth.go
controllers/meow_controller.go
internal/adapters/controller/session.go
Index ¶
- Variables
- type CardContentReq
- type CardStatsRequest
- type ClearDeckStatsRequest
- type CreateCardRequest
- type CreateDeckRequest
- type GetNextCardResponse
- type GetSessionStatsResponse
- type LoginRequest
- type LoginResponse
- type MeowController
- func (c *MeowController) ClearDeckStats(ctx echo.Context) error
- func (hc *MeowController) ClearSession(c echo.Context) error
- func (c *MeowController) CreateCard(ctx echo.Context) error
- func (hc *MeowController) CreateDeck(c echo.Context) error
- func (hc *MeowController) CreateDefaultDeck(c echo.Context) error
- func (c *MeowController) DeleteCard(ctx echo.Context) error
- func (hc *MeowController) DeleteDeck(c echo.Context) error
- func (c *MeowController) ExportDeck(ctx echo.Context) error
- func (hc *MeowController) GetAllDecks(c echo.Context) error
- func (hc *MeowController) GetCardByID(c echo.Context) error
- func (hc *MeowController) GetDeckByID(c echo.Context) error
- func (hc *MeowController) GetNextCard(c echo.Context) error
- func (hc *MeowController) GetSessionStats(c echo.Context) error
- func (hc *MeowController) ImportDeck(c echo.Context) error
- func (hc *MeowController) Login(c echo.Context) error
- func (hc *MeowController) StartSession(c echo.Context) error
- func (c *MeowController) UpdateCard(ctx echo.Context) error
- func (c *MeowController) UpdateCardStats(ctx echo.Context) error
- func (hc *MeowController) UpdateDeck(c echo.Context) error
- type StartSessionRequest
- type UpdateCardRequest
- type UpdateDeckRequest
Constants ¶
This section is empty.
Variables ¶
var JWTSecret = []byte("your_secret_key")
JWTSecret is the secret key used to sign JWT tokens. In a production environment, ensure this is secure and not hard-coded.
Functions ¶
This section is empty.
Types ¶
type CardContentReq ¶
type CardContentReq struct {
Text string `json:"text" validate:"required"`
}
CardContentReq represents the content structure for front and back of a card
type CardStatsRequest ¶
type CardStatsRequest struct { CardID string `json:"card_id" validate:"required"` DeckID string `json:"deck_id,omitempty"` Action types.CardAction `json:"action" validate:"required,oneof=IncrementFail IncrementPass IncrementSkip SetStars Retire Unretire ResetStats"` Value *int `json:"value,omitempty"` // Used only for SetStars }
CardStatsRequest represents the expected payload for updating card stats
type ClearDeckStatsRequest ¶
type ClearDeckStatsRequest struct { ClearSession bool `json:"clearSession" validate:"required"` ClearStats bool `json:"clearStats" validate:"required"` }
ClearDeckStatsRequest represents the expected payload for clearing deck statistics
type CreateCardRequest ¶
type CreateCardRequest struct { DeckID string `json:"deck_id" validate:"required,uuid"` Front CardContentReq `json:"front" validate:"required"` Back CardContentReq `json:"back" validate:"required"` Link string `json:"link"` }
CreateCardRequest represents the expected payload for creating a card
type CreateDeckRequest ¶
type CreateDeckRequest struct {
DefaultData bool `json:"defaultData"`
}
CreateDeckRequest represents the request payload for creating a deck
type GetNextCardResponse ¶
type GetNextCardResponse struct {
CardID string `json:"card_id"`
}
GetNextCardResponse represents the response containing the next card ID
type GetSessionStatsResponse ¶
type GetSessionStatsResponse struct { TotalCards int `json:"total_cards"` ViewedCount int `json:"viewed_count"` Remaining int `json:"remaining"` CurrentIndex int `json:"current_index"` CardStats []types.CardStats `json:"card_stats"` }
GetSessionStatsResponse represents the session statistics
type LoginRequest ¶
type LoginRequest struct { Username string `json:"username" validate:"required"` Password string `json:"password" validate:"required"` }
LoginRequest represents the expected payload for login
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
}
LoginResponse represents the response containing the JWT token
type MeowController ¶
type MeowController struct {
// contains filtered or unexported fields
}
func NewMeowController ¶
func NewMeowController(service domain.MeowDomain, logger *slog.Logger) *MeowController
func (*MeowController) ClearDeckStats ¶
func (c *MeowController) ClearDeckStats(ctx echo.Context) error
@Summary Clear deck statistics @Description Clears the statistics for a specific deck. Can optionally clear session data and/or card statistics. @Tags Decks @Accept json @Produce json @Param id path string true "Deck ID" @Param stats body ClearDeckStatsRequest true "Clear Deck Statistics" @Success 200 {object} map[string]string @Failure 400 {object} echo.HTTPError @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Router /decks/stats/{id} [post]
func (*MeowController) ClearSession ¶
func (hc *MeowController) ClearSession(c echo.Context) error
ClearSession handles the termination of a review session for a deck @Summary Clear a review session @Description Terminate and clear the current review session for a specific deck @Tags Sessions @Produce json @Param deck_id query string true "Deck ID" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /sessions/clear [delete]
func (*MeowController) CreateCard ¶
func (c *MeowController) CreateCard(ctx echo.Context) error
@Summary Create a new card @Description Create a new card and associate it with a deck @Tags cards @Accept json @Produce json @Param card body CreateCardRequest true "Create Card" @Success 201 {object} types.Card @Failure 400 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Router /cards [post]
func (*MeowController) CreateDeck ¶
func (hc *MeowController) CreateDeck(c echo.Context) error
CreateDeck handles the creation of a new deck @Summary Create a new deck @Description Create a new deck with provided details @Tags Decks @Accept json @Produce json @Param deck body types.Deck true "Deck to create" @Success 201 {object} types.Deck @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /decks [post]
func (*MeowController) CreateDefaultDeck ¶
func (hc *MeowController) CreateDefaultDeck(c echo.Context) error
CreateDeck handles the creation of a new deck, optionally with default data @Summary Create a new deck @Description Create a new deck with or without default data @Tags Decks @Accept json @Produce json @Param deck body CreateDeckRequest true "Deck creation parameters" @Success 200 {object} types.Deck @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /decks/default [post]
func (*MeowController) DeleteCard ¶
func (c *MeowController) DeleteCard(ctx echo.Context) error
DeleteCard deletes a card by its ID @Summary Delete a card @Description Delete a card by its ID @Tags Cards @Produce json @Param id path string true "Card ID" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /cards/{id} [delete]
func (*MeowController) DeleteDeck ¶
func (hc *MeowController) DeleteDeck(c echo.Context) error
DeleteDeck handles the deletion of a deck @Summary Delete a deck @Description Delete a deck by its ID @Tags Decks @Param id path string true "Deck ID" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /decks/{id} [delete]
func (*MeowController) ExportDeck ¶
func (c *MeowController) ExportDeck(ctx echo.Context) error
ExportDeck handles the export of a deck as a JSON file @Summary Export a deck @Description Export a deck as a JSON file @Tags decks @Produce application/json @Param id path string true "Deck ID" @Success 200 {object} types.Deck @Failure 400 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Router /decks/export/{id} [get]
func (*MeowController) GetAllDecks ¶
func (hc *MeowController) GetAllDecks(c echo.Context) error
GetAllDecks retrieves all decks @Summary Get all decks @Description Retrieve a list of all decks @Tags Decks @Produce json @Success 200 {array} types.Deck @Failure 500 {object} map[string]string @Router /decks [get]
func (*MeowController) GetCardByID ¶
func (hc *MeowController) GetCardByID(c echo.Context) error
GetCardByID retrieves a card by its ID @Summary Get a card by ID @Description Retrieve a single card by its ID @Tags Cards @Produce json @Param id path string true "Card ID" @Success 200 {object} types.Card @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /cards/{id} [get]
func (*MeowController) GetDeckByID ¶
func (hc *MeowController) GetDeckByID(c echo.Context) error
GetDeckByID retrieves a deck by its ID @Summary Get a deck by ID @Description Retrieve a single deck by its ID @Tags Decks @Produce json @Param id path string true "Deck ID" @Success 200 {object} types.Deck @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /decks/{id} [get]
func (*MeowController) GetNextCard ¶
func (hc *MeowController) GetNextCard(c echo.Context) error
GetNextCard retrieves the next card ID in the current session @Summary Get the next card in the session @Description Retrieve the ID of the next card to review in the current session @Tags Sessions @Produce json @Param deck_id query string true "Deck ID" @Success 200 {object} GetNextCardResponse @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /sessions/next [get]
func (*MeowController) GetSessionStats ¶
func (hc *MeowController) GetSessionStats(c echo.Context) error
GetSessionStats retrieves the statistics of the current session for a deck @Summary Get session statistics @Description Retrieve the statistics of the current review session for a specific deck @Tags Sessions @Produce json @Param deck_id query string true "Deck ID" @Success 200 {object} GetSessionStatsResponse @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /sessions/stats [get]
func (*MeowController) ImportDeck ¶
func (hc *MeowController) ImportDeck(c echo.Context) error
ImportDeck handles the import deck POST request @Summary Import a deck from a JSON file @Description Import a new deck by uploading a JSON file @Tags Decks @Accept multipart/form-data @Produce json @Param deck_file formData file true "Deck JSON File" @Success 201 {object} types.Deck @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /decks/import [post]
func (*MeowController) Login ¶
func (hc *MeowController) Login(c echo.Context) error
Login handles user authentication @Summary User Login @Description Authenticate user and return a JWT token @Tags Authentication @Accept json @Produce json @Param credentials body LoginRequest true "User Credentials" @Success 200 {object} LoginResponse @Failure 400 {object} map[string]string @Failure 401 {object} map[string]string @Failure 500 {object} map[string]string @Router /login [post]
func (*MeowController) StartSession ¶
func (hc *MeowController) StartSession(c echo.Context) error
StartSession handles the initiation of a new review session for a deck @Summary Start a new review session @Description Initiate a new review session for a specific deck with the given parameters @Tags Sessions @Accept json @Produce json @Param session body StartSessionRequest true "Session Parameters" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /sessions/start [post]
func (*MeowController) UpdateCard ¶
func (c *MeowController) UpdateCard(ctx echo.Context) error
@Summary Update an existing card @Description Update the details of an existing card by its ID @Tags cards @Accept json @Produce json @Param id path string true "Card ID" @Param card body UpdateCardRequest true "Update Card" @Success 200 {object} types.Card @Failure 400 {object} echo.HTTPError @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Router /cards/{id} [put]
func (*MeowController) UpdateCardStats ¶
func (c *MeowController) UpdateCardStats(ctx echo.Context) error
@Summary Update card statistics @Description Update the statistics of a card based on the specified action @Tags Cards @Accept json @Produce json @Param stats body CardStatsRequest true "Card Stats Update" @Success 200 {object} types.Card @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /cards/stats [post]
func (*MeowController) UpdateDeck ¶
func (hc *MeowController) UpdateDeck(c echo.Context) error
UpdateDeck handles updating an existing deck @Summary Update a deck @Description Update the name (and optionally the ID) of an existing deck by its ID @Tags Decks @Accept json @Produce json @Param id path string true "Deck ID" @Param deck body UpdateDeckRequest true "Updated Deck" @Success 200 {object} types.Deck @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Router /decks/{id} [put]
type StartSessionRequest ¶
type StartSessionRequest struct { DeckID string `json:"deck_id" validate:"required,uuid"` Count int `json:"count" validate:"min=1"` Method types.SessionMethod `json:"method" validate:"required,oneof=Random Fails Skips Worst"` }
StartSessionRequest represents the expected payload for starting a session
type UpdateCardRequest ¶
type UpdateCardRequest struct { Front *CardContentReq `json:"front"` Back *CardContentReq `json:"back"` Link *string `json:"link"` }
UpdateCardRequest represents the expected payload for updating a card
type UpdateDeckRequest ¶
type UpdateDeckRequest struct { Name string `json:"name" validate:"required"` Description string `json:"description" validate:"required"` }
UpdateDeckRequest represents the expected payload for updating a deck