problem

package
v0.0.0-...-9f3f5e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoProblem = errors.New("mongo: no problem in result")

Functions

func Init

func Init(sm *http.ServeMux, l *log.Logger, mongo *db.Mongo)

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 (*Controller) Get

func (*Controller) Gets

func (*Controller) Post

func (*Controller) Put

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 Example

type Example struct {
	Input       string `bson:"input" json:"input"`
	Output      string `bson:"output" json:"output"`
	Explanation string `bson:"explanation" json:"explanation"`
}

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 (*Handler) ExtractId

func (h *Handler) ExtractId(w http.ResponseWriter, r *http.Request) int

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Hint

type Hint struct {
	HintNumber int    `bson:"hint_number" json:"hint_number"`
	Message    string `bson:"message" json:"message"`
}

type M

type M map[string]interface{}

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 NewRepo

func NewRepo(l *log.Logger, mongo *db.Mongo, collName string) *Repository

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)

func (*Repository) ReadBy

func (r *Repository) ReadBy(problemNumber int) (*Problem, error)

func (*Repository) Update

func (r *Repository) Update(p *Problem) (*Problem, error)

type TestCase

type TestCase struct {
	Input  string `bson:"input" json:"input"`
	Answer string `bson:"answer" json:"answer"`
}

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL