示例#1
0
文件: ads.go 项目: hogenwang/comcms
//删除广告
func (c *AdsController) DoDel() {
	CheckAdminLogin(&c.Controller, 1)
	id, _ := strconv.ParseInt(c.GetString("id"), 10, 64)
	tip := &models.TipJSON{}
	tip.Status = models.TipError
	if id <= 0 {
		tip.Message = "错误参数传递!"
		EchoTip(&c.Controller, tip)
	}
	entity := models.GetAds(id)
	if entity == nil {
		tip.Message = "系统找不到本记录!"
		EchoTip(&c.Controller, tip)
	} else {
		if err := models.DelAds(entity); err != nil {
			tip.Message = "删除出错:" + err.Error()
			EchoTip(&c.Controller, tip)
		} else {
			tip.Status = models.TipSuccess
			tip.Message = "删除成功!"
			tip.ReturnUrl = "/admin/link"
			EchoTip(&c.Controller, tip)
		}
	}
}
示例#2
0
文件: ads.go 项目: hogenwang/comcms
//编辑广告页面
func (c *AdsController) Edit() {
	CheckAdminLogin(&c.Controller, 0)

	myid := c.Ctx.Input.Param(":id")
	id, err := strconv.ParseInt(myid, 10, 64)
	if err != nil {
		EchoErrorPage(&c.Controller, "错误参数传递!", "/admin/ads")
	}
	entity := models.GetAds(id)
	if entity == nil {
		EchoErrorPage(&c.Controller, "系统找不到本记录!", "/admin/ads")
	}
	c.Data["Title"] = "修改广告"
	c.Data["Action"] = "edit"
	c.Data["Entity"] = entity
	c.TplNames = "admin/ads_add.tpl"
}
示例#3
0
文件: ads.go 项目: hogenwang/comcms
//执行修改广告
func (c *AdsController) DoEdit() {
	CheckAdminLogin(&c.Controller, 1)
	tip := &models.TipJSON{}
	tip.Status = models.TipError

	id, err := c.GetInt64("Id")
	if err != nil {
		tip.Message = "错误参数传递!"
		EchoTip(&c.Controller, tip)
	}
	entity := models.GetAds(id)
	if entity == nil {
		tip.Message = "系统找不到本记录!"
		EchoTip(&c.Controller, tip)
	}
	entity.Title = c.GetString("Title")
	if entity.Title == "" {
		tip.Message = "标题不能为空!"
		EchoTip(&c.Controller, tip)
	}
	entity.Rank, _ = strconv.ParseInt(c.GetString("Rank"), 10, 64)
	entity.Description = c.GetString("Description")
	if c.GetString("IsHide") == "1" {
		entity.IsHide = 1
	} else {
		entity.IsHide = 0
	}
	entity.Tid, _ = strconv.ParseInt(c.GetString("Tid"), 10, 64)
	content := GetAdsDetail(&c.Controller)
	entity.Content = content

	if id, err := models.EditAds(entity); id > 0 && err == nil {
		//修改成功
		tip.Status = models.TipSuccess
		tip.Id = id
		tip.ReturnUrl = "/admin/ads"
		tip.Message = "广告修改成功"
	} else {
		tip.Id = id
		tip.Message = "修改广告失败:" + err.Error()
	}
	EchoTip(&c.Controller, tip)
}