Exemplo n.º 1
0
func (u *ArticleModel) New(userId int64, title string, body []byte) (string, error) {
	cid := util.Unique()
	vo := NewArticleVO(userId, title, body)

	vo.Cid = cid
	vo.Html = blackfriday.MarkdownCommon(body)

	reg, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
	vo.Description = reg.ReplaceAll(vo.Html, []byte(""))

	_, err := db.NewInsertBuilder(u.Table()).Insert(vo)
	if err != nil {
		return cid, err
	}

	return cid, err
}
Exemplo n.º 2
0
func UserToken(nick string, pwd []byte) (string, string) {
	salt := util.Unique()
	return salt, gos.UserToken([]interface{}{nick}, pwd, []byte(salt))
}