// 通过noteId得到notebookId // shareService call // [ok] func (this *NoteService) GetNotebookId(noteId string) bson.ObjectId { note := info.Note{} // db.Get(db.Notes, noteId, ¬e) // LogJ(note) db.GetByQWithFields(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, []string{"NotebookId"}, ¬e) return note.NotebookId }
func (this *ThemeService) GetThemePath(userId, themeId string) string { theme := info.Theme{} db.GetByQWithFields(db.Themes, bson.M{"_id": bson.ObjectIdHex(themeId), "UserId": bson.ObjectIdHex(userId)}, []string{"Path"}, &theme) if theme.Path != "" { return theme.Path } return "" }
// 自增Usn // 每次notebook,note添加, 修改, 删除, 都要修改 func (this *UserService) IncrUsn(userId string) int { user := info.User{} query := bson.M{"_id": bson.ObjectIdHex(userId)} db.GetByQWithFields(db.Users, query, []string{"Usn"}, &user) usn := user.Usn usn += 1 Log("inc Usn") db.UpdateByQField(db.Users, query, "Usn", usn) return usn // return db.Update(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, bson.M{"$inc": bson.M{"ReadNum": 1}}) }
// 判断是否是blog func (this *NotebookService) IsBlog(notebookId string) bool { notebook := info.Notebook{} db.GetByQWithFields(db.Notebooks, bson.M{"_id": bson.ObjectIdHex(notebookId)}, []string{"IsBlog"}, ¬ebook) return notebook.IsBlog }
// 得到用户名 func (this *UserService) GetUsername(userId string) string { user := info.User{} db.GetByQWithFields(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, []string{"Username"}, &user) return user.Username }
func (this *UserService) GetUsn(userId string) int { user := info.User{} query := bson.M{"_id": bson.ObjectIdHex(userId)} db.GetByQWithFields(db.Users, query, []string{"Usn"}, &user) return user.Usn }