Documentation ¶
Overview ¶
数据库模型.
Package mysql 为项目所需的模型对象定义.
Package mysql .
Index ¶
- Constants
- Variables
- func BuildQuery(conds Conds) (sql string, binds []interface{})
- func CountCategory()
- func GetAPIStaticDomain() string
- func GetAdsCode(positionIdentify string, isMobile bool) (code string)
- func Init()
- func InstallAdsPosition()
- func UpdateAdsCache()
- type AdsCont
- type AdsPosition
- type Attachment
- type AttachmentResult
- type Auth
- type Awesome
- type AwesomeCate
- type Banner
- type Book
- type BookCategory
- type BookCommentsResult
- type BookCounter
- func (*BookCounter) Decrease(bookId int, isPV bool)
- func (*BookCounter) Increase(bookId int, isPV bool)
- func (m *BookCounter) PageViewSort(prd period, limit int, withCache ...bool) (books []SortedBook)
- func (m *BookCounter) StarSort(prd period, limit int, withCache ...bool) (books []SortedBook)
- func (BookCounter) TableName() string
- func (*BookCounter) TableUnique() [][]string
- type BookOrder
- type BookResult
- type BookScoresResult
- type Bookmark
- type Category
- type CommentCount
- type Comments
- type Cond
- type Conds
- type Config
- type Count
- type Dashboard
- type DataCount
- type DocResult
- type Document
- type DocumentHistory
- type DocumentHistorySimpleResult
- type DocumentSearchResult
- type DocumentSelected
- type DocumentStore
- type DocumentTree
- type ElasticSearchClient
- type ElasticSearchCount
- type ElasticSearchData
- type ElasticSearchResult
- type Fans
- func (this *Fans) FollowOrCancel(uid, fansId int) (cancel bool, err error)
- func (this *Fans) GetFansList(uid, page, pageSize int) (fans []FansResult, total int, err error)
- func (this *Fans) GetFollowList(fansId, page, pageSize int) (fans []FansResult, total int, err error)
- func (this *Fans) Relation(uid, fansId interface{}) (ok bool)
- func (Fans) TableName() string
- func (this *Fans) TableUnique() [][]string
- type FansResult
- type FriendLink
- type GithubUser
- type Label
- type Logs
- type Member
- func (m *Member) Add() error
- func (m *Member) FindByAccount(account string) (*Member, error)
- func (m *Member) FindByFieldFirst(field string, value interface{}) (*Member, error)
- func (this *Member) GetByUsername(username string) (member Member, err error)
- func (m *Member) IsAdministrator() bool
- func (m *Member) ResolveRoleName()
- func (m *Member) TableEngine() string
- func (m Member) TableName() string
- func (m *Member) TableNameWithPrefix() string
- func (m *Member) Update() error
- type MemberRelationshipResult
- type MemberToken
- type Migration
- type Option
- type PrintBook
- type QQ
- type Queue
- type ReadCount
- type ReadProgress
- type ReadRecord
- type ReadingRule
- type ReadingSortedUser
- type ReadingTime
- type RecordList
- type RegLimit
- type RelateBook
- type Relationship
- type Rule
- type Score
- type Seo
- type Sign
- func (m *Sign) GetSignRule() (r *Rule)
- func (m *Sign) IsContinuousSign(uid int) bool
- func (m *Sign) IsSignToday(uid int) bool
- func (*Sign) LatestOne(uid int) (s Sign)
- func (m *Sign) Sign(uid int, fromApp bool) (reward int, err error)
- func (m *Sign) Sorted(limit int, orderField string, withCache ...bool) (members []Member)
- func (Sign) TableName() string
- func (m *Sign) TableUnique() [][]string
- type SitemapDocs
- type SortedBook
- type Spider
- type Star
- type StarResult
- type Ticket
- type Token
- type Tokens
- type Tool
- type Ups
- type User
- type Wechat
- type WechatCode
Constants ¶
const ( AdsPositionBeforeFriendLink = "global-before-friend-link" AdsPositionUnderLatestRecommend = "index-under-latest-recommend" AdsPositionSearchRight = "search-right" AdsPositionSearchTop = "search-top" AdsPositionSearchBottom = "search-bottom" AdsPositionUnderBookName = "intro-under-book-name" AdsPositionBeforeMenu = "intro-before-menu" AdsPositionBeforeRelatedBooks = "intro-before-related-books" AdsPositionBeforeExplorePagination = "explore-before-pagination" AdsPositionUnderExplorePagination = "explore-under-pagination" AdsPositionContentTop = "content-top" AdsPositionContentBottom = "content-bottom" )
const ( PeriodDay period = "day" PeriodWeek period = "week" PeriodLastWeek period = "last-week" PeriodMonth period = "month" PeriodLastMoth period = "last-month" PeriodAll period = "all" PeriodYear period = "year" )
const ( QUEUE_STATUS_PADDING int8 = 0 //待导出 QUEUE_STATUS_EXPORTING int8 = 1 //导出中 QUEUE_STATUS_FINISHED int8 = 2 //导出完成 QUEUE_STATUS_FAILED int8 = 3 //导出失败 )
Variables ¶
var ( // ErrMemberNoExist 用户不存在. ErrMemberNoExist = errors.New("用户不存在") ErrMemberExist = errors.New("用户已存在") ErrMemberDisabled = errors.New("用户被禁用") ErrMemberEmailEmpty = errors.New("用户邮箱不能为空") ErrMemberEmailExist = errors.New("用户邮箱已被使用") ErrMemberDescriptionTooLong = errors.New("用户描述必须小于500字") ErrMemberEmailFormatError = errors.New("邮箱格式不正确") ErrMemberPasswordFormatError = errors.New("密码必须在6-50个字符之间") ErrMemberAccountFormatError = errors.New("账号只能由英文字母数字组成,且在3-50个字符") ErrMemberRoleError = errors.New("用户权限不正确") // ErrorMemberPasswordError 密码错误. ErrorMemberPasswordError = errors.New("用户密码错误") //ErrorMemberAuthMethodInvalid 不支持此认证方式 ErrMemberAuthMethodInvalid = errors.New("不支持此认证方式") //ErrLDAPConnect 无法连接到LDAP服务器 ErrLDAPConnect = errors.New("无法连接到LDAP服务器") //ErrLDAPFirstBind 第一次LDAP绑定失败 ErrLDAPFirstBind = errors.New("第一次LDAP绑定失败") //ErrLDAPSearch LDAP搜索失败 ErrLDAPSearch = errors.New("LDAP搜索失败") //ErrLDAPUserNotFoundOrTooMany ErrLDAPUserNotFoundOrTooMany = errors.New("LDAP用户不存在或者多于一个") // ErrDataNotExist 指定的服务已存在. ErrDataNotExist = errors.New("数据不存在") // ErrInvalidParameter 参数错误. ErrInvalidParameter = errors.New("Invalid parameter") ErrPermissionDenied = errors.New("Permission denied") ErrCommentClosed = errors.New("评论已关闭") ErrCommentContentNotEmpty = errors.New("评论内容不能为空") )
var ModelQQ = new(QQ)
Functions ¶
func BuildQuery ¶
BuildQuery 根据conds构建sql和绑定的参数
func CountCategory ¶
func CountCategory()
func GetAPIStaticDomain ¶
func GetAPIStaticDomain() string
func GetAdsCode ¶
func InstallAdsPosition ¶
func InstallAdsPosition()
func UpdateAdsCache ¶
func UpdateAdsCache()
Types ¶
type AdsCont ¶
type AdsCont struct { Id int Pid int `orm:"index"` Title string Code string `orm:"size(4096)"` Start int StartTime string `orm:"-"` End int EndTime string `orm:"-"` Status bool }
广告
func NewAdsCont ¶
func NewAdsCont() *AdsCont
func (*AdsCont) GetPositions ¶
func (m *AdsCont) GetPositions() []AdsPosition
type AdsPosition ¶
type AdsPosition struct { Id int Title string Identify string `orm:"index;size(32)"` IsMobile bool `orm:"index"` }
广告位
func NewAdsPosition ¶
func NewAdsPosition() *AdsPosition
type Attachment ¶
type Attachment struct { AttachmentId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"attachmentId"` BookId int `gorm:"not null;"json:"bookId"` DocumentId int `gorm:"not null;"json:"documentId"` FileName string `gorm:"not null;"json:"fileName"` FilePath string `gorm:"not null;"json:"filePath"` FileSize float64 `gorm:"not null;"json:"fileSize"` HttpPath string `gorm:"not null;"json:"httpPath"` FileExt string `gorm:"not null;"json:"fileExt"` CreateTime time.Time `gorm:""json:"createTime"` CreateAt int `gorm:"not null;"json:"createAt"` }
Attachment struct .
func NewAttachment ¶
func NewAttachment() *Attachment
type AttachmentResult ¶
type AttachmentResult struct { Attachment IsExist bool BookName string DocumentName string FileShortSize string Account string LocalHttpPath string }
func NewAttachmentResult ¶
func NewAttachmentResult() *AttachmentResult
type Awesome ¶
type Awesome struct { Id int `gorm:"not null;"json:"id"` Name string `gorm:"not null;UNIQUE_INDEX"json:"name"` // 唯一标识 GitName string `gorm:"not null;"json:"gitName"` OwnerAvatarUrl string `gorm:"not null;"json:"ownerAvatarUrl"` HtmlUrl string `gorm:"not null;"json:"htmlUrl"` GitDescription string `gorm:"not null;"json:"gitDescription"` GitCreatedAt time.Time `gorm:""json:"gitCreatedAt"` GitUpdatedAt time.Time `gorm:""json:"gitUpdatedAt"` GitUrl string `gorm:"not null;"json:"gitUrl"` SshUrl string `gorm:"not null;"json:"sshUrl"` CloneUrl string `gorm:"not null;"json:"cloneUrl"` HomePage string `gorm:"not null;"json:"homePage"` StarCount int `gorm:"not null;"json:"starCount"` WatcherCount int `gorm:"not null;"json:"watcherCount"` Language string `gorm:"not null;"json:"language"` ForkCount int `gorm:"not null;"json:"forkCount"` LicenseKey string `gorm:"not null;"json:"licenseKey"` LicenseName string `gorm:"not null;"json:"licenseName"` LicenseUrl string `gorm:"not null;"json:"licenseUrl"` CreatedAt time.Time `gorm:""json:"createdAt"` UpdatedAt time.Time `gorm:""json:"updatedAt"` DeletedAt *time.Time `gorm:""json:"deletedAt"` Desc string `gorm:"not null;"json:"desc"` LongDesc string `gorm:"not null;"json:"longDesc"` Version int `gorm:"not null;"json:"version"` ReadCount int `gorm:"not null;"json:"readCount"` }
type AwesomeCate ¶
type AwesomeCate struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` //自增主键 Pid int `gorm:"not null;"json:"pid"` //分类id Title string `gorm:"not null;UNIQUE_INDEX"json:"title"` //分类名称 Intro string `gorm:"not null;"json:"intro"` //介绍 Icon string `gorm:"not null;"json:"icon"` //分类icon Cnt int `gorm:"not null;"json:"cnt"` //分类下的文档项目统计 Sort int `gorm:"not null;"json:"sort"` //排序 Status bool `gorm:"not null;"json:"status"` //分类状态,true表示显示,否则表示隐藏 }
分类
func (AwesomeCate) TableName ¶
func (m AwesomeCate) TableName() string
type Banner ¶
type Banner struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` Type string `gorm:"not null;"json:"type"` Title string `gorm:"not null;"json:"title"` Link string `gorm:"not null;"json:"link"` Image string `gorm:"not null;"json:"image"` Sort int `gorm:"not null;"json:"sort"` Status bool `gorm:"not null;"json:"status"` CreatedAt time.Time `gorm:"not null;"json:"createdAt"` }
type Book ¶
type Book struct { BookId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"bookId"` BookName string `gorm:"not null;"json:"bookName"` // BookName 项目名称. Identify string `gorm:"not null;"json:"identify"` // Identify 项目唯一标识. OrderIndex int `gorm:"not null;"json:"orderIndex"` Pin int `gorm:"not null;"json:"pin"` // pin值,用于首页固定显示 Description string `gorm:"not null;"json:"description"` // Description 项目描述. Label string `gorm:"not null;"json:"label"` PrivatelyOwned int `gorm:"not null;"json:"privatelyOwned"` // PrivatelyOwned 项目私有: 0 公开/ 1 私有 PrivateToken string `gorm:"not null;"json:"privateToken"` // 当项目是私有时的访问Token. Status int `gorm:"not null;"json:"status"` //状态:0 正常/1 已删除 Editor string `gorm:"not null;"json:"editor"` //默认的编辑器. DocCount int `gorm:"not null;"json:"docCount"` // DocCount 包含文档数量. CommentStatus string `gorm:"not null;"json:"commentStatus"` // CommentStatus 评论设置的状态:open 为允许所有人评论,closed 为不允许评论, group_only 仅允许参与者评论 ,registered_only 仅允许注册者评论. CommentCount int `gorm:"not null;"json:"commentCount"` Cover string `gorm:"not null;"json:"cover"` //封面地址 Theme string `gorm:"not null;"json:"theme"` //主题风格 CreateTime time.Time `gorm:""json:"createTime"` // CreateTime 创建时间 . MemberId int `gorm:"not null;"json:"memberId"` ModifyTime time.Time `gorm:""json:"modifyTime"` ReleaseTime time.Time `gorm:""json:"releaseTime"` //项目发布时间,每次发布都更新一次,如果文档更新时间小于发布时间,则文档不再执行发布 GenerateTime time.Time `gorm:""json:"generateTime"` //下载文档生成时间 LastClickGenerate time.Time `gorm:""json:"lastClickGenerate"` //上次点击上传文档的时间,用于显示频繁点击浪费服务器硬件资源的情况 Version int64 `gorm:"not null;"json:"version"` Vcnt int `gorm:"not null;"json:"vcnt"` // 文档项目被阅读次数 Star int `gorm:"not null;"json:"star"` // 文档项目被收藏次数 Score int `gorm:"not null;"json:"score"` // 文档项目评分,默认40,即4.0星 CntScore int `gorm:"not null;"json:"cntScore"` // 评分人数 CntComment int `gorm:"not null;"json:"cntComment"` // 评论人数 Author string `gorm:"not null;"json:"author"` //原作者,即来源 AuthorURL string `gorm:"not null;"json:"authorUrl"` //原作者链接,即来源链接 AdTitle string `gorm:"not null;"json:"adTitle"` // 文字广告标题 AdLink string `gorm:"not null;"json:"adLink"` // 文字广告链接 Lang string `gorm:"not null;"json:"lang"` BookType string `gorm:"not null;"json:"bookType"` // original 原创, opensource 开源 Avatar string `gorm:"-"json:"avatar"` UserName string `gorm:"-"json:"userName"` }
Book struct .
func (*Book) ToBookResult ¶
func (book *Book) ToBookResult() (m *BookResult)
type BookCategory ¶
type BookCategory struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` //自增主键 BookId int `gorm:"not null;unique_index:unique_idx"json:"bookId"` //书籍id CategoryId int `gorm:"not null;unique_index:unique_idx"json:"categoryId"` //分类id }
文档项目与分类关联表,一个文档项目可以属于多个分类
type BookCommentsResult ¶
type BookCommentsResult struct { Id int `json:"id"` Uid int `json:"uid"` Score int `json:"score"` Avatar string `json:"avatar"` Account string `json:"account"` Nickname string `json:"nickname"` BookId int `json:"book_id"` BookName string `json:"book_name"` Identify string `json:"identify"` Content string `json:"content"` Status int8 `json:"status"` TimeCreate time.Time `json:"created_at"` //评论时间 }
评论内容
type BookCounter ¶
type BookCounter struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` Bid int `gorm:"not null;"json:"bid"` //bookId Day int `gorm:"not null;"json:"day"` // 20060102 StarCnt int `gorm:"not null;"json:"starCnt"` ViewCnt int `gorm:"not null;"json:"viewCnt"` }
func NewBookCounter ¶
func NewBookCounter() *BookCounter
func (*BookCounter) Decrease ¶
func (*BookCounter) Decrease(bookId int, isPV bool)
func (*BookCounter) Increase ¶
func (*BookCounter) Increase(bookId int, isPV bool)
func (*BookCounter) PageViewSort ¶
func (m *BookCounter) PageViewSort(prd period, limit int, withCache ...bool) (books []SortedBook)
func (*BookCounter) StarSort ¶
func (m *BookCounter) StarSort(prd period, limit int, withCache ...bool) (books []SortedBook)
func (BookCounter) TableName ¶
func (BookCounter) TableName() string
func (*BookCounter) TableUnique ¶
func (*BookCounter) TableUnique() [][]string
type BookOrder ¶
type BookOrder string
定义书籍排序类型
const ( OrderRecommend BookOrder = "recommend" OrderPopular BookOrder = "popular" //热门 OrderLatest BookOrder = "latest" //最新 OrderNew BookOrder = "new" //最新 OrderScore BookOrder = "score" //评分排序 OrderComment BookOrder = "comment" //评论排序 OrderStar BookOrder = "star" //收藏排序 OrderView BookOrder = "vcnt" //浏览排序 OrderLatestRecommend BookOrder = "latest-recommend" //最新推荐 )
type BookResult ¶
type BookResult struct { BookId int `json:"book_id"` BookName string `json:"book_name"` Identify string `json:"identify"` OrderIndex int `json:"order_index"` Description string `json:"description"` PrivatelyOwned int `json:"privately_owned"` PrivateToken string `json:"private_token"` DocCount int `json:"doc_count"` CommentStatus string `json:"comment_status"` CommentCount int `json:"comment_count"` CreateTime time.Time `json:"create_time"` CreateName string `json:"create_name"` ModifyTime time.Time `json:"modify_time"` Cover string `json:"cover"` Theme string `json:"theme"` Label string `json:"label"` MemberId int `json:"member_id"` Username int `json:"user_name"` Editor string `json:"editor"` RelationshipId int `json:"relationship_id"` RoleId int `json:"role_id"` RoleName string `json:"role_name"` Status int Vcnt int `json:"vcnt"` Star int `json:"star"` Score int `json:"score"` CntComment int `json:"cnt_comment"` CntScore int `json:"cnt_score"` ScoreFloat string `json:"score_float"` LastModifyText string `json:"last_modify_text"` IsDisplayComment bool `json:"is_display_comment"` Author string `json:"author"` AuthorURL string `json:"author_url"` AdTitle string `json:"ad_title"` AdLink string `json:"ad_link"` Lang string `json:"lang"` }
func NewBookResult ¶
func NewBookResult() *BookResult
func (*BookResult) DealCover ¶
func (b *BookResult) DealCover()
type BookScoresResult ¶
type BookScoresResult struct { Avatar string `json:"avatar"` Nickname string `json:"nickname"` Score string `json:"score"` TimeCreate time.Time `json:"time_create"` //评论时间 }
评分内容
type Bookmark ¶
type Bookmark struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` BookId int `gorm:"not null;index"json:"bookId"` //书籍id,主要是为了方便根据书籍id查询书签 Uid int `gorm:"not null;"json:"uid"` //用户id DocId int `gorm:"not null;"json:"docId"` //文档id CreateAt int `gorm:"not null;"json:"createAt"` //创建时间 }
书签
func NewBookmark ¶
func NewBookmark() *Bookmark
type Category ¶
type Category struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` //自增主键 Pid int `gorm:"not null;"json:"pid"` //分类id Title string `gorm:"not null;"json:"title"` //分类名称 Intro string `gorm:"not null;"json:"intro"` //介绍 Icon string `gorm:"not null;"json:"icon"` //分类icon Cnt int `gorm:"not null;"json:"cnt"` //分类下的文档项目统计 Sort int `gorm:"not null;"json:"sort"` //排序 Status bool `gorm:"not null;"json:"status"` //分类状态,true表示显示,否则表示隐藏 }
分类
func NewCategory ¶
func NewCategory() *Category
type CommentCount ¶
type Comments ¶
type Comments struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` Uid int `gorm:"not null;index"json:"uid"` //用户id BookId int `gorm:"not null;"json:"bookId"` //文档项目id Content string `gorm:"not null;"json:"content"` //评论内容 TimeCreate time.Time `gorm:"not null;"json:"timeCreate"` //评论时间 Status int8 `gorm:"not null;"json:"status"` // 审核状态; 0,待审核,1 通过,-1 不通过 }
评论表
func NewComments ¶
func NewComments() *Comments
func (*Comments) SetCommentStatus ¶
type Cond ¶
type Cond struct { // Op MySQL中查询条件,如like,=,in Op string // Val 查询条件对应的值 Val interface{} }
Cond 为字段查询结构体
type Conds ¶
type Conds map[string]interface{}
Conds 为Cond类型map,用于定义Where方法参数 map[field.name]interface{}
type Config ¶
type Config struct { Id int // Key string //键 Value string //值 Statement string //描述 Cate string //分类 }
配置项
type Dashboard ¶
type Dashboard struct { BookNumber int `json:"book_number"` DocumentNumber int `json:"document_number"` MemberNumber int `json:"member_number"` CommentNumber int `json:"comment_number"` AttachmentNumber int `json:"attachment_number"` }
func NewDashboard ¶
func NewDashboard() *Dashboard
type DocResult ¶
type DocResult struct { DocumentId int `json:"doc_id"` DocumentName string `json:"doc_name"` Identify string `json:"identify"` // Identify 文档唯一标识 Release string `json:"release"` // Release 发布后的Html格式内容. Vcnt int `json:"vcnt"` //文档项目被浏览次数 CreateTime time.Time `json:"create_time"` BookId int `json:"book_id"` BookIdentify string `json:"book_identify"` BookName string `json:"book_name"` }
文档结果
type Document ¶
type Document struct { DocumentId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"documentId"` DocumentName string `gorm:"not null;"json:"documentName"` Identify string `gorm:"not null;"json:"identify"` // Identify 文档唯一标识 BookId int `gorm:"not null;"json:"bookId"` ParentId int `gorm:"not null;"json:"parentId"` OrderSort int `gorm:"not null;"json:"orderSort"` Release string `gorm:"not null;type:longtext"json:"release"` // Release 发布后的Html格式内容. CreateTime time.Time `gorm:"not null;"json:"createTime"` MemberId int `gorm:"not null;"json:"memberId"` ModifyTime time.Time `gorm:"not null;"json:"modifyTime"` ModifyAt int `gorm:"not null;"json:"modifyAt"` Version int64 `gorm:"not null;"json:"version"` AttachList []*Attachment `gorm:"-"json:"attachList"` Vcnt int `gorm:"not null;"json:"vcnt"` //文档项目被浏览次数 Markdown string `gorm:"-"json:"markdown"` }
Document struct.
func NewDocument ¶
func NewDocument() *Document
type DocumentHistory ¶
type DocumentHistory struct { HistoryId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"historyId"` Action string `gorm:"not null;"json:"action"` ActionName string `gorm:"not null;"json:"actionName"` DocumentId int `gorm:"not null;"json:"documentId"` DocumentName string `gorm:"not null;"json:"documentName"` ParentId int `gorm:"not null;"json:"parentId"` MemberId int `gorm:"not null;"json:"memberId"` ModifyTime time.Time `gorm:"not null;"json:"modifyTime"` ModifyAt int `gorm:"not null;"json:"modifyAt"` Version int64 `gorm:"not null;"json:"version"` }
func NewDocumentHistory ¶
func NewDocumentHistory() *DocumentHistory
type DocumentHistorySimpleResult ¶
type DocumentHistorySimpleResult struct { HistoryId int `json:"history_id"` ActionName string `json:"action_name"` MemberId int `json:"member_id"` Account string `json:"account"` Nickname string `json:"nickname"` ModifyAt int `json:"modify_at"` ModifyName string `json:"modify_name"` ModifyTime time.Time `json:"modify_time"` Version int64 `json:"version"` }
type DocumentSearchResult ¶
type DocumentSearchResult struct { DocumentId int `json:"doc_id"` BookId int `json:"book_id"` DocumentName string `json:"doc_name"` Identify string `json:"identify"` // Identify 文档唯一标识 Description string `json:"description"` Author string `json:"author"` BookName string `json:"book_name"` BookIdentify string `json:"book_identify"` ModifyTime time.Time `json:"modify_time"` CreateTime time.Time `json:"create_time"` }
type DocumentSelected ¶
type DocumentStore ¶
type DocumentStore struct { DocumentId int `gorm:"not null;primary_key"json:"documentId"` //文档id,对应Document中的document_id Markdown string `gorm:"not null;type:longtext"json:"markdown"` //markdown内容 Content string `gorm:"not null;type:longtext"json:"content"` //文本内容 }
Document Store,文档存储,将大内容分发到专门的数据表里面
func (DocumentStore) TableName ¶
func (DocumentStore) TableName() string
type DocumentTree ¶
type ElasticSearchClient ¶
type ElasticSearchClient struct { Host string //host Index string //索引 Type string //type On bool //是否启用全文搜索 Timeout time.Duration //超时时间 IsRelateSearch bool }
全文搜索客户端
type ElasticSearchCount ¶
type ElasticSearchCount struct { Shards struct { Failed int `json:"failed"` Skipped int `json:"skipped"` Successful int `json:"successful"` Total int `json:"total"` } `json:"_shards"` Count int `json:"count"` }
统计信息结构
type ElasticSearchData ¶
type ElasticSearchData struct { Id int `json:"id"` //文档或书籍id BookId int `json:"book_id"` //书籍id。这里的book_id起到的作用是IsBooK的布尔,以及搜索书籍文档时候的过滤 Title string `json:"title"` //文档标题或书籍名称 Keywords string `json:"keywords"` //文档或书籍关键字 Content string `json:"content"` //文档摘要或书籍文本内容 Vcnt int `json:"vcnt"` //浏览量 Private int `json:"private"` //书籍或者文档是否是公开的 }
全文搜索
type ElasticSearchResult ¶
type ElasticSearchResult struct { Shards struct { Failed int `json:"failed"` Skipped int `json:"skipped"` Successful int `json:"successful"` Total int `json:"total"` } `json:"_shards"` Hits struct { Hits []struct { ID string `json:"_id"` Index string `json:"_index"` Score interface{} `json:"_score"` Source struct { Id int `json:"id"` BookId int `json:"book_id"` Title string `json:"title"` Keywords string `json:"keywords"` Content string `json:"content"` Vcnt int `json:"vcnt"` Private int `json:"private"` } `json:"_source"` Type string `json:"_type"` Sort []int `json:"sort"` } `json:"hits"` MaxScore interface{} `json:"max_score"` Total int `json:"total"` } `json:"hits"` TimedOut bool `json:"timed_out"` Took int `json:"took"` }
搜索结果结构
type Fans ¶
type Fans struct { Id int `gorm:"not null;"json:"id"` //自增主键 Uid int `gorm:"not null;index"json:"uid"` //被关注的用户id FansId int `gorm:"not null;index"json:"fansId"` //粉丝id }
粉丝表
func (*Fans) FollowOrCancel ¶
关注和取消关注
func (*Fans) GetFansList ¶
func (this *Fans) GetFansList(uid, page, pageSize int) (fans []FansResult, total int, err error)
查询用户的粉丝(用户id作为被关注对象)
func (*Fans) GetFollowList ¶
func (this *Fans) GetFollowList(fansId, page, pageSize int) (fans []FansResult, total int, err error)
查询用户的关注(用户id作为fans_id)
type FriendLink ¶
type FriendLink struct { Id int `gorm:"not null;"json:"id"` //自增主键 Sort int `gorm:"not null;"json:"sort"` //排序 Link string `gorm:"not null;"json:"link"` //链接地址 Title string `gorm:"not null;"json:"title"` //链接名称 Remark string `gorm:"not null;"json:"remark"` // 备注 Status bool `gorm:"not null;"json:"status"` }
友链数据表
func (*FriendLink) GetList ¶
func (this *FriendLink) GetList(all bool) (links []FriendLink)
查询友链列表 all表示是否查询全部,当为false时,只查询启用状态的友链,否则查询全部
func (FriendLink) TableName ¶
func (FriendLink) TableName() string
type GithubUser ¶
type GithubUser struct { Id int `gorm:"not null;primary_key"json:"id"` //用户id MemberId int `gorm:"not null;"json:"memberId"` //绑定的用户id UpdatedAt time.Time `gorm:"not null;"json:"updatedAt"` //用户资料更新时间 AvatarURL string `gorm:"not null;"json:"avatarUrl"` //用户头像链接 Email string `gorm:"not null;"json:"email"` //电子邮箱 Login string `gorm:"not null;"json:"login"` //用户名 Name string `gorm:"not null;"json:"name"` //昵称 HtmlURL string `gorm:"not null;"json:"htmlUrl"` //github主页 }
GitHub 用户数据 用户使用GitHub登录的时候,直接根据GitHub的id获取数据
type Label ¶
type Label struct { LabelId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"labelId"` LabelName string `gorm:"not null;"json:"labelName"` BookNumber int `gorm:"not null;"json:"bookNumber"` }
func (*Label) TableNameWithPrefix ¶
type Logs ¶
type Logs struct { LoggerId int64 `gorm:"not null;primary_key;AUTO_INCREMENT"json:"loggerId"` MemberId int `gorm:"not null;"json:"memberId"` // 日志类别:operate 操作日志/ system 系统日志/ exception 异常日志 / document 文档操作日志 Category string `gorm:"not null;"json:"category"` Content string `gorm:"not null;"json:"content"` OriginalData string `gorm:"not null;"json:"originalData"` PresentData string `gorm:"not null;"json:"presentData"` CreateTime time.Time `gorm:""json:"createTime"` UserAgent string `gorm:"not null;"json:"userAgent"` IPAddress string `gorm:"not null;"json:"ipAddress"` }
Logs struct .
func (*Logs) TableNameWithPrefix ¶
type Member ¶
type Member struct { MemberId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"memberId"` Account string `gorm:"not null;UNIQUE_INDEX"json:"account"` Nickname string `gorm:"not null;"json:"nickname"` //昵称 Password string `gorm:"not null;"json:"-"` AuthMethod string `gorm:"not null;"json:"authMethod"` //认证方式: local 本地数据库 /ldap LDAP Description string `gorm:"not null;"json:"description"` Email string `gorm:"not null;"json:"email"` Phone string `gorm:"not null;"json:"phone"` Avatar string `gorm:"not null;"json:"avatar"` Role int `gorm:"not null;"json:"role"` //用户角色:0 超级管理员 /1 管理员/ 2 普通用户 . RoleName string `gorm:"-"json:"roleName"` Status int `gorm:"not null;"json:"status"` //用户状态:0 正常/1 禁用 CreateTime time.Time `gorm:""json:"createTime"` CreateAt int `gorm:"not null;"json:"createAt"` LastLoginTime time.Time `gorm:""json:"lastLoginTime"` Wxpay string `gorm:"not null;"json:"wxpay"` // 微信支付的收款二维码 Alipay string `gorm:"not null;"json:"alipay"` // 支付宝支付的收款二维码 TotalReadingTime int `gorm:"not null;"json:"totalReadingTime"` // 总阅读时长 TotalSign int `gorm:"not null;"json:"totalSign"` // 总签到天数 TotalContinuousSign int `gorm:"not null;"json:"totalContinuousSign"` // 总连续签到天数 HistoryTotalContinuousSign int `gorm:"not null;"json:"historyTotalContinuousSign"` // 历史最高连续签到天数 }
member
func (*Member) FindByAccount ¶
根据账号查找用户.
func (*Member) FindByFieldFirst ¶
根据指定字段查找用户.
func (*Member) GetByUsername ¶
获取用户信息,根据用户名或邮箱
func (*Member) IsAdministrator ¶
func (*Member) ResolveRoleName ¶
func (m *Member) ResolveRoleName()
func (*Member) TableNameWithPrefix ¶
type MemberRelationshipResult ¶
type MemberRelationshipResult struct { MemberId int `json:"member_id"` Account string `json:"account"` Description string `json:"description"` Email string `json:"email"` Phone string `json:"phone"` Avatar string `json:"avatar"` Role int `json:"role"` //用户角色:0 管理员/ 1 普通用户 Status int `json:"status"` //用户状态:0 正常/1 禁用 CreateTime time.Time `json:"create_time"` CreateAt int `json:"create_at"` RelationshipId int `json:"relationship_id"` BookId int `json:"book_id"` // RoleId 角色:0 创始人(创始人不能被移除) / 1 管理员/2 编辑者/3 观察者 RoleId int `json:"role_id"` RoleName string `json:"role_name"` }
MemberRelationshipResult
func NewMemberRelationshipResult ¶
func NewMemberRelationshipResult() *MemberRelationshipResult
new MemberRelationshipResult
func (*MemberRelationshipResult) FindForUsersByBookId ¶
func (m *MemberRelationshipResult) FindForUsersByBookId(bookId, pageIndex, pageSize int) ([]*MemberRelationshipResult, int, error)
查询项目的用户
func (*MemberRelationshipResult) FromMember ¶
func (m *MemberRelationshipResult) FromMember(member *Member) *MemberRelationshipResult
拼装用户信息
func (*MemberRelationshipResult) ResolveRoleName ¶
func (m *MemberRelationshipResult) ResolveRoleName() *MemberRelationshipResult
角色名称
type MemberToken ¶
type MemberToken struct { TokenId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"tokenId"` MemberId int `gorm:"not null;"json:"memberId"` Token string `gorm:"not null;"json:"token"` Email string `gorm:"not null;"json:"email"` IsValid bool `gorm:"not null;"json:"isValid"` ValidTime time.Time `gorm:""json:"validTime"` SendTime time.Time `gorm:""json:"sendTime"` }
func NewMemberToken ¶
func NewMemberToken() *MemberToken
type Migration ¶
type Migration struct { MigrationId int `orm:"column(migration_id);pk;auto;unique;" json:"migration_id"` Name string `orm:"column(name);size(500)" json:"name"` Statements string `orm:"column(statements);type(text);null" json:"statements"` Status string `orm:"column(status);default(update)" json:"status"` CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"` Version int64 `orm:"type(bigint);column(version);unique" json:"version"` }
func NewMigration ¶
func NewMigration() *Migration
func (*Migration) TableNameWithPrefix ¶
type Option ¶
type Option struct { OptionId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"optionId"` OptionTitle string `gorm:"not null;"json:"optionTitle"` OptionName string `gorm:"not null;"json:"optionName"` OptionValue string `gorm:"not null;"json:"optionValue"` Remark string `gorm:"not null;"json:"remark"` }
Option struct .
type PrintBook ¶
type PrintBook struct { Id int `json:"id"` Cover string `json:"cover"` Title string `json:"title"` Keywords string `json:"keywords"` Description string `json:"description"` Author string `json:"author"` Publish string `json:"publish"` //出版社 Lang string `json:"lang"` //语种 Page int `json:"page"` //页数 View int `json:"view"` Support int `json:"support"` ShopLinks []struct { Name string `json:"name"` Href string `json:"href"` } `orm:"-" json:"shop_links"` ShopLinksJSON string `orm:"type(text)"` Content string `json:"content" orm:"type(longtext)"` // markdown content }
type QQ ¶
type QQ struct { Id int OpenId string MemberId int Name string `orm:"size(50)"` //昵称 Gender string `orm:"size(5)"` AvatarURL string `orm:"column(avatar_url)"` //用户头像链接 }
func (*QQ) GetUserByOpenid ¶
根据giteeid获取用户的gitee数据。这里可以查询用户是否绑定了或者数据是否在库中存在
type Queue ¶
type Queue struct { Id int //自增主键 BookId int `orm:"unique"` //书籍ID Status int8 `orm:"default(0)"` //导出状态,0待导出,1导出中,2导出完成,3导出失败 }
导出离线文档队列
type ReadCount ¶
type ReadCount struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` // 自增主键 BookId int `gorm:"not null;"json:"bookId"` // 书籍 Uid int `gorm:"not null;"json:"uid"` // 用户id Cnt int `gorm:"not null;"json:"cnt"` // 阅读的文档数 }
阅读统计 用来记录一本书(假设有100个章节),用户已经阅读了多少章节,以标识用户书籍的阅读进度 从而不用每次从阅读记录的表 read_record 表里面进行mysql 的 count 统计
type ReadProgress ¶
type ReadProgress struct { Cnt int `json:"cnt"` //已阅读过的文档 Total int `json:"total"` //总文档 Percent string `json:"percent"` //占的百分比 BookIdentify string `json:"book_identify"` }
阅读进度(非表)
type ReadRecord ¶
type ReadRecord struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` BookId int `gorm:"not null;index"json:"bookId"` //书籍id DocId int `gorm:"not null;"json:"docId"` //文档id Uid int `gorm:"not null;index"json:"uid"` //用户id CreateAt int `gorm:"not null;"json:"createAt"` //记录创建时间,也就是内容阅读时间 }
阅读记录.用于记录阅读的文档,以及阅读进度统计
func NewReadRecord ¶
func NewReadRecord() *ReadRecord
func (*ReadRecord) List ¶
func (this *ReadRecord) List(uid, bookId int) (lists []RecordList, cnt int64, err error)
查询阅读记录
func (ReadRecord) TableName ¶
func (ReadRecord) TableName() string
type ReadingSortedUser ¶
type ReadingTime ¶
type ReadingTime struct { Id int `gorm:"not null;"json:"id"` Uid int `gorm:"not null;"json:"uid"` Day int `gorm:"not null;"json:"day"` // 日期,如 20191212 Duration int `gorm:"not null;"json:"duration"` // 每天的阅读时长 }
阅读时长
func NewReadingTime ¶
func NewReadingTime() *ReadingTime
func (*ReadingTime) GetReadingTime ¶
func (r *ReadingTime) GetReadingTime(uid int, prd period) int
func (*ReadingTime) Sort ¶
func (r *ReadingTime) Sort(prd period, limit int, withCache ...bool) (users []ReadingSortedUser)
func (ReadingTime) TableName ¶
func (ReadingTime) TableName() string
func (*ReadingTime) TableUnique ¶
func (*ReadingTime) TableUnique() [][]string
type RecordList ¶
阅读记录列表(非表)
type RegLimit ¶
type RegLimit struct { Id int Ip string `orm:"size(15);index"` CreatedAt time.Time `orm:"index"` DailyRegNum int `orm:"-"` HourRegNum int `orm:"-"` RealIPField string `orm:"-"` }
func (*RegLimit) CheckIPIsAllowed ¶
type RelateBook ¶
func NewRelateBook ¶
func NewRelateBook() *RelateBook
type Relationship ¶
type Relationship struct { RelationshipId int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"relationshipId"` MemberId int `gorm:"not null;"json:"memberId"` BookId int `gorm:"not null;"json:"bookId"` RoleId int `gorm:"not null;"json:"roleId"` // RoleId 角色:0 创始人(创始人不能被移除) / 1 管理员/2 编辑者/3 观察者 }
func NewRelationship ¶
func NewRelationship() *Relationship
func (*Relationship) TableEngine ¶
func (m *Relationship) TableEngine() string
TableEngine 获取数据使用的引擎.
func (*Relationship) TableNameWithPrefix ¶
func (m *Relationship) TableNameWithPrefix() string
type Score ¶
type Score struct { Id int `gorm:"not null;"json:"id"` BookId int `gorm:"not null;"json:"bookId"` Uid int `gorm:"not null;"json:"uid"` Score int `gorm:"not null;"json:"score"` //评分 TimeCreate time.Time `gorm:"not null;"json:"timeCreate"` }
评分表
func (*Score) BookScores ¶
func (this *Score) BookScores(p, listRows, bookId int) (scores []BookScoresResult, err error)
获取评分内容
type Seo ¶
type Seo struct { Id int `gorm:"not null;"json:"id"` //自增主键 Page string `gorm:"not null;"json:"page"` //页面 Statement string `gorm:"not null;"json:"statement"` //页面说明 Title string `gorm:"not null;"json:"title"` //SEO标题 Keywords string `gorm:"not null;"json:"keywords"` //SEO关键字 Description string `gorm:"not null"json:"description"` //SEO摘要 CreatedAt time.Time `gorm:""json:"createdAt"` // 创建时间 UpdatedAt time.Time `gorm:""json:"updatedAt"` // 更新时间 DeletedAt *time.Time `gorm:"index"json:"deletedAt"` // 删除时间 }
SEO struct .
type Sign ¶
type Sign struct { Id int `gorm:"not null;"json:"id"` Uid int `gorm:"not null;"json:"uid"` // 签到的用户id Day int `gorm:"not null;"json:"day"` // 签到日期,如20200101 Reward int `gorm:"not null;"json:"reward"` // 奖励的阅读秒数 FromApp bool `gorm:"not null;"json:"fromApp"` CreatedAt time.Time `gorm:"not null;"json:"createdAt"` }
会员签到表
type SitemapDocs ¶
type SortedBook ¶
type Spider ¶
type Spider struct { Id int //主键 BookId int `orm:"index"` //归属于哪一本数 Title string //文档标题 Content string `orm:"type(text)"` //内容 TimeCreate int //创建时间 TimeUpdate int //更新时间 }
爬虫
type Star ¶
type StarResult ¶
type StarResult struct { BookId int `json:"book_id"` BookName string `json:"book_name"` Identify string `json:"identify"` Description string `json:"description"` DocCount int `json:"doc_count"` Cover string `json:"cover"` MemberId int `json:"member_id"` Nickname string `json:"user_name"` Vcnt int `json:"vcnt"` Star int `json:"star"` Score int `json:"score"` CntComment int `json:"cnt_comment"` CntScore int `json:"cnt_score"` ScoreFloat string `json:"score_float"` OrderIndex int `json:"order_index"` }
type Ticket ¶
type Ticket struct { Id int Uid int Status int8 // 0,未使用;1,已使用;-1,已过期 Message string // 书票说明 CreatedAt int }
书票数 可设定书票有效期
type Token ¶
type Token struct { EndOffset int `json:"end_offset"` Position int `json:"position"` StartOffset int `json:"start_offset"` Token string `json:"token"` Type string `json:"type"` }
分词
type Tool ¶
type Tool struct { Id int `gorm:"not null;"json:"id"` Name string `gorm:"not null;"json:"name"` Desc string `gorm:"not null;"json:"desc"` Identify string `gorm:"not null;UNIQUE_INDEX"json:"identify"` Cover string `gorm:"not null;"json:"cover"` CreatedAt time.Time `gorm:""json:"createdAt"` // 创建时间 UpdatedAt time.Time `gorm:""json:"updatedAt"` // 更新时间 DeletedAt *time.Time `gorm:"index"json:"deletedAt"` // 删除时间 Uid int `gorm:"not null;"json:"uid"` }
type User ¶
type User struct { Id int `json:"id" form:"id" gorm:"primary_key"` // 主键ID CreatedAt time.Time `gorm:""json:"createdAt"` // 创建时间 UpdatedAt time.Time `gorm:""json:"updatedAt"` // 更新时间 DeletedAt *time.Time `gorm:"index"json:"deletedAt"` // 删除时间 Name string `gorm:"not null;UNIQUE_INDEX"json:"name"` // 姓名 OpenId int `gorm:"not null;"json:"openId"` // 开放平台id OpenType int `gorm:"not null;"json:"openType"` // 开放平台类型,微信、支付宝等 Address string `gorm:"not null;"json:"address"` // 地址 Password string `gorm:"not null;"json:"password"` // 密码 Point int `gorm:"not null;"json:"point"` // 积分 Quota int `gorm:"not null;"json:"quota"` // 免费下载资料的配额 Balance int `gorm:"not null;"json:"balance"` // 账户余额 Level int `gorm:"not null;"json:"level"` // 等级 Account string `gorm:"not null;"json:"account"` AuthMethod string `gorm:"not null;"json:"authMethod"` Nickname string `gorm:"not null;"json:"nickname"` Desc string `gorm:"not null;"json:"desc"` Email string `gorm:"not null;"json:"email"` Phone string `gorm:"not null;"json:"phone"` Avatar string `gorm:"not null;"json:"avatar"` Role int `gorm:"not null;"json:"role"` Status int `gorm:"not null;"json:"status"` LastLoginTime time.Time `gorm:""json:"lastLoginTime"` LastLoginIP string `gorm:"not null;"json:"lastLoginIp"` // 最后一次登陆IP Wxpay string `gorm:"not null;"json:"wxpay"` // Alipay string `gorm:"not null;"json:"alipay"` // RoleName string `gorm:"-"` AreaId int `gorm:"not null"json:"areaId"` // 社区 Identify int `gorm:"not null"json:"identify"` // 0 未认证,1已认证 }
type Wechat ¶
type Wechat struct { Id int `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"` MemberId int `gorm:"not null;"json:"memberId"` //绑定的用户id Openid string `gorm:"not null;"json:"openid"` Unionid string `gorm:"not null;"json:"unionid"` AvatarURL string `gorm:"not null;"json:"avatarUrl"` Nickname string `gorm:"not null;"json:"nickname"` SessKey string `gorm:"not null;"json:"sessKey"` }
type WechatCode ¶
微信小程序码记录表
func NewWechatCode ¶
func NewWechatCode() (code *WechatCode)
func (*WechatCode) CreateWechatCode ¶
func (this *WechatCode) CreateWechatCode(bookId int)
调用分钟频率受限(5000次/分钟),如需大量小程序码,建议预生成\ 生成微信小程序码
func (*WechatCode) Delete ¶
func (this *WechatCode) Delete(bookId int)
func (*WechatCode) GetCode ¶
func (this *WechatCode) GetCode(bookId int) (path string)
Source Files ¶
- ads.go
- api.go
- attachment.go
- attachment_result.go
- awesome.go
- awesome_cate.go
- banner.go
- base.go
- book.go
- book_category.go
- book_counter.go
- book_result.go
- bookmarks.go
- category.go
- comments.go
- config.go
- dashboard.go
- document.go
- document_history.go
- document_search_result.go
- document_store.go
- document_tree.go
- elasticsearch.go
- errors.go
- fans.go
- friendlink.go
- github.go
- label.go
- logs.go
- member.go
- member_result.go
- member_token.go
- migrations.go
- mysql.gen.go
- options.go
- print_book.go
- qq.go
- queue.go
- read_record.go
- reading_time.go
- reg_limit.go
- relationship.go
- releate_book.go
- seo.go
- sign.go
- spider.go
- star.go
- ticket.go
- tool.go
- user.go
- wechat.go
- wechat_code.go