Example #1
0
//删除友链
func (this *LinkController) Delete() {
	id, _ := this.GetInt64("id")
	link := models.Link{Id: id}
	if link.Read() == nil {
		link.Delete()
	}
	this.Redirect("/admin/link/list", 302)
}
Example #2
0
//编辑友链
func (this *LinkController) Edit() {
	id, _ := this.GetInt64("id")
	link := models.Link{Id: id}
	if err := link.Read(); err != nil {
		this.showmsg("友链不存在")
	}

	if this.Ctx.Request.Method == "POST" {
		sitename := strings.TrimSpace(this.GetString("sitename"))
		url := strings.TrimSpace(this.GetString("url"))
		rank, _ := this.GetInt64("rank")
		link.Sitename = sitename
		link.Url = url
		link.Rank = int8(rank)
		link.Update()
		this.Redirect("/admin/link/list", 302)
	}
	this.Data["link"] = link
	this.display()
}