models

package
v1.0.1-0...-a87b900 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2018 License: Apache-2.0, Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

数据库模型.

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

Package models .

Index

Constants

This section is empty.

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 ModelGitee = new(Gitee)
View Source
var ModelGithub = new(Github)
View Source
var ModelQQ = new(QQ)
View Source
var ModelStoreLocal = new(store.Local)
View Source
var ModelStoreOss = new(store.Oss)
View Source
var TableDocumentStore = "md_document_store"
View Source
var TableSeo = "md_seo"

Functions

func GetOptionValue

func GetOptionValue(key, def string) string

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)

Types

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() error

func (*Attachment) Find

func (m *Attachment) Find(id int) (*Attachment, error)

func (*Attachment) FindListByDocumentId

func (m *Attachment) FindListByDocumentId(doc_id 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) TableEngine

func (m *Attachment) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Attachment) TableName

func (m *Attachment) TableName() string

TableName 获取对应数据库表名.

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
	DocumentName  string
	FileShortSize string
	Account       string
	LocalHttpPath string
}

func NewAttachmentResult

func NewAttachmentResult() *AttachmentResult

func (*AttachmentResult) Find

func (m *AttachmentResult) Find(id int) (*AttachmentResult, error)

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)" json:"order_index"`
	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)" json:"member_id"`
	ModifyTime        time.Time `orm:"type(datetime);column(modify_time);auto_now_add" 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       //评论人数
}

Book struct .

func NewBook

func NewBook() *Book

func (*Book) Find

func (m *Book) Find(id int) (*Book, error)

func (*Book) FindByField

func (m *Book) FindByField(field string, value interface{}) ([]*Book, error)

根据指定字段查询结果集.

func (*Book) FindByFieldFirst

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

根据指定字段查询一个结果.

func (*Book) FindByIdentify

func (m *Book) FindByIdentify(identify string) (*Book, error)

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, member_id 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) HomeData

func (m *Book) HomeData(pageIndex, pageSize int, orderType BookOrder, cid int, fields ...string) (books []Book, totalCount int, err error)

首页数据 TODO:完善根据分类查询数据 orderType:排序条件,可选值:recommend(推荐)、latest()

func (*Book) Insert

func (m *Book) Insert() error

func (*Book) ResetDocumentNumber

func (m *Book) ResetDocumentNumber(book_id int)

重置文档数量

func (*Book) TableEngine

func (m *Book) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Book) TableName

func (m *Book) TableName() string

TableName 获取对应数据库表名.

func (*Book) TableNameWithPrefix

func (m *Book) TableNameWithPrefix() string

func (*Book) ThoroughDeleteBook

func (m *Book) ThoroughDeleteBook(id int) error

彻底删除项目.

func (*Book) ToBookResult

func (book *Book) ToBookResult() *BookResult

func (*Book) Update

func (m *Book) Update(cols ...string) error

type BookCategory

type BookCategory struct {
	Id         int //自增主键
	BookId     int //书籍id
	CategoryId int //分类id
}

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

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(book_id int, cids []string)

处理书籍分类

func (*BookCategory) TableUnique

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

多字段唯一键

type BookCommentsResult

type BookCommentsResult struct {
	Uid        int       `json:"uid"`
	Score      int       `json:"score"`
	Avatar     string    `json:"avatar"`
	Nickname   string    `json:"nickname"`
	Content    string    `json:"content"`
	TimeCreate time.Time `json:"time_create"` //评论时间
}

评论内容

type BookOrder

type BookOrder string

定义书籍排序类型

const (
	OrderRecommend BookOrder = "recommend"
	OrderPopular   BookOrder = "popular"
	OrderLatest    BookOrder = "latest"
	OrderScore     BookOrder = "score"   //评分排序
	OrderComment   BookOrder = "comment" //评论排序
	OrderStar      BookOrder = "star"    //收藏排序
	OrderView      BookOrder = "vcnt"    //浏览排序
)

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

func NewBookResult

func NewBookResult() *BookResult

func (*BookResult) FindByIdentify

func (m *BookResult) FindByIdentify(identify string, member_id int) (*BookResult, error)

根据项目标识查询项目以及指定用户权限的信息.

func (*BookResult) FindToPager

func (m *BookResult) FindToPager(pageIndex, pageSize int, private ...int) (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 Category

type Category struct {
	Id     int    //自增主键
	Pid    int    //分类id
	Title  string `orm:"size(30);unique"` //分类名称
	Intro  string //介绍
	Icon   string //分类icon
	Cnt    int    //分类下的文档项目统计
	Sort   int    //排序
	Status bool   //分类状态,true表示显示,否则表示隐藏
}

分类

func (*Category) AddCates

func (this *Category) AddCates(pid int, cates string) (err error)

新增分类

func (*Category) Del

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

删除分类(如果分类下的文档项目不为0,则不允许删除)

func (*Category) Find

func (this *Category) Find(id int) (cate Category)

查询单个分类

func (*Category) GetCates

func (this *Category) GetCates(pid int, status int) (cates []Category, err error)

查询所有分类 @param pid -1表示不限(即查询全部),否则表示查询指定pid的分类 @param status -1表示不限状态(即查询所有状态的分类),0表示关闭状态,1表示启用状态

func (*Category) UpdateByField

func (this *Category) UpdateByField(id int, field, val string) (err error)

根据字段更新内容

type Comment

type Comment struct {
	CommentId int `orm:"pk;auto;unique;column(comment_id)" json:"comment_id"`
	Floor     int `orm:"column(floor);type(unsigned);default(0)" json:"floor"`
	BookId    int `orm:"column(book_id);type(int)" json:"book_id"`
	// DocumentId 评论所属的文档.
	DocumentId int `orm:"column(document_id);type(int)" json:"document_id"`
	// Author 评论作者.
	Author string `orm:"column(author);size(100)" json:"author"`
	//MemberId 评论用户ID.
	MemberId int `orm:"column(member_id);type(int)" json:"member_id"`
	// IPAddress 评论者的IP地址
	IPAddress string `orm:"column(ip_address);size(100)" json:"ip_address"`
	// 评论日期.
	CommentDate time.Time `orm:"type(datetime);column(comment_date);auto_now_add" json:"comment_date"`
	//Content 评论内容.
	Content string `orm:"column(content);size(2000)" json:"content"`
	// Approved 评论状态:0 待审核/1 已审核/2 垃圾评论/ 3 已删除
	Approved int `orm:"column(approved);type(int)" json:"approved"`
	// UserAgent 评论者浏览器内容
	UserAgent string `orm:"column(user_agent);size(500)" json:"user_agent"`
	// Parent 评论所属父级
	ParentId     int `orm:"column(parent_id);type(int);default(0)" json:"parent_id"`
	AgreeCount   int `orm:"column(agree_count);type(int);default(0)" json:"agree_count"`
	AgainstCount int `orm:"column(against_count);type(int);default(0)" json:"against_count"`
}

Comment struct

func NewComment

func NewComment() *Comment

func (*Comment) Find

func (m *Comment) Find(id int) (*Comment, error)

func (*Comment) Insert

func (m *Comment) Insert() error

Insert 添加一条评论.

func (*Comment) TableEngine

func (m *Comment) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Comment) TableName

func (m *Comment) TableName() string

TableName 获取对应数据库表名.

func (*Comment) TableNameWithPrefix

func (m *Comment) TableNameWithPrefix() string

func (*Comment) Update

func (m *Comment) Update(cols ...string) error

type CommentResult

type CommentResult struct {
	Comment
	Author       string `json:"author"`
	ReplyAccount string `json:"reply_account"`
}

func (*CommentResult) FindForDocumentToPager

func (m *CommentResult) FindForDocumentToPager(doc_id, page_index, page_size int) (comments []*CommentResult, totalCount int, err error)

type CommentVote

type CommentVote struct {
	VoteId          int       `orm:"column(vote_id);pk;auto;unique" json:"vote_id"`
	CommentId       int       `orm:"column(comment_id);type(int);index" json:"comment_id"`
	CommentMemberId int       `orm:"column(comment_member_id);type(int);index;default(0)" json:"comment_member_id"`
	VoteMemberId    int       `orm:"column(vote_member_id);type(int);index" json:"vote_member_id"`
	VoteState       int       `orm:"column(vote_state);type(int)" json:"vote_state"`
	CreateTime      time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
}

func NewCommentVote

func NewCommentVote() *CommentVote

func (*CommentVote) InsertOrUpdate

func (m *CommentVote) InsertOrUpdate() (*CommentVote, error)

func (*CommentVote) TableEngine

func (m *CommentVote) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*CommentVote) TableName

func (m *CommentVote) TableName() string

TableName 获取对应数据库表名.

func (*CommentVote) TableNameWithPrefix

func (m *CommentVote) TableNameWithPrefix() string

func (*CommentVote) TableUnique

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

type Comments

type Comments struct {
	Id         int
	Uid        int       `orm:"index"` //用户id
	BookId     int       `orm:"index"` //文档项目id
	Content    string    //评论内容
	TimeCreate time.Time //评论时间
}

评论表

func (*Comments) AddComments

func (this *Comments) AddComments(uid, book_id int, content string) (err error)

添加评论

func (*Comments) BookComments

func (this *Comments) BookComments(p, listRows, bookid int) (comments []BookCommentsResult, err error)

获取评论内容

type Dashboard

type Dashboard struct {
	BookNumber       int64 `json:"book_number"`
	DocumentNumber   int64 `json:"document_number"`
	MemberNumber     int64 `json:"member_number"`
	CommentNumber    int64 `json:"comment_number"`
	AttachmentNumber int64 `json:"attachment_number"`
}

func NewDashboard

func NewDashboard() *Dashboard

func (*Dashboard) Query

func (m *Dashboard) Query() *Dashboard

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"`
	//Markdown     string        `orm:"column(markdown);type(text);null" json:"markdown"` // Markdown markdown格式文档.
	Release string `orm:"column(release);type(text);null" json:"release"` // Release 发布后的Html格式内容.
	//Content      string        `orm:"column(content);type(text);null" json:"content"`   // Content 未发布的 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);auto_now" 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"`
}

Document struct.

func NewDocument

func NewDocument() *Document

func (*Document) CreateDocumentTreeForHtml

func (m *Document) CreateDocumentTreeForHtml(book_id, selected_id int) (string, error)

func (*Document) Find

func (m *Document) Find(id int) (*Document, error)

根据文档ID查询指定文档.

func (*Document) FindByBookIdAndDocIdentify

func (m *Document) FindByBookIdAndDocIdentify(BookId, Identify interface{}) (*Document, error)

根据指定字段查询一条文档.

func (*Document) FindByFieldFirst

func (m *Document) FindByFieldFirst(field string, v interface{}) (*Document, error)

根据指定字段查询一条文档.

func (*Document) FindDocumentTree

func (m *Document) FindDocumentTree(book_id int, isEdit ...bool) ([]*DocumentTree, error)

获取项目的文档树状结构

func (*Document) FindListByBookId

func (m *Document) FindListByBookId(book_id int) (docs []*Document, err error)

根据项目ID查询文档列表.

func (*Document) GenerateBook

func (m *Document) GenerateBook(book *Book, base_url string)

func (*Document) GetMenuTop

func (m *Document) GetMenuTop(book_id int) (docs []*Document, err error)

根据项目ID查询文档一级目录.

func (*Document) InsertOrUpdate

func (m *Document) InsertOrUpdate(cols ...string) (id int64, err error)

插入和更新文档.

func (*Document) RecursiveDocument

func (m *Document) RecursiveDocument(doc_id int) error

递归删除一个文档.

func (*Document) ReleaseContent

func (m *Document) ReleaseContent(book_id int, base_url string)

发布文档

func (*Document) TableEngine

func (m *Document) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Document) TableName

func (m *Document) TableName() string

TableName 获取对应数据库表名.

func (*Document) TableNameWithPrefix

func (m *Document) TableNameWithPrefix() string

func (*Document) TableUnique

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

多字段唯一键

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"`
	Markdown     string    `orm:"column(markdown);type(text);null" json:"markdown"`
	Content      string    `orm:"column(content);type(text);null" json:"content"`
	MemberId     int       `orm:"column(member_id);type(int)" 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) Clear

func (m *DocumentHistory) Clear(doc_id int) error

清空指定文档的历史.

func (*DocumentHistory) Delete

func (m *DocumentHistory) Delete(history_id, doc_id int) error

删除历史.

func (*DocumentHistory) Find

func (m *DocumentHistory) Find(id int) (*DocumentHistory, error)

func (*DocumentHistory) FindToPager

func (m *DocumentHistory) FindToPager(doc_id, page_index, page_size int) (docs []*DocumentHistorySimpleResult, totalCount int, err error)

分页查询指定文档的历史.

func (*DocumentHistory) InsertOrUpdate

func (m *DocumentHistory) InsertOrUpdate() (history *DocumentHistory, err error)

func (*DocumentHistory) Restore

func (m *DocumentHistory) Restore(history_id, doc_id, uid int) 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"`
	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"`
	DocumentName string `json:"doc_name"`
	// Identify 文档唯一标识
	Identify     string    `json:"identify"`
	Description  string    `json:"description"`
	Author       string    `json:"author"`
	ModifyTime   time.Time `json:"modify_time"`
	CreateTime   time.Time `json:"create_time"`
	BookId       int       `json:"book_id"`
	BookName     string    `json:"book_name"`
	BookIdentify string    `json:"book_identify"`
}

func NewDocumentSearchResult

func NewDocumentSearchResult() *DocumentSearchResult

func (*DocumentSearchResult) FindToPager

func (m *DocumentSearchResult) FindToPager(keyword string, page_index, page_size, member_id int) (search_result []*DocumentSearchResult, total_count int, err error)

分页全局搜索.

func (*DocumentSearchResult) SearchDocument

func (m *DocumentSearchResult) SearchDocument(keyword string, book_id int) (docs []*DocumentSearchResult, err error)

项目内搜索.

type DocumentSelected

type DocumentSelected struct {
	Selected bool `json:"selected"`
	Opened   bool `json:"opened"`
}

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);"`                 //文本内容
}

Document Store,文档存储,将大内容分发到专门的数据表里面

func (*DocumentStore) DeleteById

func (this *DocumentStore) DeleteById(document_id ...interface{})

查询markdown内容或者content内容

func (*DocumentStore) GetFiledById

func (this *DocumentStore) GetFiledById(document_id interface{}, field string) string

查询markdown内容或者content内容

func (*DocumentStore) InsertOrUpdate

func (this *DocumentStore) InsertOrUpdate(ds DocumentStore, fields ...string) (err error)

插入或者更新

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 Fans

type Fans struct {
	Id     int //自增主键
	Uid    int `orm:"index"` //被关注的用户id
	FansId int `orm:"index"` //粉丝id
}

粉丝表

func (*Fans) FollowOrCancle

func (this *Fans) FollowOrCancle(uid, fans_id int) (cancel bool, err error)

关注和取消关注

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(fans_id, page, pageSize int) (fans []FansResult, total int64, err error)

查询用户的关注(用户id作为fans_id)

func (*Fans) Relation

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

查询是否已经关注了用户

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    //自增主键
	Sort   int    //排序
	Link   string `orm:"unique"` //链接地址
	Title  string //链接名称
	Status bool   `orm:"default(1)"` //状态
}

友链数据表

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

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

根据字段更新友链

type Gitee

type Gitee struct {
	oauth.GiteeUser
}

func (*Gitee) Bind

func (this *Gitee) Bind(giteeId, memberId interface{}) (err error)

绑定用户

func (*Gitee) GetUserByGiteeId

func (this *Gitee) GetUserByGiteeId(id int, cols ...string) (user Gitee, err error)

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

type Github

type Github struct {
	oauth.GithubUser
}

func (*Github) Bind

func (this *Github) Bind(githubId, memberId interface{}) (err error)

绑定用户

func (*Github) GetUserByGithubId

func (this *Github) GetUserByGithubId(id int, cols ...string) (user Github, err error)

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

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 NewLabel

func NewLabel() *Label

func (*Label) FindFirst

func (m *Label) FindFirst(field string, value interface{}) (*Label, error)

func (*Label) FindToPager

func (m *Label) FindToPager(pageIndex, pageSize int) (labels []*Label, totalCount int, err error)

分页查找标签.

func (*Label) InsertOrUpdate

func (m *Label) InsertOrUpdate(labelName string) error

插入或更新标签.

func (*Label) InsertOrUpdateMulti

func (m *Label) InsertOrUpdateMulti(labels string)

批量插入或更新标签.

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 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 NewLogger

func NewLogger() *Logger

func (*Logger) Add

func (m *Logger) Add() error

func (*Logger) TableEngine

func (m *Logger) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Logger) TableName

func (m *Logger) TableName() string

TableName 获取对应数据库表名.

func (*Logger) TableNameWithPrefix

func (m *Logger) TableNameWithPrefix() string

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)" 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"` //支付宝支付的收款二维码
}

func NewMember

func NewMember() *Member

func (*Member) Add

func (m *Member) Add() error

Add 添加一个用户.

func (*Member) Delete

func (m *Member) Delete(oldId int, newId int) error

func (*Member) Find

func (m *Member) Find(id int) (*Member, error)

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

func (m *Member) FindToPager(pageIndex, pageSize int) ([]*Member, int64, error)

分页查找用户.

func (*Member) GetByUsername

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

根据用户名获取用户信息

func (*Member) GetNicknameByUid

func (m *Member) GetNicknameByUid(id interface{}) string

获取昵称

func (*Member) GetQrcodeByUid

func (m *Member) GetQrcodeByUid(uid interface{}) (qrcode map[string]string)

根据用户id获取二维码

func (*Member) GetUsernameByUid

func (m *Member) GetUsernameByUid(id interface{}) string

获取用户名

func (*Member) IsAdministrator

func (c *Member) IsAdministrator() bool

func (*Member) Login

func (m *Member) Login(account string, password string) (*Member, error)

Login 用户登录.

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(cols ...string) error

Update 更新用户信息.

func (*Member) Valid

func (m *Member) Valid(is_hash_password bool) error

校验用户.

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

func NewMemberRelationshipResult

func NewMemberRelationshipResult() *MemberRelationshipResult

func (*MemberRelationshipResult) FindForUsersByBookId

func (m *MemberRelationshipResult) FindForUsersByBookId(book_id, pageIndex, pageSize int) ([]*MemberRelationshipResult, int, error)

func (*MemberRelationshipResult) FromMember

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 (m *MemberToken) FindSendCount(mail string, start_time time.Time, end_time time.Time) (int, error)

func (*MemberToken) InsertOrUpdate

func (m *MemberToken) InsertOrUpdate() (*MemberToken, error)

func (*MemberToken) TableEngine

func (m *MemberToken) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*MemberToken) TableName

func (m *MemberToken) TableName() string

TableName 获取对应数据库表名.

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) 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    `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 NewOption

func NewOption() *Option

func (*Option) All

func (p *Option) All() ([]*Option, error)

func (*Option) Find

func (p *Option) Find(id int) (*Option, error)

func (*Option) FindByKey

func (p *Option) FindByKey(key string) (*Option, error)

func (*Option) Init

func (m *Option) Init() error

func (*Option) InsertMulti

func (p *Option) InsertMulti(option ...Option) error

func (*Option) InsertOrUpdate

func (p *Option) InsertOrUpdate() error

func (*Option) TableEngine

func (m *Option) TableEngine() string

TableEngine 获取数据使用的引擎.

func (*Option) TableName

func (m *Option) TableName() string

TableName 获取对应数据库表名.

func (*Option) TableNameWithPrefix

func (m *Option) TableNameWithPrefix() string

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 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)" json:"book_id"`
	// RoleId 角色:0 创始人(创始人不能被移除) / 1 管理员/2 编辑者/3 观察者
	RoleId int `orm:"column(role_id);type(int)" json:"role_id"`
}

func NewRelationship

func NewRelationship() *Relationship

func (*Relationship) DeleteByBookIdAndMemberId

func (m *Relationship) DeleteByBookIdAndMemberId(book_id, member_id int) error

func (*Relationship) Find

func (m *Relationship) Find(id int) (*Relationship, error)

func (*Relationship) FindByBookIdAndMemberId

func (m *Relationship) FindByBookIdAndMemberId(book_id, member_id int) (*Relationship, error)

func (*Relationship) FindForRoleId

func (m *Relationship) FindForRoleId(book_id, member_id int) (int, error)

func (*Relationship) FindFounder

func (m *Relationship) FindFounder(book_id int) (*Relationship, error)

查询指定项目的创始人.

func (*Relationship) Insert

func (m *Relationship) Insert() error

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

联合唯一键

func (*Relationship) Transfer

func (m *Relationship) Transfer(book_id, founder_id, receive_id int) error

func (*Relationship) Update

func (m *Relationship) Update() error

func (*Relationship) UpdateRoleId

func (m *Relationship) UpdateRoleId(book_id, member_id, role_id int) (*Relationship, error)

type Score

type Score struct {
	Id         int
	BookId     int
	Uid        int
	Score      int //评分
	TimeCreate time.Time
}

评分表

func (*Score) AddScore

func (this *Score) AddScore(uid, book_id, score int) (err error)

添加评分 score的值只能是1-5,然后需要对scorex10,50则表示5.0分

func (*Score) BookScoreByUid

func (this *Score) BookScoreByUid(uid, book_id interface{}) int

查询用户对文档的评分

func (*Score) BookScores

func (this *Score) BookScores(p, listRows, bookid int) (scores []BookScoresResult, err error)

获取评分内容

func (*Score) TableUnique

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

多字段唯一键

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 SitemapDocs

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

func SitemapData

func SitemapData(page, listRows int) (totalRows int64, sitemaps []SitemapDocs)

站点地图数据

type Star

type Star struct {
	Id  int
	Uid int `orm:"index"` //用户id,user id
	Bid int //书籍id,book id
}

func (*Star) DoesStar

func (this *Star) DoesStar(uid, bid interface{}) bool

是否收藏了文档

func (*Star) List

func (this *Star) List(uid, p, listRows int) (cnt int64, books []StarResult, err error)

获取收藏列表,查询项目信息

func (*Star) Star

func (this *Star) Star(uid, bid int) (cancel bool, err error)

收藏或者取消收藏 @param uid 用户id @param bid 书籍id @return cancel 是否是取消收藏,只是标记属于取消还是收藏操作,err才表示执行操作成功与否

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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