MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Post

Method Post

controllers/SubmitController.go:20–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20func (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}

Callers 4

GetBookWXACodeFunction · 0.80
GetGithubAccessTokenFunction · 0.80
GetGiteeAccessTokenFunction · 0.80
postMethod · 0.80

Calls 2

AddMethod · 0.95
JsonResultMethod · 0.80

Tested by

no test coverage detected