func (this *ProblemAddController) Post() { title := this.GetString("title") description := this.GetString("description") ptype := this.GetString("type") precode := this.GetString("precode") input := this.GetString("input") output := this.GetString("output") tags := this.GetString("tags") tags = utils.TagsCheck(tags) email := this.GetString("email") // decode iodata _, iodata, _ := utils.DecodeIoData(input, output) // decode description description = utils.Markdown2HTML(description) // store into database pro := models.Problem{} id, err := pro.AddProblem(title, ptype, description, precode, iodata, tags) if err != nil { this.Data["json"] = map[string]interface{}{ "result": false, "msg": "add problem failed", "refer": nil, "title": title, "description": description, "ptype": ptype, "precode": precode, "input": input, "output": output, "email": email, "debug": err, } } else { this.Data["json"] = map[string]interface{}{ "result": true, "msg": "add problem success", "refer": nil, "id": id, "title": title, "description": description, "ptype": ptype, "precode": precode, "input": input, "output": output, "email": email, } } this.ServeJson() }
func (this *MarkdownController) Post() { content := this.GetString("content") log.Blueln(content) rst := utils.Markdown2HTML(content) this.Data["json"] = map[string]interface{}{ "result": true, "msg": "success", "preview": rst, "refer": nil, } this.ServeJson() }