Ejemplo n.º 1
0
func (this *HomeController) ArticleList() {
	cid := this.Ctx.Input.Param(":cid")
	filter := map[string]interface{}{"categoryId": cid, "keywords": ""} //初始化一个无用定义,防止filter为nil

	article := new(models.Article)
	list := article.GetList(15, 1, filter)

	this.Data["articles"] = list
	this.TplNames = "front/articlelist.tpl"
}
Ejemplo n.º 2
0
func (this *HomeController) Get() {
	filter := map[string]interface{}{"categoryId": "", "keywords": ""} //初始化一个无用定义,防止filter为nil

	article := new(models.Article)
	list := article.GetList(15, 1, filter)

	this.Data["Website"] = "gocms"
	this.Data["Email"] = "*****@*****.**"
	this.Data["articles"] = list
	this.TplNames = "front/index.tpl"
}
Ejemplo n.º 3
0
func (this *ArticleController) GetDataList() {
	var filter map[string]interface{}
	err := json.Unmarshal(this.Ctx.Input.RequestBody, &filter)
	if err != nil {
		fmt.Println(err)
	}
	pageSize, err := strconv.Atoi(filter["pageSize"].(string))
	pageNo, err := strconv.Atoi(filter["pageNo"].(string))
	result := map[string]interface{}{"totalCount": 0, "data": nil}
	article := new(models.Article)
	totalCount := article.GetCount(filter)
	list := article.GetList(pageSize, pageNo, filter)
	result["totalCount"] = totalCount
	result["data"] = list
	this.Data["json"] = result
	fmt.Println(result)
	this.ServeJson()
}