예제 #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
}
예제 #2
0
파일: userauth.go 프로젝트: jiorry/gotock
func UserToken(nick string, pwd []byte) (string, string) {
	salt := util.Unique()
	return salt, gos.UserToken([]interface{}{nick}, pwd, []byte(salt))
}