Beispiel #1
0
func (this *GGController) Add() {
	if !this.prefixCheck() {
		return
	}
	id, err := models.NewGgOption().Insert(models.NewGg(this.Title, this.Desc, this.Class, this.Date))
	if err != nil {
		this.error("err")
		return
	}
	this.success(map[string]interface{}{"id": id})
}
Beispiel #2
0
func (this *GGController) Delete() {
	if !this.prefixCheck() {
		return
	}
	id, _ := this.GetInt("id")
	err := models.NewGgOption().Delete(id)
	if err != nil {
		this.error("err")
		return
	}
	this.success("ok")
}
Beispiel #3
0
func (this *GGController) Update() {
	if !this.prefixCheck() {
		return
	}
	ggOption := models.NewGgOption()
	id, _ := this.GetInt("id")
	gg, err := ggOption.Read(id)
	if err != nil {
		this.error("err")
		return
	}
	gg.Title = this.Title
	gg.Desc = this.Desc
	gg.Class = this.Class
	gg.Date = this.Date
	_, err = ggOption.Update(gg)
	if err != nil {
		this.error("err")
		return
	}
	this.success("ok")
}
Beispiel #4
0
func (this *GGController) Ajax() {
	offset, _ := this.GetInt("offset")
	gg := models.NewGgOption().ReadMore(offset, PAGENUM)
	this.success(gg)
}