1 Star 0 Fork 1.2K

LC/BookStack

forked from 进击的皇虫/BookStack 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SubmitController.go 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
TruthHun 提交于 2019-07-12 23:49 +08:00 . 审核机制
package controllers
import (
"strings"
"github.com/TruthHun/BookStack/models"
"github.com/astaxie/beego"
)
type SubmitController struct {
BaseController
}
func (this *SubmitController) Index() {
this.Data["SeoTitle"] = "开源书籍和文档收录"
this.Data["IsSubmit"] = true
this.TplName = "submit/index.html"
}
func (this *SubmitController) Post() {
uid := this.Member.MemberId
if uid <= 0 {
this.JsonResult(1, "请先登录")
}
form := &models.SubmitBooks{}
err := this.ParseForm(form)
if err != nil {
beego.Error(err.Error())
this.JsonResult(1, "数据解析失败")
}
lowerURL := strings.ToLower(form.Url)
if !(strings.HasPrefix(lowerURL, "https://") || strings.HasPrefix(lowerURL, "http://")) {
this.JsonResult(1, "URL链接地址格式不正确")
}
if form.Url == "" || form.Title == "" {
this.JsonResult(1, "请填写必填项")
}
form.Uid = uid
if err = form.Add(); err != nil {
this.JsonResult(1, err.Error())
}
this.JsonResult(0, "提交成功,感谢您的分享。")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/tinyLC/BookStack.git
git@gitee.com:tinyLC/BookStack.git
tinyLC
BookStack
BookStack
master

搜索帮助