mysql

package
v0.0.0-...-8d6dda1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

数据库模型.

Package mysql 为项目所需的模型对象定义.

Package mysql .

Index

Constants

View Source
const (
	AdsPositionBeforeFriendLink        = "global-before-friend-link"
	AdsPositionGlobalFooter            = "global-footer"
	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"
	AdsPositionUnderExploreNav         = "explore-under-nav"
	AdsPositionBeforeExplorePagination = "explore-before-pagination"
	AdsPositionUnderExplorePagination  = "explore-under-pagination"
	AdsPositionContentTop              = "content-top"
	AdsPositionContentBottom           = "content-bottom"
)
View Source
const (
	PeriodDay      period = "day"
	PeriodWeek     period = "week"
	PeriodLastWeek period = "last-week"
	PeriodMonth    period = "month"
	PeriodLastMoth period = "last-month"
	PeriodAll      period = "all"
	PeriodYear     period = "year"
)
View Source
const (
	QUEUE_STATUS_PADDING   int8 = 0 //待导出
	QUEUE_STATUS_EXPORTING int8 = 1 //导出中
	QUEUE_STATUS_FINISHED  int8 = 2 //导出完成
	QUEUE_STATUS_FAILED    int8 = 3 //导出失败
)

Variables

View Source
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("评论内容不能为空")
)
View Source
var ModelQQ = new(QQ)

Functions

func BuildQuery

func BuildQuery(conds Conds) (sql string, binds []interface{})

BuildQuery 根据conds构建sql和绑定的参数

func CountCategory

func CountCategory()

func GetAPIStaticDomain

func GetAPIStaticDomain() string

func GetAdsCode

func GetAdsCode(positionIdentify string, isMobile bool) (code string)

func Init

func Init()

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

func (*AdsCont) Lists

func (m *AdsCont) Lists(isMobile bool, status ...bool) (ads []AdsCont)

func (AdsCont) TableName

func (AdsCont) TableName() string

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

func (*Attachment) TableName

func (m *Attachment) TableName() string

TableName 获取对应数据库表名.

type AttachmentResult

type AttachmentResult struct {
	Attachment
	IsExist       bool
	BookName      string
	DocumentName  string
	FileShortSize string
	Account       string
	LocalHttpPath string
}

func NewAttachmentResult

func NewAttachmentResult() *AttachmentResult

type Auth

type Auth struct {
	Id    int
	Token string `orm:"size(32);unique"`
	Uid   int    `orm:"index"`
}

func NewAuth

func NewAuth() *Auth

func (*Auth) DeleteByToken

func (m *Auth) DeleteByToken(token string)

func (*Auth) GetByToken

func (m *Auth) GetByToken(token string) (auth Auth)

func (*Auth) Insert

func (m *Auth) Insert(token string, uid int) (err error)

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"`
}

func (Awesome) TableName

func (Awesome) TableName() string

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 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"`
}

func NewBanner

func NewBanner() *Banner

func (*Banner) TableName

func (m *Banner) TableName() string

TableName 获取对应数据库表名.

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 NewBook

func NewBook() *Book

func (*Book) DealAll

func (b *Book) DealAll()

func (*Book) DealCover

func (b *Book) DealCover()

func (Book) TableName

func (m Book) TableName() string

TableName 获取对应数据库表名.

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
}

文档项目与分类关联表,一个文档项目可以属于多个分类

func (BookCategory) TableName

func (m BookCategory) TableName() string

TableName 获取对应数据库表名.

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

func (Bookmark) TableName

func (Bookmark) TableName() string

func (*Bookmark) TableUnique

func (m *Bookmark) TableUnique() [][]string

多字段唯一键

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

func (Category) TableName

func (m Category) TableName() string

type CommentCount

type CommentCount struct {
	Id     int
	BookId int
	Cnt    int
}

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) Count

func (this *Comments) Count(bookId int, status ...int) (int64, error)

func (*Comments) SetCommentStatus

func (this *Comments) SetCommentStatus(id, status int) (err error)

func (Comments) TableName

func (Comments) TableName() string

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 Count

type Count struct {
	Cnt        int
	CategoryId int
}

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

func (*Dashboard) Query

func (m *Dashboard) Query() *Dashboard

type DataCount

type DataCount struct {
	Cnt int64
}

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

func (Document) TableName

func (m Document) TableName() string

TableName 获取对应数据库表名.

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

func (DocumentHistory) TableName

func (m DocumentHistory) TableName() string

TableName 获取对应数据库表名.

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 DocumentSelected struct {
	Selected bool `json:"selected"`
	Opened   bool `json:"opened"`
}

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 DocumentTree struct {
	DocumentId   int               `json:"id"`
	DocumentName string            `json:"text"`
	ParentId     interface{}       `json:"parent"`
	Identify     string            `json:"identify"`
	BookIdentify string            `json:"-"`
	Version      int64             `json:"version"`
	State        *DocumentSelected `json:"state,omitempty"`
}

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 (this *Fans) FollowOrCancel(uid, fansId int) (cancel bool, err error)

关注和取消关注

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)

func (*Fans) Relation

func (this *Fans) Relation(uid, fansId interface{}) (ok bool)

查询是否已经关注了用户

func (Fans) TableName

func (Fans) TableName() string

func (*Fans) TableUnique

func (this *Fans) TableUnique() [][]string

多字段唯一键

type FansResult

type FansResult struct {
	Uid      int
	Nickname string
	Avatar   string
	Account  string
}
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) Add

func (this *FriendLink) Add(title, link string) (err error)

添加友情链接

func (*FriendLink) Del

func (this *FriendLink) Del(id int) (err error)

删除友情链接

func (*FriendLink) GetList

func (this *FriendLink) GetList(all bool) (links []FriendLink)

查询友链列表 all表示是否查询全部,当为false时,只查询启用状态的友链,否则查询全部

func (FriendLink) TableName

func (FriendLink) TableName() string

func (*FriendLink) Update

func (this *FriendLink) Update(id int, field string, value interface{}) (err error)

根据字段更新友链

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获取数据

func (GithubUser) TableName

func (m GithubUser) TableName() string

TableName 获取对应数据库表名.

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 NewLabel

func NewLabel() *Label

func (*Label) TableEngine

func (m *Label) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Label) TableName

func (m *Label) TableName() string

TableName 获取对应数据库表名.

func (*Label) TableNameWithPrefix

func (m *Label) TableNameWithPrefix() string

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 NewLogger

func NewLogger() *Logs

func (*Logs) Add

func (m *Logs) Add() error

func (*Logs) TableEngine

func (m *Logs) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Logs) TableName

func (m *Logs) TableName() string

TableName 获取对应数据库表名.

func (*Logs) TableNameWithPrefix

func (m *Logs) TableNameWithPrefix() string

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 NewMember

func NewMember() *Member

func (*Member) Add

func (m *Member) Add() error

Add 添加一个用户.

func (*Member) FindByAccount

func (m *Member) FindByAccount(account string) (*Member, error)

根据账号查找用户.

func (*Member) FindByFieldFirst

func (m *Member) FindByFieldFirst(field string, value interface{}) (*Member, error)

根据指定字段查找用户.

func (*Member) GetByUsername

func (this *Member) GetByUsername(username string) (member Member, err error)

获取用户信息,根据用户名或邮箱

func (*Member) IsAdministrator

func (m *Member) IsAdministrator() bool

func (*Member) ResolveRoleName

func (m *Member) ResolveRoleName()

func (*Member) TableEngine

func (m *Member) TableEngine() string

TableEngine 获取数据使用的引擎.

func (Member) TableName

func (m Member) TableName() string

TableName 获取对应数据库表名.

func (*Member) TableNameWithPrefix

func (m *Member) TableNameWithPrefix() string

func (*Member) Update

func (m *Member) Update() error

Update 更新用户信息.

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 (*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

func (MemberToken) TableName

func (m MemberToken) TableName() string

TableName 获取对应数据库表名.

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) FindFirst

func (m *Migration) FindFirst() (*Migration, error)

func (*Migration) TableEngine

func (m *Migration) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Migration) TableName

func (m *Migration) TableName() string

TableName 获取对应数据库表名.

func (*Migration) TableNameWithPrefix

func (m *Migration) TableNameWithPrefix() string

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 .

func (Option) TableName

func (m Option) TableName() string

TableName 获取对应数据库表名.

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) Bind

func (this *QQ) Bind(openid, memberId interface{}) (err error)

绑定用户

func (*QQ) GetUserByOpenid

func (this *QQ) GetUserByOpenid(openid string, cols ...string) (user QQ, err error)

根据giteeid获取用户的gitee数据。这里可以查询用户是否绑定了或者数据是否在库中存在

func (*QQ) TableName

func (this *QQ) TableName() string

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 统计

func (ReadCount) TableName

func (ReadCount) TableName() string

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) Add

func (this *ReadRecord) Add(docId, uid int) (err error)

添加阅读记录

func (*ReadRecord) List

func (this *ReadRecord) List(uid, bookId int) (lists []RecordList, cnt int64, err error)

查询阅读记录

func (ReadRecord) TableName

func (ReadRecord) TableName() string

type ReadingRule

type ReadingRule struct {
	Min       int
	Max       int
	MaxReward int
	Invalid   int
}

阅读计时规则

type ReadingSortedUser

type ReadingSortedUser struct {
	Uid      int
	Account  string
	Nickname string
	Avatar   string
	SumTime  int
}

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 RecordList struct {
	DocId    int
	Title    string
	Identify string
	CreateAt int
}

阅读记录列表(非表)

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

func (rl *RegLimit) CheckIPIsAllowed(ip string) (allowHour, allowDaily bool)

func (*RegLimit) Insert

func (rl *RegLimit) Insert(ip string) (err error)

type RelateBook

type RelateBook struct {
	Id      int
	BookId  int `orm:"unique"`
	BookIds string
	Expire  int
}

func NewRelateBook

func NewRelateBook() *RelateBook

func (*RelateBook) Lists

func (r *RelateBook) Lists(bookId int, limit ...int) (books []Book)

Get the related books for a given book

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) TableName

func (m Relationship) TableName() string

TableName 获取对应数据库表名.

func (*Relationship) TableNameWithPrefix

func (m *Relationship) TableNameWithPrefix() string

func (*Relationship) TableUnique

func (u *Relationship) TableUnique() [][]string

联合唯一键

type Rule

type Rule struct {
	BasicReward         int
	ContinuousReward    int
	AppReward           int
	MaxContinuousReward int
}

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)

获取评分内容

func (Score) TableName

func (Score) TableName() string

func (*Score) TableUnique

func (this *Score) TableUnique() [][]string

多字段唯一键

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 .

func (Seo) TableName

func (Seo) TableName() string

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"`
}

会员签到表

func NewSign

func NewSign() *Sign

func (*Sign) GetSignRule

func (m *Sign) GetSignRule() (r *Rule)

获取签到奖励规则

func (*Sign) IsContinuousSign

func (m *Sign) IsContinuousSign(uid int) bool

是否未断签

func (*Sign) IsSignToday

func (m *Sign) IsSignToday(uid int) bool

今天是否已签到

func (*Sign) LatestOne

func (*Sign) LatestOne(uid int) (s Sign)

func (*Sign) Sign

func (m *Sign) Sign(uid int, fromApp bool) (reward int, err error)

执行签到。使用事务

func (*Sign) Sorted

func (m *Sign) Sorted(limit int, orderField string, withCache ...bool) (members []Member)

func (Sign) TableName

func (Sign) TableName() string

func (*Sign) TableUnique

func (m *Sign) TableUnique() [][]string

多字段唯一键

type SitemapDocs

type SitemapDocs struct {
	DocumentId   int
	DocumentName string
	Identify     string
	BookId       int
}

type SortedBook

type SortedBook struct {
	Id       int
	BookId   int
	Identify string
	Cover    string
	BookName string
	Cnt      int
}

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 `gorm:"not null;primary_key;AUTO_INCREMENT"json:"id"`
	Uid      int `gorm:"not null;index"json:"uid"` //用户id,user id
	Bid      int `gorm:"not null;"json:"bid"`      //书籍id,book id
	LastRead int `gorm:"not null;"json:"lastRead"` //最后阅读书剑
}

func (Star) TableName

func (Star) TableName() string

func (*Star) TableUnique

func (this *Star) TableUnique() [][]string

多字段唯一键

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 Tokens

type Tokens struct {
	Tokens []Token `json:"tokens"`
}

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"`
}

func (Tool) TableName

func (Tool) TableName() string

type Ups

type Ups = map[string]interface{}

Ups 为更新某一条记录时存放的变更数据集合 map[field.name]field.value

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已认证
}

func (User) TableName

func (User) TableName() string

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"`
}

func (Wechat) TableName

func (Wechat) TableName() string

type WechatCode

type WechatCode struct {
	Id     int
	BookId int    `orm:"unique"`
	Path   string `orm:"default()"`
}

微信小程序码记录表

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)

Jump to

Keyboard shortcuts

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