Documentation ¶
Index ¶
- Variables
- func Init(sm *http.ServeMux, l *log.Logger, mongo *db.Mongo)
- type Controller
- func (h *Controller) Delete(pn int, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
- func (h *Controller) Get(pn int, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
- func (h *Controller) Gets(w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
- func (h *Controller) Post(cp *CreateProblem, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
- func (h *Controller) Put(pn int, up *UpdateProblem, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
- type CreateProblem
- type Example
- type Handler
- type Hint
- type M
- type Problem
- type Repository
- type TestCase
- type UpdateProblem
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoProblem = errors.New("mongo: no problem in result")
Functions ¶
Types ¶
type Controller ¶
type Controller struct { Log *log.Logger Repo *Repository }
func NewController ¶
func NewController(l *log.Logger, r *Repository) *Controller
func (*Controller) Delete ¶
func (h *Controller) Delete(pn int, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
func (*Controller) Get ¶
func (h *Controller) Get(pn int, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
func (*Controller) Gets ¶
func (h *Controller) Gets(w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
func (*Controller) Post ¶
func (h *Controller) Post(cp *CreateProblem, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
func (*Controller) Put ¶
func (h *Controller) Put(pn int, up *UpdateProblem, w http.ResponseWriter, r *http.Request) (*utl.ResponseBody, utl.StatusCode)
type CreateProblem ¶
type CreateProblem struct { ContestNumber int `json:"contest_number"` ProblemName string `json:"problem_name"` Diffculty string `json:"diffculty"` Hints []Hint `json:"hints"` Statement string `json:"statement"` InputExplain string `json:"input_explain"` OutputExplain string `json:"output_explain"` Examples []Example `json:"examples"` TestCases []TestCase `json:"test_cases"` RelatedTopics []string `json:"related_topics"` }
func (*CreateProblem) ToProblem ¶
func (p *CreateProblem) ToProblem() *Problem
type Handler ¶
type Handler struct { Log *log.Logger Repo *Repository Cont *Controller }
func NewHandler ¶
func NewHandler(l *log.Logger, r *Repository, c *Controller) *Handler
func (*Handler) Decide ¶
func (h *Handler) Decide(w http.ResponseWriter, r *http.Request) utl.StatusCode
type Problem ¶
type Problem struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"` AuthorUsername string `bson:"author_username" json:"author_username"` ContestNumber int `bson:"contest_number" json:"contest_number"` ProblemNumber int `bson:"problem_number" json:"problem_number"` ProblemName string `bson:"problem_name" json:"problem_name"` Diffculty string `bson:"diffculty" json:"diffculty"` LikeCount int `bson:"like_count" json:"like_count"` DislikeCount int `bson:"dislike_count" json:"dislike_count"` Hints []Hint `bson:"hints" json:"hints"` Statement string `bson:"statement" json:"statement"` InputExplain string `bson:"input_explain" json:"input_explain"` OutputExplain string `bson:"output_explain" json:"output_explain"` Examples []Example `bson:"examples" json:"examples"` TestCases []TestCase `bson:"test_cases" json:"test_cases"` AcceptedCount int `bson:"accepted_count" json:"accepted_count"` SubmissionCount int `bson:"submission_count" json:"submission_count"` RelatedTopics []string `bson:"related_topics" json:"related_topics"` DiscussionMongoId string `bson:"discussion_mongo_id" json:"discussion_mongo_id"` SolutionsMongoId string `bson:"solutions_mongo_id" json:"solutions_mongo_id"` CreatedAt time.Time `bson:"created_at" json:"created_at"` UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` }
func (*Problem) AdjustUpdateData ¶
func (p *Problem) AdjustUpdateData(up *UpdateProblem)
type Repository ¶
type Repository struct { Log *log.Logger Coll *mongo.Collection }
func (*Repository) Create ¶
func (r *Repository) Create(p *CreateProblem) (*Problem, error)
func (*Repository) DeleteBy ¶
func (r *Repository) DeleteBy(pn int) (err error)
func (*Repository) Read ¶
func (r *Repository) Read() ([]Problem, error)
type UpdateProblem ¶
type UpdateProblem struct { ProblemName string `json:"problem_name"` Diffculty string `json:"diffculty"` Hints []Hint `json:"hints"` Statement string `json:"statement"` InputExplain string `json:"input_explain"` OutputExplain string `json:"output_explain"` Examples []Example `json:"examples"` TestCases []TestCase `json:"test_cases"` RelatedTopics []string `json:"related_topics"` }
Click to show internal directories.
Click to hide internal directories.