MCPcopy Index your code
hub / github.com/TruthHun/DocHub / Edit

Method Edit

controllers/AdminControllers/SingleController.go:23–53  ·  view source on GitHub ↗

单页编辑,只编辑文本内容

()

Source from the content-addressed store, hash-verified

21
22//单页编辑,只编辑文本内容
23func (this *SingleController) Edit() {
24 var (
25 page models.Pages
26 cs *models.CloudStore
27 err error
28 )
29
30 cs, err = models.NewCloudStore(false)
31 if err != nil {
32 this.CustomAbort(http.StatusInternalServerError, err.Error())
33 }
34
35 this.Data["IsSingle"] = true
36 alias := this.GetString(":alias")
37
38 if this.Ctx.Request.Method == "POST" {
39 this.ParseForm(&page)
40 page.TimeCreate = int(time.Now().Unix())
41 page.Content = cs.ImageWithoutDomain(page.Content)
42 _, err := orm.NewOrm().Update(&page)
43 if err != nil {
44 this.ResponseJson(false, err.Error())
45 }
46 this.ResponseJson(true, "更新成功")
47 } else {
48 page, _ = models.NewPages().One(alias)
49 page.Content = cs.ImageWithDomain(page.Content)
50 this.Data["Data"] = page
51 this.TplName = "edit.html"
52 }
53}
54
55//删除单页
56func (this *SingleController) Del() {

Callers

nothing calls this directly

Calls 6

ParseFormMethod · 0.80
ImageWithoutDomainMethod · 0.80
UpdateMethod · 0.80
OneMethod · 0.80
ImageWithDomainMethod · 0.80
ResponseJsonMethod · 0.45

Tested by

no test coverage detected