示例#1
0
func (c *ContentController) Get() {
	openid := getContentCookie(c)
	op := c.Input().Get("op")
	beego.Debug("get op :---------------", op)
	switch op {
	case "con":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		// id = c.Input().Get("id")
		post, err := models.GetOnePost(id)
		if err != nil {
			beego.Error(err)
		}
		beego.Debug("id :", id)
		c.Data["Id"] = id
		c.Data["Post"] = post
		beego.Debug("is con " + post.Title)
		help_num, err := models.GatPostHelpNum(id)
		c.Data["HelpNum"] = help_num
		state, err := models.GatPaseHelpState(id, openid)
		c.Data["HelpState"] = state
		c.TplName = "content.html"
		return
	}
	c.TplName = "content.html"
}
示例#2
0
func (c *ContentController) Post() {
	openid := getContentCookie(c)
	op := c.Input().Get("op")
	beego.Debug("post op :---------------", op)
	switch op {
	case "help":
		id_s := c.Input().Get("id")
		if len(openid) != 0 && len(id_s) != 0 {
			post, err := models.GetOnePost(id_s)
			if err != nil {
				beego.Error(err)
			}
			_, err = models.AddPosthelp(post.Id, openid, 1)
			if err != nil {
				beego.Error(err)
			} else {
				if post.Label == 1 {
					err = models.AddWxUserMoney(post.OpenId, 1)
					if err != nil {
						beego.Error(err)
					} else {
						_, err = models.AddUserMoneyRecord(post.OpenId, MONEY_BELIKE_SUM, MONEY_BELIKE)
					}
				}
				url := "/content?op=con&id=" + id_s
				c.Redirect(url, 302)
				return
			}
		}
		c.TplName = "content.html"
		break
	}
	c.TplName = "content.html"
}
示例#3
0
func (c *AdminContentController) Get() {
	op := c.Input().Get("op")
	switch op {
	case "con":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		id = c.Input().Get("id")
		post, err := models.GetOnePost(id)
		if err != nil {
			beego.Error(err)
		}
		c.Data["Post"] = post
		beego.Debug("is con " + post.Title)
		c.TplName = "admincontent.html"
		return
	}
	c.TplName = "admincontent.html"

}
示例#4
0
func (c *AdminModifyController) Get() {
	// beego.Debug(c.Input())
	bool, username := chackAccount(c.Ctx)
	if bool {

	} else {
		c.Redirect("/admin", 302)
		return
	}
	posts, err := models.GetAllPostsAdmin()
	if err != nil {
		beego.Error(err)
	}
	c.Data["Posts"] = posts
	c.Data["isUser"] = bool
	c.Data["User"] = username

	op := c.Input().Get("op")
	switch op {
	case "m":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		post, err := models.GetOnePost(id)
		// err := models.DeletePost(id)
		// if err != nil {
		//  beego.Error(err)
		// }
		if err != nil {
			break
		}
		c.Data["Post"] = post
		beego.Debug("is con " + post.Title)
		c.TplName = "adminmodify.html"
		return
	default:
		id := c.Input().Get("id")
		title := c.Input().Get("title")
		info := c.Input().Get("info")
		city := c.Input().Get("city")
		bfrom := c.Input().Get("bfrom")
		beego.Debug("is con " + title)
		if len(id) != 0 && len(title) != 0 && len(info) != 0 {
			b_from := false
			fromshow := ""
			fromurl := ""
			if bfrom == "on" {
				b_from = true
				fromshow = c.Input().Get("fromshow")
				fromurl = c.Input().Get("fromurl")
			}
			beego.Debug("bfrom :", bfrom)
			err := models.UpdatePostInfo(id, title, info, city, b_from, fromshow, fromurl)
			if err != nil {
				beego.Error(err)
			}
			c.Redirect("/admin", 302)
		}
		return
	}

}