Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ArticleVerifying 审核中 ArticleVerifying = 1 // ArticleVerifySuccess 审核通过 ArticleVerifySuccess = 2 // ArticleVerifyFail 审核未通过 ArticleVerifyFail = 3 )
View Source
const ( // CollectSourceArticle 对话题进行收藏 CollectSourceArticle = "collect_source_article" // CollectSourceVote 对投票进行收藏 CollectSourceVote = "collect_source_vote" )
View Source
const ( // CommentSourceArticle 对话题进行评论 CommentSourceArticle = "article" // CommentSourceVote 对投票进行评论 CommentSourceVote = "vote" )
View Source
const ( // CommentVerifying 审核中 CommentVerifying = 1 // CommentVerifySuccess 审核通过 CommentVerifySuccess = 2 // CommentVerifyFail 审核未通过 CommentVerifyFail = 3 )
View Source
const ( // NoParent 无父结点时的parent_id NoParent = 0 // MaxOrder 最大的排序号 MaxOrder = 10000 // MinOrder 最小的排序号 MinOrder = 0 // PageSize 默认每页的条数 PageSize = 20 // MaxPageSize 每页最大的条数 MaxPageSize = 100 // MinPageSize 每页最小的条数 MinPageSize = 5 // MaxNameLen 最大的名称长度 MaxNameLen = 100 // MaxContentLen 最大的内容长度 MaxContentLen = 50000 )
通用常量
View Source
const ( // ArticleScore 创建话题时增加的积分 ArticleScore = 5 // ByCommentScore 话题或投票被评论时增加的积分 ByCommentScore = 2 // ByCollectScore 话题或投票被收藏时增加的积分 ByCollectScore = 2 // CommentScore 评论话题或投票时增加的积分 CommentScore = 1 // CollectScore 收藏话题或投票时增加的积分 CollectScore = 1 )
积分相关常量
View Source
const ( // ActiveTime 生成激活账号的链接 ActiveTime = "activeTime" // ResetTime 生成重置密码的链接 ResetTime = "resetTime" )
redis相关常量, 为了防止从redis中存取数据时key混乱了,在此集中定义常量来作为各key的名字
View Source
const ( // DevelopmentMode 开发模式 DevelopmentMode = "development" // TestMode 测试模式 TestMode = "test" // ProductionMode 产品模式 ProductionMode = "production" )
View Source
const ( // MessageTypeComment 有人评论了文章 MessageTypeComment = 1 // MessageTypeInvite 有人邀请回答 MessageTypeInvite = 2 )
View Source
const ( // UpTypeArticle 为文章点赞 UpTypeArticle = 1 // UpTypeComment 为评论点赞 UpTypeComment = 2 )
View Source
const ( // UserRoleNormal 普通用户 UserRoleNormal = 1 // UserRoleEditor 网站编辑 UserRoleEditor = 2 // UserRoleAdmin 管理员 UserRoleAdmin = 3 // UserRoleSuperAdmin 超级管理员 UserRoleSuperAdmin = 4 )
View Source
const ( // UserStatusInActive 未激活 UserStatusInActive = 1 // UserStatusActived 已激活 UserStatusActived = 2 // UserStatusFrozen 已冻结 UserStatusFrozen = 3 )
View Source
const ( // UserSexMale 男 UserSexMale = 0 // UserSexFemale 女 UserSexFemale = 1 // MaxUserNameLen 用户名的最大长度 MaxUserNameLen = 20 // MinUserNameLen 用户名的最小长度 MinUserNameLen = 4 // MaxPassLen 密码的最大长度 MaxPassLen = 20 // MinPassLen 密码的最小长度 MinPassLen = 6 // MaxSignatureLen 个性签名最大长度 MaxSignatureLen = 200 // MaxLocationLen 居住地的最大长度 MaxLocationLen = 200 // MaxIntroduceLen 个人简介的最大长度 MaxIntroduceLen = 500 )
View Source
const ( // VoteUnderway 进行中 VoteUnderway = 1 // VoteOver 已结束 VoteOver = 2 )
View Source
const MaxArticleCateCount = 6
MaxArticleCateCount 文章最多属于几个分类
View Source
const MaxCareerCompanyLen = 200
MaxCareerCompanyLen 公司或组织名称的最大长度
View Source
const MaxCareerTitleLen = 200
MaxCareerTitleLen 职位的最大长度
View Source
const MaxCommentLen = 5000
MaxCommentLen 最大的评论长度
View Source
const MaxFolderCount = 20
MaxFolderCount 最多能创建的收藏夹个数
View Source
const MaxSchoolNameLen = 200
MaxSchoolNameLen 学校或教育机构名的最大长度
View Source
const MaxSchoolSpecialityLen = 200
MaxSchoolSpecialityLen 专业的最大长度
View Source
const MaxTopArticleCount = 4
MaxTopArticleCount 最多能置顶的文章数
Variables ¶
View Source
var DB *gorm.DB
DB 数据库连接
View Source
var ErrorCode = errorCode{
SUCCESS: 0,
ERROR: 1,
NotFound: 404,
LoginError: 1000,
LoginTimeout: 1001,
InActive: 1002,
}
ErrorCode �错误码
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Name string `json:"name"` BrowseCount uint `json:"browseCount"` CommentCount uint `json:"commentCount"` CollectCount uint `json:"collectCount"` Status int `json:"status"` Content string `json:"content"` Categories []Category `gorm:"many2many:article_category;ForeignKey:ID;AssociationForeignKey:ID" json:"categories"` Comments []Comment `gorm:"ForeignKey:SourceID" json:"comments"` UserID uint `json:"userID"` User User `json:"user"` LastUserID uint `json:"lastUserID"` //最后一个回复话题、收藏话题、赞同话题的人 LastUser User `gorm:"AssociationForeignKey:LastUserID" json:"lastUser"` }
Article 文章, 也称话题
type Career ¶
type Career struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Company string `json:"company"` //公司或组织 Title string `json:"title"` //职位 UserID uint `json:"userID"` }
Career 职业生涯
type Category ¶
type Category struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Name string `json:"name"` Sequence int `json:"sequence"` //同级别的分类可根据sequence的值来排序 ParentID int `json:"parentId"` //直接父分类的ID }
Category 话题的分类
type Collect ¶
type Collect struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` UserID uint `json:"userID"` SourceName string `json:"sourceName"` //用来区分是对话题,还是对投票进行评论 SourceID uint `json:"sourceID"` //话题或投票的ID FolderID uint `json:"folderID"` //收藏到哪个收藏夹 Folder Folder `json:"folder"` }
Collect 收藏
type Comment ¶
type Comment struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Status int `json:"status"` Content string `json:"content"` ParentID uint `json:"parentID"` //直接父评论的ID Parents []Comment `json:"parents"` //所有的父评论 SourceName string `json:"sourceName"` //用来区分是对话题,还是对投票进行评论 SourceID uint `json:"sourceID"` //话题或投票的ID UserID uint `json:"userID"` User User `json:"user"` }
Comment 评论, 也称回复
type Folder ¶
type Folder struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Name string `json:"name"` UserID uint `json:"userID"` ParentID uint `json:"parentID"` }
Folder 收藏夹
type Image ¶
type Image struct { ID uint `gorm:"primary_key" json:"id"` Title string `json:"title"` OrignalTitle string `json:"orignalTitle"` URL string `json:"url"` Width uint `json:"width"` Height uint `json:"height"` Mime string `json:"mime"` }
Image 图片
type Message ¶
type Message struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Type int `json:"type"` HasRead bool `json:"hasRead"` ArticleID int `json:"articleID"` UserID int `json:"userID"` FromUserID int `json:"fromUserID"` ChatID int `json:"chatID"` CommentID int `json:"commentID"` }
Message 消息
type School ¶
type School struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Name string `json:"name"` Speciality string `json:"speciality"` //专业 UserID uint `json:"userID"` }
School 学校(教育经历)
type TopArticle ¶
type TopArticle struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` ArticleID uint `json:"articleID"` }
TopArticle 置顶的文章
type Up ¶
type Up struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` TargetID uint `json:"targetID"` Type int `json:"type"` UserID uint `json:"userID"` User User `json:"user"` }
Up 点赞
type User ¶
type User struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Name string `json:"name"` Pass string `json:"-"` Email string `json:"-"` Sex uint `json:"sex"` Location string `json:"location"` Introduce string `json:"introduce"` Phone string `json:"-"` Score uint `json:"score"` ArticleCount uint `json:"articleCount"` CommentCount uint `json:"commentCount"` CollectCount uint `json:"collectCount"` Signature string `json:"signature"` //个人签名 Role int `json:"role"` //角色 AvatarURL string `json:"avatarURL"` //头像 CoverURL string `json:"coverURL"` //个人主页背景图片URL Status int `json:"status"` Schools []School `json:"schools"` //教育经历 Careers []Career `json:"careers"` //职业经历 }
User 用户
func (User) CheckPassword ¶
CheckPassword 验证密码是否正确
func (User) EncryptPassword ¶
EncryptPassword 给密码加密
type UserVote ¶
type UserVote struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` UserID uint `json:"userID"` User User `json:"user"` VoteID uint `json:"voteID"` VoteItemID uint `json:"voteItemID"` }
UserVote 用户对哪个投票项进行了投票
type Vote ¶
type Vote struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` EndAt time.Time `json:"endAt"` Name string `json:"name"` BrowseCount int `json:"browseCount"` CommentCount int `json:"commentCount"` CollectCount int `json:"collectCount"` Status int `json:"status"` Content string `json:"content"` Comments []Comment `gorm:"ForeignKey:SourceID" json:"comments"` UserID uint `json:"userID"` User User `json:"user"` LastUserID uint `json:"lastUserID"` //最后一个回复投票、收藏投票、参与投票的人 LastUser User `gorm:"AssociationForeignKey:LastUserID" json:"lastUser"` VoteItems []VoteItem `json:"voteItems"` }
Vote 投票
type VoteItem ¶
type VoteItem struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Name string `json:"name"` Count uint `json:"count"` VoteID uint `json:"voteID"` }
VoteItem 投票项, 一个投票有多个投票项,用户选择投票项进行投票
Click to show internal directories.
Click to hide internal directories.