Documentation
¶
Index ¶
- Constants
- Variables
- func CountProblemByOptions(tx *gorm.DB, options GetProblemOptions) (int64, error)
- func CreateProblem(tx *gorm.DB, problem Problem) error
- func DeleteProblem(tx *gorm.DB, slug string) error
- func GetTagsList(problem Problem) []string
- func UpdateProblem(tx *gorm.DB, problem Problem) error
- type GetProblemOptions
- type Problem
- type ProblemDifficulty
- type ProblemInfoView
- type ProblemTag
- type ProblemTagView
Constants ¶
View Source
const DefaultProblemDifficulty = ProblemDifficultyEasy
Variables ¶
View Source
var ProblemInfoSelection = append([]string{"slug", "title", "difficulty", "accept_count", "submit_count"}, models.MetaFieldsSelection...)
Functions ¶
func CountProblemByOptions ¶
func CountProblemByOptions(tx *gorm.DB, options GetProblemOptions) (int64, error)
func GetTagsList ¶
Types ¶
type GetProblemOptions ¶
type GetProblemOptions struct { Selection []string Slug string TitleQuery string Difficulty ProblemDifficulty Tags []*ProblemTag Offset *int Limit *int }
type Problem ¶
type Problem struct { models.MetaFields Slug string `json:"slug" gorm:"primaryKey"` Title string `json:"title" gorm:"not null"` Description *string `json:"description,omitempty"` Difficulty ProblemDifficulty `json:"difficulty,omitempty"` Tags []*ProblemTag `json:"tags" gorm:"many2many:problem_problem_tags;"` Solved *bool `json:"solved,omitempty" gorm:"-"` AcceptCount int `json:"acceptCount"` SubmitCount int `json:"submitCount"` }
func GetProblemListByOptions ¶
func GetProblemListByOptions(tx *gorm.DB, options GetProblemOptions) ([]Problem, error)
func (Problem) ToProblemInfo ¶
func (p Problem) ToProblemInfo() ProblemInfoView
type ProblemDifficulty ¶
type ProblemDifficulty string
const ( ProblemDifficultyEasy ProblemDifficulty = "easy" ProblemDifficultyMedium ProblemDifficulty = "medium" ProblemDifficultyHard ProblemDifficulty = "hard" )
func (ProblemDifficulty) IsValid ¶
func (d ProblemDifficulty) IsValid() bool
type ProblemInfoView ¶
type ProblemInfoView struct { Slug string `json:"slug"` Title string `json:"title"` Difficulty ProblemDifficulty `json:"difficulty"` Tags []ProblemTagView `json:"tags"` Solved *bool `json:"solved,omitempty"` PassRate float32 `json:"passRate"` }
func GetProblemInfoViewList ¶
func GetProblemInfoViewList(problems []Problem) []ProblemInfoView
type ProblemTag ¶
type ProblemTag struct { models.MetaFields Name string `json:"name" gorm:"primaryKey"` Problems []*Problem `json:"problems,omitempty" gorm:"many2many:problem_problem_tags;"` }
func (ProblemTag) ToProblemTagView ¶
func (pt ProblemTag) ToProblemTagView() ProblemTagView
type ProblemTagView ¶
type ProblemTagView struct { models.MetaFields Name string `json:"name"` }
func GetProblemTagViewList ¶
func GetProblemTagViewList(tags []*ProblemTag) []ProblemTagView
Click to show internal directories.
Click to hide internal directories.