func TestArticlesGyCategory(t *testing.T) { pagination := new(db.Pagination) pagination.PerPage = 10 pagination.Page = 1 services.ArticlesGyCategory(1, "bootstrap", pagination, false) for _, v := range pagination.Data { fmt.Println("id:", v.(entities.Article).Id, "title:", v.(entities.Article).Title) } }
func (c *ArticleController) ArticlesGyCategory() { category := c.GetString(":category") if len(category) > 0 { c.Data["active_category"] = category } userId := c.CurrentUserId() pagination := c.NewPagination() services.ArticlesGyCategory(userId, category, pagination, false) c.Data["pagination"] = pagination c.TplName = "index.html" }
func (c *ArticleController) ArticlesGyUserIdAndCategory() { userIdStr := c.GetString(":userId") category := c.GetString(":category") userId, _ := strconv.ParseInt(userIdStr, 10, 64) if len(category) > 0 { c.Data["active_category"] = category } pagination := c.NewPagination() services.ArticlesGyCategory(userId, category, pagination, true) c.Data["pagination"] = pagination c.SetCategories(userId) c.TplName = "user_home.html" }