Documentation ¶
Overview ¶
数据库模型.
Package models .
Package models 为书籍所需的模型对象定义.
Package models .
Index ¶
- Constants
- Variables
- func CountCategory()
- func GetAPIStaticDomain() string
- func GetAdsCode(positionIdentify string, isMobile bool) (code string)
- func GetOptionValue(key, def string) string
- func Init()
- func InitCreditRule()
- func InstallAdsPosition()
- func NewVersionControl(docId int, version int64) *versionControl
- func SetIncreAndDecre(table string, field string, condition string, incre bool, step ...int) (err error)
- func SitemapUpdate(domain string)
- func UpdateAdsCache()
- type AdsCont
- type AdsPosition
- type Attachment
- func (m *Attachment) Delete() (err error)
- func (m *Attachment) Find(id int) (*Attachment, error)
- func (m *Attachment) FindListByDocumentId(docId int) (attaches []*Attachment, err error)
- func (m *Attachment) FindToPager(pageIndex, pageSize int) (attachList []*AttachmentResult, totalCount int64, err error)
- func (m *Attachment) Insert() error
- func (m *Attachment) TableEngine() string
- func (m *Attachment) TableName() string
- func (m *Attachment) TableNameWithPrefix() string
- func (m *Attachment) Update() error
- type AttachmentResult
- type Auth
- type Banner
- type Book
- func (m *Book) Find(id int, cols ...string) (book *Book, err error)
- func (m *Book) FindByField(field string, value interface{}) (books []*Book, err error)
- func (m *Book) FindByFieldFirst(field string, value interface{}) (book *Book, err error)
- func (m *Book) FindByIdentify(identify string, cols ...string) (book *Book, err error)
- func (m *Book) FindForHomeToPager(pageIndex, pageSize, member_id int, orderType string) (books []*BookResult, totalCount int, err error)
- func (m *Book) FindForLabelToPager(keyword string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error)
- func (m *Book) FindToPager(pageIndex, pageSize, memberId int, PrivatelyOwned ...int) (books []*BookResult, totalCount int, err error)
- func (m *Book) GetBooksById(id []int, fields ...string) (books []Book, err error)
- func (m *Book) HasProjectAccess(identify string, memberId int, minRole int) bool
- func (m *Book) HomeData(pageIndex, pageSize int, orderType BookOrder, lang string, cid int, ...) (books []Book, totalCount int, err error)
- func (m *Book) Insert() (err error)
- func (m *Book) Replace(bookId int, src, dst string)
- func (m *Book) ResetDocumentNumber(bookId int)
- func (n *Book) SearchBook(wd string, page, size int) (books []Book, cnt int, err error)
- func (b *Book) SearchBookByLabel(labels []string, limit int, excludeIds []int) (bookIds []int, err error)
- func (m *Book) Sorted(limit int, orderField string) (books []Book)
- func (m *Book) TableEngine() string
- func (m *Book) TableName() string
- func (m *Book) TableNameWithPrefix() string
- func (m *Book) ThoroughDeleteBook(id int) (err error)
- func (book *Book) ToBookResult() (m *BookResult)
- func (m *Book) Update(cols ...string) (err error)
- 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) TableUnique() [][]string
- type BookOrder
- type BookResult
- type BookScoresResult
- type Bookmark
- func (m *Bookmark) Delete(uid, bookId, docId int) (err error)
- func (m *Bookmark) Exist(uid, docId int) (exist bool)
- func (m *Bookmark) InsertOrDelete(uid, docId int) (insert bool, err error)
- func (m *Bookmark) List(uid, bookId int) (bl []bookmarkList, rows int64, err error)
- func (m *Bookmark) TableUnique() [][]string
- type Category
- func (this *Category) AddCates(pid int, cates string) (err error)
- func (m *Category) CategoryOfUserCollection(uid int, forAPI ...bool) (cates []Category)
- func (this *Category) Del(id int) (err error)
- func (this *Category) Find(id int) (cate Category)
- func (this *Category) GetCates(pid int, status int) (cates []Category, err error)
- func (this *Category) UpdateByField(id int, field, val string) (err error)
- type CommentCount
- type Comments
- func (this *Comments) AddComments(uid, bookId int, content string) (err error)
- func (this *Comments) ClearComments(uid int)
- func (this *Comments) Comments(p, listRows, bookId int, status ...int) (comments []BookCommentsResult, err error)
- func (this *Comments) Count(bookId int, status ...int) (int64, error)
- func (this *Comments) DeleteComment(id int)
- func (this *Comments) SetCommentStatus(id, status int) (err error)
- type Config
- type Count
- type Course
- type Credit
- type CreditLog
- type CreditRule
- type Dashboard
- type DataCount
- type DocResult
- type Document
- func (m *Document) AutoTitle(identify interface{}, defaultTitle ...string) (title string)
- func (m *Document) BookStackAuto(bookId, docId int, isSummary ...bool) (md, cont string)
- func (m *Document) BookStackCrawl(html, md string, bookId, uid int) (content, markdown string, err error)
- func (m *Document) CreateDocumentTreeForHtml(bookId, selectedId int) (string, error)
- func (m *Document) Find(id int) (doc *Document, err error)
- func (m *Document) FindByBookIdAndDocIdentify(BookId, Identify interface{}) (*Document, error)
- func (m *Document) FindByFieldFirst(field string, v interface{}) (*Document, error)
- func (m *Document) FindDocumentTree(bookId int, selectedId int, isEdit ...bool) ([]*DocumentTree, error)
- func (m *Document) FindListByBookId(bookId int, withoutContent ...bool) (docs []*Document, err error)
- func (m *Document) GenerateBook(book *Book, baseUrl string)
- func (m *Document) GetMenuTop(bookId int) (docs []*Document, err error)
- func (m *Document) GetParentTitle(pid int) (title string)
- func (m *Document) InsertOrUpdate(cols ...string) (id int64, err error)
- func (m *Document) RecursiveDocument(docId int) error
- func (m *Document) ReleaseContent(bookId int, baseUrl string)
- func (m *Document) SplitMarkdownAndStore(seg string, markdown string, docId int) (err error)
- func (m *Document) TableEngine() string
- func (m *Document) TableName() string
- func (m *Document) TableNameWithPrefix() string
- type DocumentHistory
- func (m *DocumentHistory) Clear(docId int) error
- func (m *DocumentHistory) Delete(historyId, docId int) error
- func (history *DocumentHistory) DeleteByDocumentId(docId int) (err error)
- func (history *DocumentHistory) DeleteByHistoryId(historyId int) (err error)
- func (history *DocumentHistory) DeleteByLimit(docId, limit int) (err error)
- func (m *DocumentHistory) Find(id int) (*DocumentHistory, error)
- func (m *DocumentHistory) FindToPager(docId, pageIndex, pageSize int) (docs []*DocumentHistorySimpleResult, totalCount int, err error)
- func (m *DocumentHistory) InsertOrUpdate() (history *DocumentHistory, err error)
- func (history *DocumentHistory) Restore(historyId, docId, uid int) (err error)
- func (m *DocumentHistory) TableEngine() string
- func (m *DocumentHistory) TableName() string
- func (m *DocumentHistory) TableNameWithPrefix() string
- type DocumentHistorySimpleResult
- type DocumentSearchResult
- func (m *DocumentSearchResult) FindToPager(keyword string, pageIndex, pageSize, memberId int) (searchResult []*DocumentSearchResult, totalCount int, err error)
- func (m *DocumentSearchResult) GetDocsById(id []int, withoutCont ...bool) (docs []DocResult, err error)
- func (m *DocumentSearchResult) SearchDocument(keyword string, bookId int, page, size int) (docs []*DocumentSearchResult, cnt int, err error)
- type DocumentSelected
- type DocumentStore
- func (this *DocumentStore) DeleteById(docId ...interface{})
- func (this *DocumentStore) GetById(docId interface{}) (ds DocumentStore, err error)
- func (this *DocumentStore) GetFiledById(docId interface{}, field string) string
- func (this *DocumentStore) InsertOrUpdate(ds DocumentStore, fields ...string) (err error)
- type DocumentTree
- type DownloadCounter
- type ElasticSearchClient
- func (this *ElasticSearchClient) BuildIndex(es ElasticSearchData) (err error)
- func (this *ElasticSearchClient) BuildIndexByBuck(data []ElasticSearchData) (err error)
- func (this *ElasticSearchClient) Count() (count int, err error)
- func (this *ElasticSearchClient) DeleteIndex(id int, isBook bool) (err error)
- func (this *ElasticSearchClient) Init() (err error)
- func (this *ElasticSearchClient) RebuildAllIndex(bookId ...int)
- func (this *ElasticSearchClient) Search(wd string, p, listRows int, isSearchDoc bool, bookId ...int) (result ElasticSearchResult, err error)
- func (this *ElasticSearchClient) SegWords(keyword string) string
- func (this *ElasticSearchClient) SetBookPublic(bookId int, public bool) (err error)
- 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 int64, err error)
- func (this *Fans) GetFollowList(fansId, page, pageSize int) (fans []FansResult, total int64, err error)
- func (this *Fans) Relation(uid, fansId interface{}) (ok bool)
- func (this *Fans) TableUnique() [][]string
- type FansResult
- type FriendLink
- type Gitee
- type Github
- type Label
- func (m *Label) FindFirst(field string, value interface{}) (*Label, error)
- func (m *Label) FindToPager(pageIndex, pageSize int, word ...string) (labels []*Label, totalCount int, err error)
- func (m *Label) InsertOrUpdate(labelName string) (err error)
- func (m *Label) InsertOrUpdateMulti(labels string)
- func (m *Label) TableEngine() string
- func (m *Label) TableName() string
- func (m *Label) TableNameWithPrefix() string
- type Logger
- type Member
- func (m *Member) Add() error
- func (m *Member) Delete(oldId int, adminId int) (err error)
- func (m *Member) Find(id int, cols ...string) (*Member, error)
- func (m *Member) FindByAccount(account string) (*Member, error)
- func (m *Member) FindByFieldFirst(field string, value interface{}) (*Member, error)
- func (m *Member) FindByNickname(nickname string, cols ...string) (user Member)
- func (m *Member) FindToPager(pageIndex, pageSize int, wd string, role ...int) ([]*Member, int64, error)
- func (this *Member) GetByUsername(username string) (member Member, err error)
- func (m *Member) GetNicknameByUid(id interface{}) string
- func (m *Member) GetQrcodeByUid(uid interface{}) (qrcode map[string]string)
- func (m *Member) GetUsernameByUid(id interface{}) string
- func (m *Member) IsAdministrator() bool
- func (m *Member) Login(account string, password string) (*Member, error)
- func (m *Member) ResolveRoleName()
- func (m *Member) TableEngine() string
- func (m *Member) TableName() string
- func (m *Member) TableNameWithPrefix() string
- func (m *Member) Update(cols ...string) error
- func (m *Member) Valid(isHashPassword bool) error
- type MemberRelationshipResult
- type MemberToken
- func (m *MemberToken) FindByFieldFirst(field string, value interface{}) (*MemberToken, error)
- func (m *MemberToken) FindSendCount(mail string, startTime time.Time, endTime time.Time) (int, error)
- func (m *MemberToken) InsertOrUpdate() (*MemberToken, error)
- func (m *MemberToken) TableEngine() string
- func (m *MemberToken) TableName() string
- func (m *MemberToken) TableNameWithPrefix() string
- type Migration
- type Option
- func (p *Option) All() ([]*Option, error)
- func (p *Option) Find(id int) (*Option, error)
- func (p *Option) FindByKey(key string) (*Option, error)
- func (m *Option) ForbiddenReferer() []string
- func (m *Option) Init() error
- func (p *Option) InsertMulti(option ...Option) error
- func (p *Option) InsertOrUpdate() error
- func (m *Option) IsResponseEmptyForAPP(requestVersion, word string) (yes bool)
- func (m *Option) TableEngine() string
- func (m *Option) TableName() string
- func (m *Option) TableNameWithPrefix() string
- type PrintBook
- type QQ
- type Queue
- type ReadCount
- type ReadProgress
- type ReadRecord
- func (this *ReadRecord) Add(docId, uid int) (err error)
- func (this *ReadRecord) BooksProgress(uid int, bookId ...int) (read map[int]int)
- func (this *ReadRecord) Clear(uid, bookId int) (err error)
- func (this *ReadRecord) Delete(uid, docId int) (err error)
- func (*ReadRecord) GetReadingRule() (r *ReadingRule)
- func (this *ReadRecord) HistoryReadBook(uid, page, size int) (books []Book)
- func (this *ReadRecord) LastReading(uid int, cols ...string) (r ReadRecord)
- func (this *ReadRecord) List(uid, bookId int) (lists []RecordList, cnt int64, err error)
- func (this *ReadRecord) Progress(uid, bookId int) (rp ReadProgress, err error)
- func (this *ReadRecord) TableUnique() [][]string
- func (*ReadRecord) UpdateReadingRule()
- type ReadingRule
- type ReadingSortedUser
- type ReadingTime
- type RecordList
- type RegLimit
- type RelateBook
- type Relationship
- func (m *Relationship) DeleteByBookIdAndMemberId(bookId, memberId int) error
- func (m *Relationship) Find(id int) (*Relationship, error)
- func (m *Relationship) FindByBookIdAndMemberId(bookId, memberId int) (*Relationship, error)
- func (m *Relationship) FindForRoleId(bookId, memberId int) (int, error)
- func (m *Relationship) FindFounder(bookId int) (*Relationship, error)
- func (m *Relationship) HasRelatedBook(uid int) bool
- func (m *Relationship) Insert() error
- func (m *Relationship) TableEngine() string
- func (m *Relationship) TableName() string
- func (m *Relationship) TableNameWithPrefix() string
- func (u *Relationship) TableUnique() [][]string
- func (m *Relationship) Transfer(bookId, founderId, receiveId int) error
- func (m *Relationship) Update() error
- func (m *Relationship) UpdateRoleId(bookId, memberId, roleId int) (*Relationship, error)
- 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) LatestSignTime(uid int) (date int)
- 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 (m *Sign) SortedByPeriod(limit int, prd period, withCache ...bool) (members []Member)
- func (m *Sign) TableUnique() [][]string
- func (m *Sign) UpdateSignRule()
- type SitemapDocs
- type SortedBook
- type Spider
- type Star
- func (this *Star) DoesStar(uid, bid interface{}) bool
- func (this *Star) List(uid, p, listRows int, cid int, order ...string) (cnt int64, books []StarResult, err error)
- func (this *Star) SetLastReadTime(uid, bid int)
- func (this *Star) Star(uid, bid int) (cancel bool, err error)
- func (this *Star) TableUnique() [][]string
- type StarResult
- type SubmitBooks
- type Ticket
- type Token
- type Tokens
- 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 ( AllowRegister = true AllowVisitor = true )
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 IsRebuildAllIndex = false
是否正在创建全量索引
var ModelGitee = new(Gitee)
var ModelGithub = new(Github)
var ModelQQ = new(QQ)
var TableDocumentStore = "md_document_store"
var TableSeo = "md_seo"
Functions ¶
func GetAPIStaticDomain ¶
func GetAPIStaticDomain() string
func GetAdsCode ¶
func GetOptionValue ¶
func InstallAdsPosition ¶
func InstallAdsPosition()
func NewVersionControl ¶
func SetIncreAndDecre ¶
func SetIncreAndDecre(table string, field string, condition string, incre bool, step ...int) (err error)
设置增减 @param table 需要处理的数据表 @param field 字段 @param condition 条件 @param incre 是否是增长值,true则增加,false则减少 @param step 增或减的步长
func SitemapUpdate ¶
func SitemapUpdate(domain string)
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 `orm:"column(attachment_id);pk;auto;unique" json:"attachment_id"` BookId int `orm:"column(book_id);type(int)" json:"book_id"` DocumentId int `orm:"column(document_id);type(int);null" json:"doc_id"` FileName string `orm:"column(file_name);size(255)" json:"file_name"` FilePath string `orm:"column(file_path);size(2000)" json:"file_path"` FileSize float64 `orm:"column(file_size);type(float)" json:"file_size"` HttpPath string `orm:"column(http_path);size(2000)" json:"http_path"` FileExt string `orm:"column(file_ext);size(50)" json:"file_ext"` CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` CreateAt int `orm:"column(create_at);type(int)" json:"create_at"` }
Attachment struct .
func NewAttachment ¶
func NewAttachment() *Attachment
func (*Attachment) Delete ¶
func (m *Attachment) Delete() (err error)
func (*Attachment) Find ¶
func (m *Attachment) Find(id int) (*Attachment, error)
func (*Attachment) FindListByDocumentId ¶
func (m *Attachment) FindListByDocumentId(docId int) (attaches []*Attachment, err error)
func (*Attachment) FindToPager ¶
func (m *Attachment) FindToPager(pageIndex, pageSize int) (attachList []*AttachmentResult, totalCount int64, err error)
分页查询附件
func (*Attachment) Insert ¶
func (m *Attachment) Insert() error
func (*Attachment) TableNameWithPrefix ¶
func (m *Attachment) TableNameWithPrefix() string
func (*Attachment) Update ¶
func (m *Attachment) Update() error
type AttachmentResult ¶
type AttachmentResult struct { Attachment IsExist bool BookName string BookIdentify string DocumentName string DocIdentify string FileShortSize string Account string LocalHttpPath string }
func NewAttachmentResult ¶
func NewAttachmentResult() *AttachmentResult
func (*AttachmentResult) Find ¶
func (m *AttachmentResult) Find(id int) (*AttachmentResult, error)
type Banner ¶
type Banner struct { Id int `json:"id"` Type string `orm:"size(30);index" json:"type" description:"横幅类型,如 wechat(小程序),pc(PC端),mobi(移动端)等"` Title string `json:"title" orm:"size(100)"` Link string `json:"link"` Image string `json:"image"` Sort int `json:"sort"` Status bool `json:"status"` CreatedAt time.Time `json:"created_at"` }
type Book ¶
type Book struct { BookId int `orm:"pk;auto;unique;column(book_id)" json:"book_id"` BookName string `orm:"column(book_name);size(500)" json:"book_name"` // BookName 书籍名称. Identify string `orm:"column(identify);size(100);unique" json:"identify"` // Identify 书籍唯一标识. OrderIndex int `orm:"column(order_index);type(int);default(0);index" json:"order_index"` Pin int `orm:"column(pin);type(int);default(0)" json:"pin"` // pin值,用于首页固定显示 Description string `orm:"column(description);size(2000)" json:"description"` // Description 书籍描述. Label string `orm:"column(label);size(500)" json:"label"` PrivatelyOwned int `orm:"column(privately_owned);type(int);default(0)" json:"privately_owned"` // PrivatelyOwned 书籍私有: 0 公开/ 1 私有 PrivateToken string `orm:"column(private_token);size(500);null" json:"private_token"` // 当书籍是私有时的访问Token. Status int `orm:"column(status);type(int);default(0)" json:"status"` //状态:0 正常/1 已删除 Editor string `orm:"column(editor);size(50)" json:"editor"` //默认的编辑器. DocCount int `orm:"column(doc_count);type(int)" json:"doc_count"` // DocCount 包含文档数量. CommentStatus string `orm:"column(comment_status);size(20);default(open)" json:"comment_status"` // CommentStatus 评论设置的状态:open 为允许所有人评论,closed 为不允许评论, group_only 仅允许参与者评论 ,registered_only 仅允许注册者评论. CommentCount int `orm:"column(comment_count);type(int)" json:"comment_count"` Cover string `orm:"column(cover);size(1000)" json:"cover"` //封面地址 Theme string `orm:"column(theme);size(255);default(default)" json:"theme"` //主题风格 CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` // CreateTime 创建时间 . MemberId int `orm:"column(member_id);size(100);index" json:"member_id"` ModifyTime time.Time `orm:"type(datetime);column(modify_time);auto_now" json:"modify_time"` ReleaseTime time.Time `orm:"type(datetime);column(release_time);" json:"release_time"` //书籍发布时间,每次发布都更新一次,如果文档更新时间小于发布时间,则文档不再执行发布 GenerateTime time.Time `orm:"type(datetime);column(generate_time);" json:"generate_time"` //下载文档生成时间 LastClickGenerate time.Time `orm:"type(datetime);column(last_click_generate)" json:"-"` //上次点击上传文档的时间,用于显示频繁点击浪费服务器硬件资源的情况 Version int64 `orm:"type(bigint);column(version);default(0)" json:"version"` Vcnt int `orm:"column(vcnt);default(0)" json:"vcnt"` // 书籍被阅读次数 Star int `orm:"column(star);default(0)" json:"star"` // 书籍被收藏次数 Score int `orm:"column(score);default(40)" json:"score"` // 书籍评分,默认40,即4.0星 CntScore int // 评分人数 CntComment int // 评论人数 Author string `orm:"size(50)"` //原作者,即来源 AuthorURL string `orm:"column(author_url)"` //原作者链接,即来源链接 AdTitle string `orm:"default()"` // 文字广告标题 AdLink string `orm:"default();size(512)"` // 文字广告链接 Lang string `orm:"size(10);index;default(zh)"` IsFreeRead int8 `orm:"type(tinyint);column(is_free_read);default(1)" json:"is_free_read"` }
Book struct .
func (*Book) FindByField ¶
根据指定字段查询结果集.
func (*Book) FindByFieldFirst ¶
根据指定字段查询一个结果.
func (*Book) FindByIdentify ¶
func (*Book) FindForHomeToPager ¶
func (m *Book) FindForHomeToPager(pageIndex, pageSize, member_id int, orderType string) (books []*BookResult, totalCount int, err error)
分页查找系统首页数据.
func (*Book) FindForLabelToPager ¶
func (m *Book) FindForLabelToPager(keyword string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error)
分页全局搜索.
func (*Book) FindToPager ¶
func (m *Book) FindToPager(pageIndex, pageSize, memberId int, PrivatelyOwned ...int) (books []*BookResult, totalCount int, err error)
分页查询指定用户的书籍 按照最新的进行排序
func (*Book) GetBooksById ¶
根据书籍id获取(公开的)书籍
func (*Book) HasProjectAccess ¶
minRole 最小的角色权限 conf.BookFounder conf.BookAdmin conf.BookEditor conf.BookObserver
func (*Book) HomeData ¶
func (m *Book) HomeData(pageIndex, pageSize int, orderType BookOrder, lang string, cid int, fields ...string) (books []Book, totalCount int, err error)
首页数据 完善根据分类查询数据 orderType:排序条件,可选值:recommend(推荐)、latest()
func (*Book) SearchBook ¶
搜索书籍,这里只返回book_id
func (*Book) SearchBookByLabel ¶
func (b *Book) SearchBookByLabel(labels []string, limit int, excludeIds []int) (bookIds []int, err error)
search books with labels
func (*Book) TableNameWithPrefix ¶
func (*Book) ToBookResult ¶
func (book *Book) ToBookResult() (m *BookResult)
type BookCategory ¶
书籍与分类关联表,一个书籍可以属于多个分类
func (*BookCategory) GetByBookId ¶
func (this *BookCategory) GetByBookId(book_id int) (cates []Category, rows int64, err error)
根据书籍id查询分类id
func (*BookCategory) SetBookCates ¶
func (this *BookCategory) SetBookCates(bookId int, cids []string)
处理书籍分类
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 ¶
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) 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"` IsFreeRead int8 `json:"is_free_read"` }
func NewBookResult ¶
func NewBookResult() *BookResult
func (*BookResult) FindByIdentify ¶
func (m *BookResult) FindByIdentify(identify string, memberId int) (result *BookResult, err error)
根据书籍标识查询书籍以及指定用户权限的信息.
func (*BookResult) FindToPager ¶
func (m *BookResult) FindToPager(pageIndex, pageSize int, private int, wd ...string) (books []*BookResult, totalCount int, err error)
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 BookId int `orm:"index"` //书籍id,主要是为了方便根据书籍id查询书签 Uid int //用户id DocId int //文档id CreateAt int //创建时间 }
书签
func NewBookmark ¶
func NewBookmark() *Bookmark
func (*Bookmark) Delete ¶
删除书签 1、只有 bookId > 0,则删除bookId所有书签【用于书籍被删除的情况】 2、bookId>0 && uid > 0 ,删除用户的书籍书签【用户用户清空书签的情况】 3、uid > 0 && docId>0 ,删除指定书签【用于删除某条书签】 4、其余情况不做处理
func (*Bookmark) InsertOrDelete ¶
添加或移除书签(如果书签不存在,则添加书签,如果书签存在,则移除书签)
type Category ¶
type Category struct { Id int `json:"id"` //自增主键 Pid int `json:"pid"` //分类id Title string `orm:"size(30);unique" json:"title,omitempty"` //分类名称 Intro string `json:"intro,omitempty"` //介绍 Icon string `json:"icon,omitempty"` //分类icon Cnt int `json:"cnt,omitempty"` //分类下的书籍统计 Sort int `json:"sort,omitempty"` //排序 Status bool `json:"status,omitempty"` //分类状态,true表示显示,否则表示隐藏 }
分类
func NewCategory ¶
func NewCategory() *Category
func (*Category) CategoryOfUserCollection ¶
用户收藏了的书籍的分类
type CommentCount ¶
type Comments ¶
type Comments struct { Id int Uid int `orm:"index"` //用户id BookId int `orm:"index"` //书籍id Content string //评论内容 TimeCreate time.Time //评论时间 Status int8 // 审核状态; 0,待审核,1 通过,-1 不通过 }
评论表
func NewComments ¶
func NewComments() *Comments
func (*Comments) AddComments ¶
添加评论
func (*Comments) Comments ¶
func (this *Comments) Comments(p, listRows, bookId int, status ...int) (comments []BookCommentsResult, err error)
获取可显示的评论内容
func (*Comments) SetCommentStatus ¶
type Config ¶
type Config struct { Id int // Key string //键 Value string //值 Statement string //描述 Cate string //分类 }
配置项
type Credit ¶
type Credit struct { }
func (*Credit) CreditCostPerMonth ¶
CreditCostPerMonth 每月成本估算,price 表示一元钱等于多少个积分。 计算结果计算网站一个月大概支出多少,以及一个勤奋的用户大概能拿到多少等价金额 注意:为避免积分规则设置错误,或者是积分规则设置者“滥发货币”引起不必要的“破产问题”,
建议积分每个月限定总额兑换机制,兑换完就自行等待下次兑换。具体可以参考微信支付出行奖励积分兑换机制玩法, 避免积分在跟实体金额兑换的时候玩死自己....
type CreditLog ¶
type CreditLog struct { Id int Uid int `orm:"index"` // 用户ID Identify string `orm:"index;size(32)"` // 规则标识 Score int // 积分,有正有负数,负数表示被扣分,正数表示加分 RewardBy int // 被谁奖励的,0 表示为系统奖励的,如果 Uid == RewardBy,表示用户自己充值的(如果有这个功能的话),否则表示是管理员(需要是管理员身份)打赏的 Log string `orm:"size(512)"` // 日志内容 CreatedAt time.Time `orm:"auto_now"` }
CreditLog 积分变更日志记录
func NewCreditLog ¶
func NewCreditLog() *CreditLog
type CreditRule ¶
type CreditRule struct { Id int // 规则ID Identify string `orm:"unique;size(32)"` // 积分标识,唯一 Title string // 规则名称 Intro string // 规则简介 Score int // 周期内每次奖励的积分 CycleType int8 // 奖励周期 RewardTimes int // 周次内总共奖励的次数 CreatedAt time.Time UpdatedAt time.Time }
CreditRule 规则
func NewCreditRule ¶
func NewCreditRule() *CreditRule
type Dashboard ¶
type Dashboard struct { BookNumber int64 `json:"book_number"` BookNumberToday int64 `json:"book_number_today"` DocumentNumber int64 `json:"document_number"` DocumentNumberToday int64 `json:"document_number_today"` MemberNumber int64 `json:"member_number"` MemberNumberToday int64 `json:"member_number_today"` CommentNumber int64 `json:"comment_number"` CommentNumberToday int64 `json:"comment_number_today"` AttachmentNumber int64 `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 `orm:"pk;auto;column(document_id)" json:"doc_id"` DocumentName string `orm:"column(document_name);size(500)" json:"doc_name"` Identify string `orm:"column(identify);size(100);index;null;default(null)" json:"identify"` // Identify 文档唯一标识 BookId int `orm:"column(book_id);type(int);index" json:"book_id"` ParentId int `orm:"column(parent_id);type(int);index;default(0)" json:"parent_id"` OrderSort int `orm:"column(order_sort);default(0);type(int);index" json:"order_sort"` Release string `orm:"column(release);type(text);null" json:"release"` // Release 发布后的Html格式内容. CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"` MemberId int `orm:"column(member_id);type(int)" json:"member_id"` ModifyTime time.Time `orm:"column(modify_time);type(datetime);default(null)" json:"modify_time"` ModifyAt int `orm:"column(modify_at);type(int)" json:"-"` Version int64 `orm:"type(bigint);column(version)" json:"version"` AttachList []*Attachment `orm:"-" json:"attach"` Vcnt int `orm:"column(vcnt);default(0)" json:"vcnt"` //书籍被浏览次数 Markdown string `orm:"-" json:"markdown"` IsFreeRead int8 `json:"is_free_read"` }
Document struct.
func NewDocument ¶
func NewDocument() *Document
func (*Document) BookStackAuto ¶
自动生成下一级的内容
func (*Document) BookStackCrawl ¶
func (m *Document) BookStackCrawl(html, md string, bookId, uid int) (content, markdown string, err error)
爬虫批量采集 @param html html @param md markdown内容 @return content,markdown 把链接替换为标识后的内容
func (*Document) CreateDocumentTreeForHtml ¶
func (*Document) FindByBookIdAndDocIdentify ¶
根据指定字段查询一条文档.
func (*Document) FindByFieldFirst ¶
根据指定字段查询一条文档.
func (*Document) FindDocumentTree ¶
func (m *Document) FindDocumentTree(bookId int, selectedId int, isEdit ...bool) ([]*DocumentTree, error)
获取书籍的文档树状结构
func (*Document) FindListByBookId ¶
func (m *Document) FindListByBookId(bookId int, withoutContent ...bool) (docs []*Document, err error)
根据书籍ID查询文档列表(含文档内容).
func (*Document) GetMenuTop ¶
根据书籍ID查询文档一级目录.
func (*Document) GetParentTitle ¶
func (*Document) InsertOrUpdate ¶
插入和更新文档. 存在文档id或者文档标识,则表示更新文档内容
func (*Document) RecursiveDocument ¶
递归删除一个文档.
func (*Document) ReleaseContent ¶
发布文档内容为HTML
func (*Document) SplitMarkdownAndStore ¶
markdown 文档拆分
func (*Document) TableNameWithPrefix ¶
type DocumentHistory ¶
type DocumentHistory struct { HistoryId int `orm:"column(history_id);pk;auto;unique" json:"history_id"` Action string `orm:"column(action);size(255)" json:"action"` ActionName string `orm:"column(action_name);size(255)" json:"action_name"` DocumentId int `orm:"column(document_id);type(int);index" json:"doc_id"` DocumentName string `orm:"column(document_name);size(500)" json:"doc_name"` ParentId int `orm:"column(parent_id);type(int);index;default(0)" json:"parent_id"` MemberId int `orm:"column(member_id);type(int);index" json:"member_id"` ModifyTime time.Time `orm:"column(modify_time);type(datetime);auto_now" json:"modify_time"` ModifyAt int `orm:"column(modify_at);type(int)" json:"-"` Version int64 `orm:"type(bigint);column(version)" json:"version"` }
func NewDocumentHistory ¶
func NewDocumentHistory() *DocumentHistory
func (*DocumentHistory) DeleteByDocumentId ¶
func (history *DocumentHistory) DeleteByDocumentId(docId int) (err error)
根据文档id删除记录
func (*DocumentHistory) DeleteByHistoryId ¶
func (history *DocumentHistory) DeleteByHistoryId(historyId int) (err error)
根据history id 删除记录
func (*DocumentHistory) DeleteByLimit ¶
func (history *DocumentHistory) DeleteByLimit(docId, limit int) (err error)
根据文档id删除
func (*DocumentHistory) Find ¶
func (m *DocumentHistory) Find(id int) (*DocumentHistory, error)
func (*DocumentHistory) FindToPager ¶
func (m *DocumentHistory) FindToPager(docId, pageIndex, pageSize int) (docs []*DocumentHistorySimpleResult, totalCount int, err error)
分页查询指定文档的历史.
func (*DocumentHistory) InsertOrUpdate ¶
func (m *DocumentHistory) InsertOrUpdate() (history *DocumentHistory, err error)
func (*DocumentHistory) Restore ¶
func (history *DocumentHistory) Restore(historyId, docId, uid int) (err error)
恢复指定历史的文档.
func (*DocumentHistory) TableEngine ¶
func (m *DocumentHistory) TableEngine() string
TableEngine 获取数据使用的引擎.
func (*DocumentHistory) TableName ¶
func (m *DocumentHistory) TableName() string
TableName 获取对应数据库表名.
func (*DocumentHistory) TableNameWithPrefix ¶
func (m *DocumentHistory) TableNameWithPrefix() string
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"` }
func NewDocumentSearchResult ¶
func NewDocumentSearchResult() *DocumentSearchResult
func (*DocumentSearchResult) FindToPager ¶
func (m *DocumentSearchResult) FindToPager(keyword string, pageIndex, pageSize, memberId int) (searchResult []*DocumentSearchResult, totalCount int, err error)
分页全局搜索.
func (*DocumentSearchResult) GetDocsById ¶
func (m *DocumentSearchResult) GetDocsById(id []int, withoutCont ...bool) (docs []DocResult, err error)
根据id查询搜索结果
func (*DocumentSearchResult) SearchDocument ¶
func (m *DocumentSearchResult) SearchDocument(keyword string, bookId int, page, size int) (docs []*DocumentSearchResult, cnt int, err error)
书籍内搜索.
type DocumentSelected ¶
type DocumentStore ¶
type DocumentStore struct { DocumentId int `orm:"pk;auto;column(document_id)"` //文档id,对应Document中的document_id Markdown string `orm:"type(text);"` //markdown内容 Content string `orm:"type(text);"` //文本内容 UpdatedAt time.Time `orm:"null"` }
Document Store,文档存储,将大内容分发到专门的数据表里面
func NewDocumentStore ¶
func NewDocumentStore() *DocumentStore
func (*DocumentStore) DeleteById ¶
func (this *DocumentStore) DeleteById(docId ...interface{})
查询markdown内容或者content内容
func (*DocumentStore) GetById ¶
func (this *DocumentStore) GetById(docId interface{}) (ds DocumentStore, err error)
查询markdown内容或者content内容
func (*DocumentStore) GetFiledById ¶
func (this *DocumentStore) GetFiledById(docId interface{}, field string) string
查询markdown内容或者content内容
func (*DocumentStore) InsertOrUpdate ¶
func (this *DocumentStore) InsertOrUpdate(ds DocumentStore, fields ...string) (err error)
插入或者更新
type DocumentTree ¶
type DownloadCounter ¶
func NewDownloadCounter ¶
func NewDownloadCounter() *DownloadCounter
func (*DownloadCounter) DoesICanDownload ¶
func (m *DownloadCounter) DoesICanDownload(uid int) (times int, min int)
大于0,表示还可以下载多少个文档 小于0,表示没有限制
func (*DownloadCounter) Increase ¶
func (m *DownloadCounter) Increase(uid int) (err error)
type ElasticSearchClient ¶
type ElasticSearchClient struct { Host string //host Index string //索引 Type string //type On bool //是否启用全文搜索 Timeout time.Duration //超时时间 IsRelateSearch bool }
全文搜索客户端
func (*ElasticSearchClient) BuildIndex ¶
func (this *ElasticSearchClient) BuildIndex(es ElasticSearchData) (err error)
创建索引
func (*ElasticSearchClient) BuildIndexByBuck ¶
func (this *ElasticSearchClient) BuildIndexByBuck(data []ElasticSearchData) (err error)
通过bulk,批量创建/更新索引
func (*ElasticSearchClient) Count ¶
func (this *ElasticSearchClient) Count() (count int, err error)
查询索引量 @return count 统计数据 @return err 错误
func (*ElasticSearchClient) DeleteIndex ¶
func (this *ElasticSearchClient) DeleteIndex(id int, isBook bool) (err error)
删除书籍索引
func (*ElasticSearchClient) Init ¶
func (this *ElasticSearchClient) Init() (err error)
初始化全文搜索客户端,包括检查索引是否存在,mapping设置等
func (*ElasticSearchClient) RebuildAllIndex ¶
func (this *ElasticSearchClient) RebuildAllIndex(bookId ...int)
重建索引【全量】 采用批量重建索引的方式进行 每次操作100条数据
func (*ElasticSearchClient) Search ¶
func (this *ElasticSearchClient) Search(wd string, p, listRows int, isSearchDoc bool, bookId ...int) (result ElasticSearchResult, err error)
搜索内容 如果书籍id大于0,则表示搜索指定的书籍的文档。否则表示搜索书籍 如果不指定书籍id,则只能搜索
func (*ElasticSearchClient) SegWords ¶
func (this *ElasticSearchClient) SegWords(keyword string) string
查询分词
func (*ElasticSearchClient) SetBookPublic ¶
func (this *ElasticSearchClient) SetBookPublic(bookId int, public bool) (err error)
设置书籍的公有和私有,需要根据文档同时更新文档的公有和私有
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 ¶
粉丝表
func (*Fans) FollowOrCancel ¶
关注和取消关注
func (*Fans) GetFansList ¶
func (this *Fans) GetFansList(uid, page, pageSize int) (fans []FansResult, total int64, err error)
查询用户的粉丝(用户id作为被关注对象)
func (*Fans) GetFollowList ¶
func (this *Fans) GetFollowList(fansId, page, pageSize int) (fans []FansResult, total int64, err error)
查询用户的关注(用户id作为fans_id)
type FriendLink ¶
type FriendLink struct { Id int //自增主键 Sort int //排序 Link string `orm:"unique;size(128)"` //链接地址 Title string //链接名称 Remark string `orm:"default()"` // 备注 Status bool `orm:"default(1)"` //状态 }
友链数据表
func (*FriendLink) GetList ¶
func (this *FriendLink) GetList(all bool) (links []FriendLink)
查询友链列表 all表示是否查询全部,当为false时,只查询启用状态的友链,否则查询全部
type Github ¶
type Github struct {
oauth.GithubUser
}
type Label ¶
type Label struct { LabelId int `orm:"column(label_id);pk;auto;unique;" json:"label_id"` LabelName string `orm:"column(label_name);size(50);unique" json:"label_name"` BookNumber int `orm:"column(book_number)" json:"book_number"` }
func (*Label) FindToPager ¶
func (m *Label) FindToPager(pageIndex, pageSize int, word ...string) (labels []*Label, totalCount int, err error)
分页查找标签.
func (*Label) InsertOrUpdate ¶
插入或更新标签.
func (*Label) TableNameWithPrefix ¶
type Logger ¶
type Logger struct { LoggerId int64 `orm:"pk;auto;unique;column(log_id)" json:"log_id"` MemberId int `orm:"column(member_id);type(int)" json:"member_id"` // 日志类别:operate 操作日志/ system 系统日志/ exception 异常日志 / document 文档操作日志 Category string `orm:"column(category);size(255);default(operate)" json:"category"` Content string `orm:"column(content);type(text)" json:"content"` OriginalData string `orm:"column(original_data);type(text)" json:"original_data"` PresentData string `orm:"column(present_data);type(text)" json:"present_data"` CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` UserAgent string `orm:"column(user_agent);size(500)" json:"user_agent"` IPAddress string `orm:"column(ip_address);size(255)" json:"ip_address"` }
Logger struct .
func (*Logger) TableNameWithPrefix ¶
type Member ¶
type Member struct { MemberId int `orm:"pk;auto;column(member_id)" json:"member_id"` Account string `orm:"size(30);unique;column(account)" json:"account"` Nickname string `orm:"size(30);unique;column(nickname)" json:"nickname"` //昵称 Password string `orm:"column(password);size(512)" json:"-"` AuthMethod string `orm:"column(auth_method);default(local);size(50);" json:"auth_method"` //认证方式: local 本地数据库 /ldap LDAP Description string `orm:"column(description);size(2000)" json:"description"` Email string `orm:"size(100);column(email);unique" json:"email"` Phone string `orm:"size(255);column(phone);null;default(null)" json:"phone"` Avatar string `orm:"column(avatar)" json:"avatar"` Role int `orm:"column(role);type(int);default(1);index" json:"role"` //用户角色:0 超级管理员 /1 管理员/ 2 普通用户 . RoleName string `orm:"-" json:"role_name"` Status int `orm:"column(status);type(int);default(0)" json:"status"` //用户状态:0 正常/1 禁用 CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` CreateAt int `orm:"type(int);column(create_at)" json:"create_at"` LastLoginTime time.Time `orm:"type(datetime);column(last_login_time);null" json:"last_login_time"` Wxpay string `json:"wxpay"` // 微信支付的收款二维码 Alipay string `json:"alipay"` // 支付宝支付的收款二维码 TotalReadingTime int `json:"total_reading_time" orm:"default(0)"` // 总阅读时长 TotalSign int `json:"total_sign" orm:"default(0);index"` // 总签到天数 TotalContinuousSign int `json:"total_continuous_sign" orm:"default(0);index"` // 总连续签到天数 HistoryTotalContinuousSign int `json:"history_total_continuous_sign" orm:"default(0);index"` // 历史最高连续签到天数 WechatNO string `json:"wechat_no" orm:"column(wechat_no);size(50)"` // 微信号 NoRank bool `json:"no_rank" orm:"default(0);index"` // 是否禁止榜单排行 ReadLevel int8 `json:"read_level" orm:"default(0);"` // 阅读等级 0代表免费 1代表付费 }
member
func (*Member) FindByAccount ¶
根据账号查找用户.
func (*Member) FindByFieldFirst ¶
根据指定字段查找用户.
func (*Member) FindByNickname ¶
func (*Member) FindToPager ¶
func (m *Member) FindToPager(pageIndex, pageSize int, wd string, role ...int) ([]*Member, int64, error)
分页查找用户.
func (*Member) GetByUsername ¶
获取用户信息,根据用户名或邮箱
func (*Member) GetQrcodeByUid ¶
根据用户id获取二维码
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 `orm:"column(token_id);pk;auto;unique" json:"token_id"` MemberId int `orm:"column(member_id);type(int)" json:"member_id"` Token string `orm:"column(token);size(150);index" json:"token"` Email string `orm:"column(email);size(255)" json:"email"` IsValid bool `orm:"column(is_valid)" json:"is_valid"` ValidTime time.Time `orm:"column(valid_time);null" json:"valid_time"` SendTime time.Time `orm:"column(send_time);auto_now_add;type(datetime)" json:"send_time"` }
func NewMemberToken ¶
func NewMemberToken() *MemberToken
func (*MemberToken) FindByFieldFirst ¶
func (m *MemberToken) FindByFieldFirst(field string, value interface{}) (*MemberToken, error)
func (*MemberToken) FindSendCount ¶
func (*MemberToken) InsertOrUpdate ¶
func (m *MemberToken) InsertOrUpdate() (*MemberToken, error)
func (*MemberToken) TableNameWithPrefix ¶
func (m *MemberToken) TableNameWithPrefix() string
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 `orm:"column(option_id);pk;auto;unique;" json:"option_id"` OptionTitle string `orm:"column(option_title);size(500)" json:"option_title"` OptionName string `orm:"column(option_name);unique;size(80)" json:"option_name"` OptionValue string `orm:"column(option_value);type(text);null" json:"option_value"` Remark string `orm:"column(remark);type(text);null" json:"remark"` }
Option struct .
func (*Option) ForbiddenReferer ¶
func (*Option) InsertMulti ¶
func (*Option) InsertOrUpdate ¶
func (*Option) IsResponseEmptyForAPP ¶
func (*Option) TableNameWithPrefix ¶
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 ¶
阅读统计 用来记录一本书(假设有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 //自增主键 BookId int `orm:"index"` //书籍id DocId int //文档id Uid int `orm:"index"` //用户id CreateAt int //记录创建时间,也就是内容阅读时间 }
阅读记录.用于记录阅读的文档,以及阅读进度统计
func NewReadRecord ¶
func NewReadRecord() *ReadRecord
func (*ReadRecord) BooksProgress ¶
func (this *ReadRecord) BooksProgress(uid int, bookId ...int) (read map[int]int)
查询阅读进度
func (*ReadRecord) Clear ¶
func (this *ReadRecord) Clear(uid, bookId int) (err error)
清空阅读记录 当删除书籍时,直接删除该书籍的所有记录
func (*ReadRecord) HistoryReadBook ¶
func (this *ReadRecord) HistoryReadBook(uid, page, size int) (books []Book)
func (*ReadRecord) LastReading ¶
func (this *ReadRecord) LastReading(uid int, cols ...string) (r ReadRecord)
查询用户最后的一条阅读记录
func (*ReadRecord) List ¶
func (this *ReadRecord) List(uid, bookId int) (lists []RecordList, cnt int64, err error)
查询阅读记录
func (*ReadRecord) Progress ¶
func (this *ReadRecord) Progress(uid, bookId int) (rp ReadProgress, err error)
查询阅读进度
type ReadingSortedUser ¶
type ReadingTime ¶
阅读时长
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) 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 NewRegLimit ¶
func NewRegLimit() (rl *RegLimit)
func (*RegLimit) CheckIPIsAllowed ¶
type RelateBook ¶
func NewRelateBook ¶
func NewRelateBook() *RelateBook
type Relationship ¶
type Relationship struct { RelationshipId int `orm:"pk;auto;unique;column(relationship_id)" json:"relationship_id"` MemberId int `orm:"column(member_id);type(int)" json:"member_id"` BookId int `orm:"column(book_id);type(int);index" json:"book_id"` RoleId int `orm:"column(role_id);type(int);index" json:"role_id"` // RoleId 角色:0 创始人(创始人不能被移除) / 1 管理员/2 编辑者/3 观察者 }
func NewRelationship ¶
func NewRelationship() *Relationship
func (*Relationship) DeleteByBookIdAndMemberId ¶
func (m *Relationship) DeleteByBookIdAndMemberId(bookId, memberId int) error
func (*Relationship) Find ¶
func (m *Relationship) Find(id int) (*Relationship, error)
func (*Relationship) FindByBookIdAndMemberId ¶
func (m *Relationship) FindByBookIdAndMemberId(bookId, memberId int) (*Relationship, error)
func (*Relationship) FindForRoleId ¶
func (m *Relationship) FindForRoleId(bookId, memberId int) (int, error)
func (*Relationship) FindFounder ¶
func (m *Relationship) FindFounder(bookId int) (*Relationship, error)
查询指定书籍的创始人.
func (*Relationship) HasRelatedBook ¶
func (m *Relationship) HasRelatedBook(uid int) bool
HasRelatedBook 查询用户是否有相关联的书籍
func (*Relationship) Insert ¶
func (m *Relationship) Insert() error
func (*Relationship) TableEngine ¶
func (m *Relationship) TableEngine() string
TableEngine 获取数据使用的引擎.
func (*Relationship) TableNameWithPrefix ¶
func (m *Relationship) TableNameWithPrefix() string
func (*Relationship) Transfer ¶
func (m *Relationship) Transfer(bookId, founderId, receiveId int) error
func (*Relationship) Update ¶
func (m *Relationship) Update() error
func (*Relationship) UpdateRoleId ¶
func (m *Relationship) UpdateRoleId(bookId, memberId, roleId int) (*Relationship, error)
type Score ¶
评分表
func (*Score) BookScoreByUid ¶
查询用户对文档的评分
func (*Score) BookScores ¶
func (this *Score) BookScores(p, listRows, bookId int) (scores []BookScoresResult, err error)
获取评分内容
type Seo ¶
type Seo struct { Id int //自增主键 Page string `orm:"unique;size(50)"` //页面 Statement string //页面说明 Title string `orm:"default({title})"` //SEO标题 Keywords string `orm:"default({keywords})"` //SEO关键字 Description string `orm:"default({description})"` //SEO摘要 }
SEO struct .
type Sign ¶
type Sign struct { Id int Uid int `orm:"index"` // 签到的用户id Day int `orm:"index"` // 签到日期,如20200101 Reward int // 奖励的阅读秒数 FromApp bool CreatedAt time.Time }
会员签到表
func (*Sign) LatestSignTime ¶
func (*Sign) SortedByPeriod ¶
type SitemapDocs ¶
func SitemapData ¶
func SitemapData(page, listRows int) (totalRows int64, sitemaps []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 Star struct { Id int Uid int `orm:"index"` //用户id,user id Bid int //书籍id,book id LastRead int `orm:"index;default(0)"` //最后阅读书剑 }
func (*Star) List ¶
func (this *Star) List(uid, p, listRows int, cid int, order ...string) (cnt int64, books []StarResult, err error)
获取收藏列表,查询书籍信息
func (*Star) SetLastReadTime ¶
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 SubmitBooks ¶
type SubmitBooks struct { Id int Uid int `orm:"index"` // 注意: nickname 和 account 是不存储用户昵称和账户的。orm:"-" 的时候,beego自带的orm没法将用户的数据匹配到字段上来,所以用这种勉强的方式 Nickname string `orm:"default();size(1)"` Account string `orm:"default();size(1)"` Title string `form:"title"` Url string `form:"url"` UrlMd5 string `orm:"size(32);unique"` Message string `orm:"size(512)" form:"message"` Status bool CreatedAt time.Time UpdatedAt time.Time CreatedAtStr string `orm:"-"` }
func NewSubmitBooks ¶
func NewSubmitBooks() *SubmitBooks
func (*SubmitBooks) Add ¶
func (m *SubmitBooks) Add() (err error)
func (*SubmitBooks) Lists ¶
func (m *SubmitBooks) Lists(page, size int, status ...bool) (books []SubmitBooks, total int64, err error)
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 Wechat ¶
type Wechat struct { Id int MemberId int //绑定的用户id Openid string `orm:"unique;size(50)"` Unionid string `orm:"size(50)"` AvatarURL string `orm:"column(avatar_url)"` Nickname string `orm:"size(30)"` SessKey string `orm:"size(50);unique"` }
func (*Wechat) GetUserByOpenid ¶
根据giteeid获取用户的gitee数据。这里可以查询用户是否绑定了或者数据是否在库中存在
func (*Wechat) GetUserBySess ¶
根据giteeid获取用户的gitee数据。这里可以查询用户是否绑定了或者数据是否在库中存在
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
- banner.go
- base.go
- book.go
- book_category.go
- book_counter.go
- book_result.go
- bookmarks.go
- category.go
- comments.go
- config.go
- course.go
- credit.go
- dashboard.go
- document.go
- document_history.go
- document_search_result.go
- document_store.go
- document_tree.go
- download_counter.go
- elasticsearch.go
- errors.go
- fans.go
- friendlink.go
- gitee.go
- github.go
- label.go
- logs.go
- member.go
- member_result.go
- member_token.go
- migrations.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
- submit_books.go
- ticket.go
- version_control.go
- wechat.go
- wechat_code.go