Documentation
¶
Index ¶
- Constants
- Variables
- func AddRoles(a *Account, roles ...Erole)
- func IsTimeValid(time2 time.Time) (valid bool)
- type AccessManager
- type Account
- type AddAccount
- type AddAccountRole
- type Blog
- type Comment
- type DeleteAccount
- type Directory
- func (c *Directory) Init()
- func (c *Directory) InitWithName(name string)
- func (c *Directory) InitWithNameAndParent(name string, parentId primitive.ObjectID)
- func (c *Directory) IsValid() (valid bool)
- func (c *Directory) UpdateName(name string)
- func (c *Directory) UpdateParent(parent Directory)
- func (c *Directory) UpdateParentId(id primitive.ObjectID)
- type DirectoryInfo
- type Entity
- type Erole
- type Filter
- type Group
- type LoginAccount
- type Praiseable
- type Project
- type RecycleItem
- type Subcomment
- type VerifyEmail
Constants ¶
View Source
const ( Token = "token" Avatar = "avatar" IsActive = "isActive" True = "true" False = "false" )
User info consts
View Source
const ( HandlerDraft = "draft" HandlerBlog = "blog" )
最好与collection名称保持一致!
Variables ¶
View Source
var ( ErrNameInvalid = errors.New("name is empty") ErrEmailInvalid = errors.New("email is empty") ErrPasswordInvalid = errors.New("password is invalid") )
example
View Source
var IndexModels = []mongo.IndexModel{ {Keys: bson.M{"entity_info.create_time": -1}}, {Keys: bson.M{"entity_info.update_time": -1}}, {Keys: bson.M{"entity_info.isdeleted": 1}}, }
IndexModels Index Models to index entity
Functions ¶
Types ¶
type AccessManager ¶
type Account ¶
type Account struct { ID primitive.ObjectID `json:"id,omitempty" example:"xxxxxxxxxxxxx==" bson:"_id,omitempty"` UserName string `json:"userName" example:"account name" bson:"username,omitempty"` Email string `json:"email" example:"email@qq.com" bson:"email,omitempty"` HashedPwd string `json:"hashedPassword" example:"$2a$10$rXMPcOyfgdU6y5n3pkYQAukc3avJE9CLsx1v0Kn99GKV1NpREvN2i" bson:"hashedpwd,omitempty"` EntityInfo Entity `json:"entityInfo,omitempty" bson:"entity_info,omitempty"` Roles []Erole `json:"roles" bson:"roles"` Infos map[string]string `json:"infos" example:"'token': 'xxxxxxxx'(private data)" bson:"infos,omitempty"` Settings map[string]string `` /* 127-byte string literal not displayed */ }
Account example
type AddAccount ¶
type AddAccount struct { UserName string `json:"userName" example:"account name"` Email string `json:"email" example:"email@mo2.com"` Password string `json:"password" example:"p@ssword"` }
AddAccount example
type AddAccountRole ¶
type AddAccountRole struct { ID primitive.ObjectID `json:"id" example:"xxxxxxxxxxxxx==" ` Roles []Erole `json:"roles"` SuperKey string `json:"super_key" example:"special"` }
AddAccountRole example
type Blog ¶
type Blog struct { ID primitive.ObjectID `json:"id,omitempty" example:"xxxxxxxxxxxxx==" bson:"_id,omitempty"` AuthorID primitive.ObjectID `json:"authorId,omitempty" example:"xxxxxxxxxxxxx==" bson:"author_id"` Title string `json:"title,omitempty" example:"mouse ❤ monkey" bson:"title,omitempty"` Description string `json:"description,omitempty" example:"mouse ❤ monkey" bson:"description,omitempty"` Content string `json:"content,omitempty" example:"xxxx\nxxxx" bson:"content,omitempty"` EntityInfo Entity `json:"entityInfo,omitempty" bson:"entity_info,omitempty"` Cover string `json:"cover,omitempty" example:"https://xxx/xxx" bson:"cover,omitempty"` KeyWords []string `json:"keyWords,omitempty" example:"xxx,xxx" bson:"key_words,omitempty"` CategoryIDs []primitive.ObjectID `json:"categories,omitempty" bson:"categories,omitempty"` YDoc string `json:"y_doc,omitempty" bson:"y_doc,omitempty"` // 用于collaboration IsYDoc bool `json:"is_y_doc,omitempty" bson:"is_y_doc,omitempty"` // 用于collaboration YToken primitive.ObjectID `json:"y_token,omitempty" bson:"y_token,omitempty"` //用于collaboration ScoreSum float64 `json:"score_sum" bson:"score_sum,omitempty"` ScoreNum int `json:"score_num" bson:"score_num,omitempty"` ProjectID primitive.ObjectID `json:"project_id" bson:"project_id"` CoAuthorIDs []primitive.ObjectID `json:"coauthors,omitempty" bson:"coauthors"` }
Blog example 若修改字段,需注意依赖此model的使用地方 important: dto.QueryBlog UpsertBlog()
func (*Blog) Add2Categories ¶
func (*Blog) Add2Category ¶
type Comment ¶
type Comment struct { ID primitive.ObjectID `json:"id,omitempty" example:"xxxxxxxxxxxxxx==" bson:"_id,omitempty"` Content string `json:"content,omitempty" example:"a comment" bson:"content,omitempty"` EntityInfo Entity `json:"entity_info,omitempty" bson:"entity_info,omitempty"` Praise Praiseable `json:"praise,omitempty" bson:"praise,omitempty"` Author primitive.ObjectID `json:"aurhor,omitempty" bson:"aurhor,omitempty"` Article primitive.ObjectID `json:"article,omitempty" bson:"article,omitempty"` Subs []Subcomment `json:"subs" bson:"subs"` }
Comment a comment
type DeleteAccount ¶
type DeleteAccount struct { Email string `json:"email" example:"email@mo2.com"` Password string `json:"password" example:"p@ssword"` }
DeleteAccount example
type Directory ¶
type Directory struct { ID primitive.ObjectID `json:"id,omitempty" example:"xxxxxxxxxxxxxx==" bson:"_id,omitempty"` ParentID primitive.ObjectID `json:"parent_id,omitempty" example:"xxxxxxxxxxxxxx==" bson:"parent_id,omitempty"` Name string `json:"name,omitempty" example:"records" bson:"name,omitempty"` Info DirectoryInfo `json:"info,omitempty" bson:"info,omitempty"` OwnerIDs []primitive.ObjectID `json:"owner_ids" bson:"owner_ids,omitempty"` }
Directory 归档
func (*Directory) InitWithName ¶
func (*Directory) InitWithNameAndParent ¶
func (*Directory) UpdateName ¶
func (*Directory) UpdateParent ¶
UpdateParent 以父目录更新当前目录
func (*Directory) UpdateParentId ¶
type DirectoryInfo ¶
type DirectoryInfo struct { Description string `json:"description,omitempty" example:"course materials" bson:"description,omitempty"` Cover string `json:"cover,omitempty" example:"https://www.motwo.cn/cover" bson:"cover,omitempty"` }
DirectoryInfo 归档信息
type Entity ¶
type Entity struct { CreateTime time.Time `json:"createTime" example:"2020-10-1" bson:"create_time,omitempty"` UpdateTime time.Time `json:"updateTime" example:"2020-10-1" bson:"update_time,omitempty"` IsDeleted bool `json:"is_deleted,omitempty" example:"true" bson:"isdeleted"` }
Entity example
type Group ¶
type Group struct { ID primitive.ObjectID `json:"id" bson:"id"` OwnerID primitive.ObjectID `json:"owner_id" bson:"owner_id"` AccessManager AccessManager `json:"access_manager,omitempty" bson:"access_manager,omitempty"` }
type LoginAccount ¶
type LoginAccount struct { UserNameOrEmail string `json:"userNameOrEmail" example:"account name/email@mo2.com"` Password string `json:"password" example:"p@ssword"` }
LoginAccount example
func (LoginAccount) Validation ¶
func (a LoginAccount) Validation() error
Validation is for LoginAccount Validation
type Praiseable ¶
type Praiseable struct { Up uint64 `json:"up" bson:"up"` Down uint64 `json:"down" bson:"down"` Weighted uint64 `json:"weighted" bson:"weighted"` }
Praiseable 可被点赞的
type Project ¶
type Project struct { ID primitive.ObjectID `bson:"_id,omitempty"` Name string `bson:"name"` Tags []string `bson:"tags"` OwnerID primitive.ObjectID `bson:"owner_id"` ManagerIDs []primitive.ObjectID `bson:"manager_i_ds"` MemberIDs []primitive.ObjectID `bson:"member_i_ds"` BlogIDs []primitive.ObjectID `bson:"blog_i_ds"` Description string `bson:"description"` Avatar string `bson:"avatar"` EntityInfo Entity `bson:"entity_info"` }
type RecycleItem ¶
type RecycleItem struct { ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` ItemID primitive.ObjectID `json:"item_id,omitempty" bson:"item_id,omitempty"` CreateTime time.Time `json:"create_time,omitempty" example:"2020-10-1" bson:"create_time,omitempty"` DeleteTime time.Time `json:"delete_time,omitempty" example:"2020-10-1" bson:"delete_time,omitempty"` Handler string `json:"handler,omitempty" example:"blog" bson:"handler,omitempty"` }
RecycleItem 回收站中的对象信息,记录加入回收站时间和预计被删除时间,以及处理函数
type Subcomment ¶
type Subcomment struct { ID primitive.ObjectID `json:"id,omitempty" example:"xxxxxxxxxxxxxx==" bson:"_id,omitempty"` Content string `json:"content,omitempty" example:"a comment" bson:"content,omitempty"` Aurhor primitive.ObjectID `json:"aurhor,omitempty" bson:"aurhor,omitempty"` EntityInfo Entity `json:"entity_info,omitempty" bson:"entity_info,omitempty"` Praise Praiseable `json:"praise,omitempty" bson:"praise,omitempty"` }
Subcomment level 2 comment
type VerifyEmail ¶
type VerifyEmail struct { Email string `json:"Email" example:"email@mo2.com"` Token string `json:"token" example:"p@ssword"` }
VerifyEmail struct for email verify
Click to show internal directories.
Click to hide internal directories.