func (c *ArticleController) CreateArticle() {

	user := c.GetSession("user")
	if nil == user {
		c.Redirect("/users/login", 200)
	}

	userId := c.CurrentUserId()
	content := c.GetString("content")
	title := c.GetString("title")
	tag := c.GetString("tag")
	categories := c.GetString("category")

	beego.Debug("title", title, "categories", categories, "tag", tag, "content", content)

	article := entities.Article{UserId: userId, Title: title, Content: content, CreatedAt: time.Now()}
	err, valid := services.ValidArticle(article)
	if valid {
		prt := &article
		prt.SetCategories(categories)
		prt.SetTags(tag)
		err = services.SaveArticle(&article)
	}

	if nil == err {
		c.Redirect("../", 302)
	} else {
		beego.Error(err)
		c.StringError(err.Error())
		c.Data["article"] = article
		c.SetCategories(article.UserId)
		c.TplName = "article_create.html"
	}

}
func TestSave(t *testing.T) {
	article := entities.Article{UserId: 1, Title: "title", Tags: "go,reis", Categories: "go3,go4", Content: "content", CreatedAt: time.Now()}
	services.SaveArticle(&article)
	db := db.NewDB()
	db.Insert(&article)

	fmt.Println("&article:", &article)
}