model

package
v0.0.0-...-2d9d122 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2018 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ArticleVerifying 审核中
	ArticleVerifying = 1

	// ArticleVerifySuccess 审核通过
	ArticleVerifySuccess = 2

	// ArticleVerifyFail 审核未通过
	ArticleVerifyFail = 3
)
View Source
const (
	// BookUnpublish 未发布
	BookUnpublish = "book_unpublish"

	// BookVerifying 审核中
	BookVerifying = "book_verifying"

	// BookVerifySuccess 审核通过
	BookVerifySuccess = "book_verify_success"

	// BookVerifyFail 审核未通过
	BookVerifyFail = "book_verify_fail"
)
View Source
const (
	// BookCommentVerifying 审核中
	BookCommentVerifying = "book_comment_verifying"

	// BookCommentVerifySuccess 审核通过
	BookCommentVerifySuccess = "book_comment_verify_success"

	// BookCommentVerifyFail 审核未通过
	BookCommentVerifyFail = "book_comment_verify_fail"
)
View Source
const (
	// BookReadLimitsPublic 公开
	BookReadLimitsPublic = "book_read_limits_public"

	// BookReadLimitsPrivate 私有
	BookReadLimitsPrivate = "book_read_limits_private"

	// BookReadLimitsPay 付费
	BookReadLimitsPay = "book_read_limits_pay"
)
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

	// MaxCategoryCount 最多可以属于几个分类
	MaxCategoryCount = 6
)

通用常量

View Source
const (
	// ArticleScore 创建话题时增加的积分
	ArticleScore = 5

	// ByCommentScore 话题或投票被评论时增加的积分
	ByCommentScore = 2

	// ByCollectScore 话题或投票被收藏时增加的积分
	ByCollectScore = 2

	// CommentScore 评论话题或投票时增加的积分
	CommentScore = 1

	// CollectScore 收藏话题或投票时增加的积分
	CollectScore = 1
)

积分相关常量

View Source
const (
	// ArticleMinuteLimitCount 用户每分钟最多能发表的文章数
	ArticleMinuteLimitCount = 30

	// ArticleDayLimitCount 用户每天最多能发表的文章数
	ArticleDayLimitCount = 1000

	// CommentMinuteLimitCount 用户每分钟最多能发表的评论数
	CommentMinuteLimitCount = 30

	// CommentDayLimitCount 用户每天最多能发表的评论数
	CommentDayLimitCount = 1000
)
View Source
const (
	// ContentTypeMarkdown markdown
	ContentTypeMarkdown = 1

	// ContentTypeHTML html
	ContentTypeHTML = 2
)
View Source
const (
	// ActiveTime 生成激活账号的链接
	ActiveTime = "activeTime"

	// ResetTime 生成重置密码的链接
	ResetTime = "resetTime"

	// LoginUser 用户信息
	LoginUser = "loginUser"

	// ArticleMinuteLimit 用户每分钟最多能发表的文章数
	ArticleMinuteLimit = "articleMinuteLimit"

	// ArticleDayLimit 用户每天最多能发表的文章数
	ArticleDayLimit = "articleDayLimit"

	// CommentMinuteLimit 用户每分钟最多能发表的评论数
	CommentMinuteLimit = "commentMinuteLimit"

	// CommentDayLimit 用户每天最多能发表的评论数
	CommentDayLimit = "commentDayLimit"
)

redis相关常量, 为了防止从redis中存取数据时key混乱了,在此集中定义常量来作为各key的名字

View Source
const (
	// ArticleFromNULL 无来源
	ArticleFromNULL = 0

	// ArticleFromJianShu 简书
	ArticleFromJianShu = 1

	// ArticleFromZhihu 知乎
	ArticleFromZhihu = 2

	// ArticleFromHuxiu 虎嗅
	ArticleFromHuxiu = 3

	// ArticleFromCustom 自定义
	ArticleFromCustom = 10
)
View Source
const (
	// CrawlerScopePage 抓取单篇文章
	CrawlerScopePage = "page"

	// CrawlerScopeList 抓取一批文章
	CrawlerScopeList = "list"
)
View Source
const (
	// DevelopmentMode 开发模式
	DevelopmentMode = "development"

	// TestMode 测试模式
	TestMode = "test"

	// ProductionMode 产品模式
	ProductionMode = "production"
)
View Source
const (
	// MessageTypeCommentArticle 回复了话题
	MessageTypeCommentArticle = "messageTypeCommentArticle"

	// MessageTypeCommentVote 回复了投票
	MessageTypeCommentVote = "messageTypeCommentVote"

	// MessageTypeCommentComment 对回复进行了回复
	MessageTypeCommentComment = "messageTypeCommentComment"
)
View Source
const (
	// UpTypeArticle 为文章点赞
	UpTypeArticle = 1

	// UpTypeComment 为评论点赞
	UpTypeComment = 2
)
View Source
const (
	// UserRoleNormal 普通用户
	UserRoleNormal = 1

	// UserRoleEditor 网站编辑
	UserRoleEditor = 2

	// UserRoleAdmin 管理员
	UserRoleAdmin = 3

	// UserRoleSuperAdmin 超级管理员
	UserRoleSuperAdmin = 4

	// UserRoleCrawler 爬虫,网站编辑或管理员登陆后台后,操作爬虫去抓取文章
	// 这时,生成的文章,其作者是爬虫账号。没有直接使用爬虫账号去登陆的情况.
	UserRoleCrawler = 5
)
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 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 �错误码

View Source
var MongoDB *mgo.Database

MongoDB 数据库连接

View Source
var RedisPool *redis.Pool

RedisPool Redis连接池

View Source
var StatsdClient *statsd.Statter

StatsdClient statsd 客户端

Functions

func UserToRedis

func UserToRedis(user User) error

UserToRedis 将用户信息存到redis

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"`
	HTMLContent   string     `json:"htmlContent"`
	ContentType   int        `json:"contentType"`
	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       `json:"lastUser"`
	LastCommentAt *time.Time `json:"lastCommentAt"`
}

Article 文章, 也称话题

type Book

type Book 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"`
	CoverURL       string         `json:"coverURL"`
	BrowseCount    uint           `json:"browseCount"`
	CommentCount   uint           `json:"commentCount"`
	CollectCount   uint           `json:"collectCount"`
	Status         string         `json:"status"`
	ReadLimits     string         `json:"readLimits"`
	Content        string         `json:"content"`
	HTMLContent    string         `json:"htmlContent"`
	ContentType    int            `json:"contentType"`
	Categories     []BookCategory `gorm:"many2many:book_category;ForeignKey:ID;AssociationForeignKey:ID" json:"categories"`
	Comments       []BookComment  `json:"comments"`
	UserID         uint           `json:"userID"`
	User           User           `json:"user"`
	Star           uint           `json:"star"` // 图书最终得了几颗星
	OneStarCount   uint           `json:"oneStarCount"`
	TwoStarCount   uint           `json:"twoStarCount"`
	ThreeStarCount uint           `json:"threeStarCount"`
	FourStarCount  uint           `json:"fourStarCount"`
	FiveStarCount  uint           `json:"fiveStarCount"`
	TotalStarCount uint           `json:"TotalStarCount"`
}

Book 图书

type BookCategory

type BookCategory 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  uint       `json:"parentId"` //直接父分类的ID
}

BookCategory 图书的分类

type BookChapter

type BookChapter 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"`
	Content      string        `json:"content"`
	HTMLContent  string        `json:"htmlContent"`
	ContentType  int           `json:"contentType"`
	Comments     []BookComment `json:"comments"`
	UserID       uint          `json:"userID"`
	User         User          `json:"user"`
	ParentID     uint          `json:"parentID"` //直接父章节的ID
	BookID       uint          `json:"bookID"`
}

BookChapter 图书的章节

type BookChapterComment

type BookChapterComment 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      string               `json:"status"`
	Content     string               `json:"content"`
	HTMLContent string               `json:"htmlContent"`
	ContentType int                  `json:"contentType"`
	ParentID    uint                 `json:"parentID"` //直接父评论的ID
	Parents     []BookChapterComment `json:"parents"`  //所有的父评论
	BookID      uint                 `json:"bookID"`
	ChapterID   uint                 `json:"chapterID"`
	UserID      uint                 `json:"userID"`
	User        User                 `json:"user"`
}

BookChapterComment 章节的评论

type BookComment

type BookComment 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      string        `json:"status"`
	Star        uint          `json:"Star"`
	Content     string        `json:"content"`
	HTMLContent string        `json:"htmlContent"`
	ContentType int           `json:"contentType"`
	ParentID    uint          `json:"parentID"` //直接父评论的ID
	Parents     []BookComment `json:"parents"`  //所有的父评论
	BookID      uint          `json:"bookID"`
	UserID      uint          `json:"userID"`
	User        User          `json:"user"`
}

BookComment 书评

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"`
	HTMLContent string     `json:"htmlContent"`
	ContentType int        `json:"contentType"`
	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 CrawlerArticle

type CrawlerArticle 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"`
	URL       string     `json:"url"`
	Title     string     `json:"title"`
	Content   string     `json:"content"`
	From      int        `json:"from"`
	ArticleID uint       `json:"articleID"`
}

CrawlerArticle 爬虫抓取的文章

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 ImageUploadedInfo

type ImageUploadedInfo struct {
	UploadDir      string
	UploadFilePath string
	Filename       string
	UUIDName       string
	ImgURL         string
}

ImageUploadedInfo 图片上传后的相关信息(目录、文件路径、文件名、UUIDName、请求URL)

func GenerateImgUploadedInfo

func GenerateImgUploadedInfo(ext string) ImageUploadedInfo

GenerateImgUploadedInfo 创建一个ImageUploadedInfo

type KeyValueConfig

type KeyValueConfig 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"`
	KeyName   string     `json:"key"`
	Value     string     `json:"value"`
}

KeyValueConfig key, value配置

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       string     `json:"type"`
	Readed     bool       `json:"readed"`
	FromUserID uint       `json:"fromUserID"`
	ToUserID   uint       `json:"toUserID"`
	FromUser   User       `json:"fromUser"`
	SourceID   uint       `json:"sourceID"`
	SourceName string     `json:"sourceName"`
	CommentID  uint       `json:"commentID"`
	Data       data       `json:"data"`
}

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"`
	ActivatedAt  *time.Time `json:"activatedAt"`
	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 UserFromRedis

func UserFromRedis(userID int) (User, error)

UserFromRedis 从redis中取出用户信息

func (User) CheckPassword

func (user User) CheckPassword(password string) bool

CheckPassword 验证密码是否正确

func (User) EncryptPassword

func (user User) EncryptPassword(password, salt string) (hash string)

EncryptPassword 给密码加密

func (User) Salt

func (user User) Salt() string

Salt 每个用户都有一个不同的盐

type UserVisit

type UserVisit struct {
	ID             bson.ObjectId `bson:"_id"`
	Platform       string        `bson:"platform"`
	URL            string        `bson:"url"`
	Referrer       string        `bson:"referrer"`
	ClientID       string        `bson:"clientID"`
	UserID         uint          `bson:"userID"`
	Date           time.Time     `bson:"date"`
	IP             string        `bson:"ip"`
	DeviceWidth    int           `bson:"deviceWidth"`
	DeviceHeight   int           `bson:"deviceHeight"`
	BrowserName    string        `bson:"browserName"`
	BrowserVersion string        `bson:"browserVersion"`
	DeviceModel    string        `bson:"deviceModel"`
	Country        string        `bson:"country"`
	Language       string        `bson:"language"`
	OSName         string        `bson:"osName"`
	OSVersion      string        `bson:"osVersion"`
}

UserVisit 访客记录

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"`
	Vote       Vote       `json:"vote"`
	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"`
	HTMLContent   string     `json:"htmlContent"`
	ContentType   int        `json:"contentType"`
	Comments      []Comment  `gorm:"ForeignKey:SourceID" json:"comments"`
	UserID        uint       `json:"userID"`
	User          User       `json:"user"`
	LastUserID    uint       `json:"lastUserID"` //最后一个回复投票、参与投票的人
	LastUser      User       `json:"lastUser"`
	LastCommentAt *time.Time `json:"lastCommentAt"`
	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 投票项, 一个投票有多个投票项,用户选择投票项进行投票

type YesterdayStats

type YesterdayStats struct {
	ID              bson.ObjectId `bson:"_id"`
	Date            string        `bson:"date"`
	SignupUserCount uint          `bson:"signupUserCount"`
	TopicCount      uint          `bson:"topicCount"`
	CommentCount    uint          `bson:"commentCount"`
	BookCount       uint          `bson:"bookCount"`
	PV              uint          `bson:"pv"`
	UV              uint          `bson:"uv"`
}

YesterdayStats 昨日统计

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL