单页编辑,只编辑文本内容
()
| 21 | |
| 22 | //单页编辑,只编辑文本内容 |
| 23 | func (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 | //删除单页 |
| 56 | func (this *SingleController) Del() { |
nothing calls this directly
no test coverage detected