Documentation ¶
Index ¶
- type Choice
- type ChoiceEntity
- type Controller
- func (c *Controller) Health(w http.ResponseWriter, r *http.Request)
- func (c *Controller) Home(w http.ResponseWriter, r *http.Request)
- func (c *Controller) NewQuestion(w http.ResponseWriter, r *http.Request)
- func (c *Controller) QuestionList(w http.ResponseWriter, r *http.Request)
- func (c *Controller) RandomQuestion(w http.ResponseWriter, _ *http.Request)
- func (c *Controller) Result(w http.ResponseWriter, r *http.Request)
- type LoadMoreParam
- type Question
- type QuestionData
- type QuestionEntity
- type QuestionListPageData
- type QuestionRepository
- func (r *QuestionRepository) FindChoicesByQuestionIds(ctx context.Context, questionIds ...int) (map[int][]Choice, error)
- func (r *QuestionRepository) FindRuleByID(ctx context.Context, ruleID string) (*Rule, error)
- func (r *QuestionRepository) FindRuleByIDs(ctx context.Context, ruleIDs ...string) (map[string]Rule, error)
- func (r *QuestionRepository) GetAllDistinctRuleIDs(ctx context.Context) ([]string, error)
- func (r *QuestionRepository) GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error)
- func (r *QuestionRepository) GetRandomQuestion(ctx context.Context, rules []string) (*Question, error)
- func (r *QuestionRepository) ListQuestions(ctx context.Context, ruleIDs []string, search string, lastRuleSortOrder int, ...) ([]Question, error)
- type QuestionService
- func (s *QuestionService) GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error)
- func (s *QuestionService) GetRandomQuestion(ctx context.Context, rules []string) (*Question, error)
- func (s *QuestionService) ListQuestions(ctx context.Context, rules []string, search string, lastRuleSortOrder int, ...) ([]Question, error)
- type Reference
- type ReferenceEntity
- type Repository
- type Rule
- type RuleEntity
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChoiceEntity ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(service Service, html fs.FS) *Controller
func (*Controller) Health ¶
func (c *Controller) Health(w http.ResponseWriter, r *http.Request)
func (*Controller) Home ¶
func (c *Controller) Home(w http.ResponseWriter, r *http.Request)
func (*Controller) NewQuestion ¶
func (c *Controller) NewQuestion(w http.ResponseWriter, r *http.Request)
func (*Controller) QuestionList ¶
func (c *Controller) QuestionList(w http.ResponseWriter, r *http.Request)
func (*Controller) RandomQuestion ¶
func (c *Controller) RandomQuestion(w http.ResponseWriter, _ *http.Request)
func (*Controller) Result ¶
func (c *Controller) Result(w http.ResponseWriter, r *http.Request)
type LoadMoreParam ¶
type QuestionData ¶
type QuestionEntity ¶
type QuestionListPageData ¶
type QuestionListPageData struct { Questions []QuestionData LoadMoreParam LoadMoreParam }
type QuestionRepository ¶
type QuestionRepository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *pgxpool.Pool) *QuestionRepository
func (*QuestionRepository) FindChoicesByQuestionIds ¶
func (r *QuestionRepository) FindChoicesByQuestionIds(ctx context.Context, questionIds ...int) (map[int][]Choice, error)
FindChoicesByQuestionIds finds choices by question ids and returns a map of question id to choices
func (*QuestionRepository) FindRuleByID ¶
func (*QuestionRepository) FindRuleByIDs ¶
func (r *QuestionRepository) FindRuleByIDs(ctx context.Context, ruleIDs ...string) (map[string]Rule, error)
FindRuleByIDs finds rules by rule ids and returns a map of rule id to rule
func (*QuestionRepository) GetAllDistinctRuleIDs ¶
func (r *QuestionRepository) GetAllDistinctRuleIDs(ctx context.Context) ([]string, error)
func (*QuestionRepository) GetChoicesByQuestionID ¶
func (*QuestionRepository) GetRandomQuestion ¶
func (*QuestionRepository) ListQuestions ¶
func (r *QuestionRepository) ListQuestions(ctx context.Context, ruleIDs []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error)
ListQuestions returns a list of questions supports pagination using the rule sort order and question number of the last question to offset
type QuestionService ¶
type QuestionService struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repository Repository) *QuestionService
func (*QuestionService) GetChoicesByQuestionID ¶
func (*QuestionService) GetRandomQuestion ¶
type ReferenceEntity ¶
type Repository ¶
type Repository interface { GetRandomQuestion(ctx context.Context, rules []string) (*Question, error) GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error) ListQuestions(ctx context.Context, rules []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error) }
type RuleEntity ¶
type Service ¶
type Service interface { GetRandomQuestion(ctx context.Context, rules []string) (*Question, error) GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error) ListQuestions(ctx context.Context, rules []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error) }
Click to show internal directories.
Click to hide internal directories.