Files
leanote/app/info/TagInfo.go

57 lines
1.5 KiB
Go
Raw Permalink Normal View History

2014-05-07 13:06:24 +08:00
package info
import (
"gopkg.in/mgo.v2/bson"
2015-03-31 14:27:26 +08:00
"time"
2014-05-07 13:06:24 +08:00
)
// 这里主要是为了统计每个tag的note数目
2014-11-10 23:56:15 +08:00
// 暂时没用
/*
2014-05-07 13:06:24 +08:00
type TagNote struct {
TagId bson.ObjectId `bson:"_id,omitempty"` // 必须要设置bson:"_id" 不然mgo不会认为是主键
UserId bson.ObjectId `bson:"UserId"`
Tag string `Title` // 标题
NoteNum int `NoteNum` // note数目
}
2014-11-10 23:56:15 +08:00
*/
2014-05-07 13:06:24 +08:00
// 每个用户一条记录, 存储用户的所有tags
type Tag struct {
2015-11-13 17:58:41 +08:00
UserId bson.ObjectId `bson:"_id"`
Tags []string `Tags`
2014-11-10 23:56:15 +08:00
}
2015-03-31 14:27:26 +08:00
// v2 版标签
type NoteTag struct {
2015-11-13 17:58:41 +08:00
TagId bson.ObjectId `bson:"_id"`
UserId bson.ObjectId `UserId` // 谁的
Tag string `Tag` // UserId, Tag是唯一索引
Usn int `Usn` // Update Sequence Number
Count int `Count` // 笔记数
CreatedTime time.Time `CreatedTime`
UpdatedTime time.Time `UpdatedTime`
IsDeleted bool `IsDeleted` // 删除位
2015-03-31 14:27:26 +08:00
}
2014-11-10 23:56:15 +08:00
type TagCount struct {
TagCountId bson.ObjectId `bson:"_id,omitempty"`
2015-11-13 17:58:41 +08:00
UserId bson.ObjectId `UserId` // 谁的
Tag string `Tag`
IsBlog bool `IsBlog` // 是否是博客的tag统计
Count int `Count` // 统计数量
2014-11-10 23:56:15 +08:00
}
2015-03-31 14:27:26 +08:00
2014-11-10 23:56:15 +08:00
/*
type TagsCounts []TagCount
func (this TagsCounts) Len() int {
return len(this)
}
func (this TagsCounts) Less(i, j int) bool {
return this[i].Count > this[j].Count
}
func (this TagsCounts) Swap(i, j int) {
this[i], this[j] = this[j], this[i]
}
2015-03-31 14:27:26 +08:00
*/