()
| 18 | } |
| 19 | |
| 20 | func (this *SubmitController) Post() { |
| 21 | uid := this.Member.MemberId |
| 22 | if uid <= 0 { |
| 23 | this.JsonResult(1, "请先登录") |
| 24 | } |
| 25 | |
| 26 | form := &models.SubmitBooks{} |
| 27 | err := this.ParseForm(form) |
| 28 | if err != nil { |
| 29 | beego.Error(err.Error()) |
| 30 | this.JsonResult(1, "数据解析失败") |
| 31 | } |
| 32 | |
| 33 | lowerURL := strings.ToLower(form.Url) |
| 34 | if !(strings.HasPrefix(lowerURL, "https://") || strings.HasPrefix(lowerURL, "http://")) { |
| 35 | this.JsonResult(1, "URL链接地址格式不正确") |
| 36 | } |
| 37 | |
| 38 | if form.Url == "" || form.Title == "" { |
| 39 | this.JsonResult(1, "请填写必填项") |
| 40 | } |
| 41 | form.Uid = uid |
| 42 | if err = form.Add(); err != nil { |
| 43 | this.JsonResult(1, err.Error()) |
| 44 | } |
| 45 | this.JsonResult(0, "提交成功,感谢您的分享。") |
| 46 | } |
no test coverage detected