Documentation ¶
Overview ¶
Package models 为项目所需的模型对象定义.
Package models .
Index ¶
- Constants
- Variables
- func GetOptionValue(key, def string) string
- type Attachment
- type Book
- func (m *Book) Find(id int) (*Book, error)
- func (m *Book) FindByField(field string, value interface{}) ([]*Book, error)
- func (m *Book) FindByFieldFirst(field string, value interface{}) (*Book, error)
- func (m *Book) FindForHomeToPager(pageIndex, pageSize, member_id int) (books []*BookResult, totalCount int, err error)
- func (m *Book) FindToPager(pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error)
- func (m *Book) Insert() error
- func (m *Book) ResetDocumentNumber(book_id int)
- func (m *Book) TableEngine() string
- func (m *Book) TableName() string
- func (m *Book) TableNameWithPrefix() string
- func (m *Book) ThoroughDeleteBook(id int) error
- func (book *Book) ToBookResult() *BookResult
- func (m *Book) Update(cols ...string) error
- type BookResult
- type Comment
- type CommentResult
- type CommentVote
- type Dashboard
- type Document
- func (m *Document) CreateDocumentTreeForHtml(book_id, selected_id int) (string, error)
- func (m *Document) Find(id int) (*Document, error)
- func (m *Document) FindByFieldFirst(field string, v interface{}) (*Document, error)
- func (m *Document) FindDocumentTree(book_id int) ([]*DocumentTree, error)
- func (m *Document) InsertOrUpdate(cols ...string) error
- func (m *Document) RecursiveDocument(doc_id int) error
- func (m *Document) ReleaseContent(book_id int)
- func (m *Document) TableEngine() string
- func (m *Document) TableName() string
- func (m *Document) TableNameWithPrefix() string
- type DocumentSearchResult
- type DocumentSelected
- type DocumentTree
- type Logger
- type Member
- func (m *Member) Add() error
- func (m *Member) Find(id int) (*Member, error)
- func (m *Member) FindByAccount(account string) (*Member, error)
- func (m *Member) FindByFieldFirst(field string, value interface{}) (*Member, error)
- func (m *Member) FindToPager(pageIndex, pageSize int) ([]*Member, int64, error)
- func (c *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
- type MemberRelationshipResult
- type MemberToken
- func (m *MemberToken) FindByFieldFirst(field string, value interface{}) (*MemberToken, error)
- func (m *MemberToken) FindSendCount(mail string, start_time time.Time, end_time 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 Model
- 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 (p *Option) InsertMulti(option ...Option) error
- func (p *Option) InsertOrUpdate() error
- func (m *Option) TableEngine() string
- func (m *Option) TableName() string
- func (m *Option) TableNameWithPrefix() string
- type Relationship
- func (m *Relationship) DeleteByBookIdAndMemberId(book_id, member_id int) error
- func (m *Relationship) Find(id int) (*Relationship, error)
- func (m *Relationship) FindByBookIdAndMemberId(book_id, member_id int) (*Relationship, error)
- func (m *Relationship) FindForRoleId(book_id, member_id int) (int, error)
- 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(book_id, founder_id, receive_id int) error
- func (m *Relationship) Update() error
- func (m *Relationship) UpdateRoleId(book_id, member_id, role_id int) (*Relationship, error)
Constants ¶
View Source
const ( Logger_Operate = "operate" Logger_System = "system" Logger_Exception = "exception" )
Variables ¶
View Source
var ( // ErrMemberNoExist 用户不存在. ErrMemberNoExist = errors.New("用户不存在") ErrMemberDisabled = errors.New("用户被禁用") // ErrorMemberPasswordError 密码错误. ErrorMemberPasswordError = errors.New("用户密码错误") // ErrDataNotExist 指定的服务已存在. ErrDataNotExist = errors.New("数据不存在") // ErrInvalidParameter 参数错误. ErrInvalidParameter = errors.New("Invalid parameter") ErrPermissionDenied = errors.New("Permission denied") ErrCommentClosed = errors.New("评论已关闭") ErrCommentContentNotEmpty = errors.New("评论内容不能为空") )
Functions ¶
func GetOptionValue ¶
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"` CreateAt int `orm:"column(create_at);type(int)" json:"create_at"` }
Attachment struct .
func NewAttachment ¶
func NewAttachment() *Attachment
func (*Attachment) Find ¶
func (m *Attachment) Find(id int) (*Attachment, 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 Book ¶
type Book struct { BookId int `orm:"pk;auto;unique;column(book_id)" json:"book_id"` // BookName 项目名称. BookName string `orm:"column(book_name);size(500)" json:"book_name"` // Identify 项目唯一标识. Identify string `orm:"column(identify);size(100);unique" json:"identify"` OrderIndex int `orm:"column(order_index);type(int);default(0)" json:"order_index"` // Description 项目描述. Description string `orm:"column(description);size(2000)" json:"description"` Label string `orm:"column(label);size(500)" json:"label"` // PrivatelyOwned 项目私有: 0 公开/ 1 私有 PrivatelyOwned int `orm:"column(privately_owned);type(int);default(0)" json:"privately_owned"` // 当项目是私有时的访问Token. PrivateToken string `orm:"column(private_token);size(500);null" json:"private_token"` //状态:0 正常/1 已删除 Status int `orm:"column(status);type(int);default(0)" json:"status"` //默认的编辑器. Editor string `orm:"column(editor);size(50)" json:"editor"` // DocCount 包含文档数量. DocCount int `orm:"column(doc_count);type(int)" json:"doc_count"` // CommentStatus 评论设置的状态:open 为允许所有人评论,closed 为不允许评论, group_only 仅允许参与者评论 ,registered_only 仅允许注册者评论. CommentStatus string `orm:"column(comment_status);size(20);default(open)" json:"comment_status"` CommentCount int `orm:"column(comment_count);type(int)" json:"comment_count"` //封面地址 Cover string `orm:"column(cover);size(1000)" json:"cover"` //主题风格 Theme string `orm:"columen(theme);size(255);default(default)" json:"theme"` // CreateTime 创建时间 . CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` MemberId int `orm:"column(member_id);size(100)" json:"member_id"` ModifyTime time.Time `orm:"type(datetime);column(modify_time);null;auto_now" json:"modify_time"` Version int64 `orm:"type(bigint);column(version)" json:"version"` }
Book struct .
func (*Book) FindByField ¶
根据指定字段查询结果集.
func (*Book) FindByFieldFirst ¶
根据指定字段查询一个结果.
func (*Book) FindForHomeToPager ¶
func (m *Book) FindForHomeToPager(pageIndex, pageSize, member_id int) (books []*BookResult, totalCount int, err error)
func (*Book) FindToPager ¶
func (m *Book) FindToPager(pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error)
分页查询指定用户的项目
func (*Book) TableNameWithPrefix ¶
func (*Book) ToBookResult ¶
func (book *Book) ToBookResult() *BookResult
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"` Editor string `json:"editor"` RelationshipId int `json:"relationship_id"` RoleId int `json:"role_id"` RoleName string `json:"role_name"` Status int 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) (books []*BookResult, totalCount int, 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) TableNameWithPrefix ¶
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) TableNameWithPrefix ¶
func (m *CommentVote) TableNameWithPrefix() string
func (*CommentVote) TableUnique ¶
func (u *CommentVote) TableUnique() [][]string
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
type Document ¶
type Document struct { DocumentId int `orm:"pk;auto;unique;column(document_id)" json:"doc_id"` DocumentName string `orm:"column(document_name);size(500)" json:"doc_name"` // Identify 文档唯一标识 Identify string `orm:"column(identify);size(100);index;null;default(null)" json:"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 markdown格式文档. Markdown string `orm:"column(markdown);type(text);null" json:"markdown"` // Release 发布后的Html格式内容. Release string `orm:"column(release);type(text);null" json:"release"` // Content 未发布的 Html 格式内容. Content string `orm:"column(content);type(text);null" json:"content"` 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);auto_now" json:"modify_time"` ModifyAt int `orm:"column(modify_at);type(int)" json:"-"` Version int64 `orm:"type(bigint);column(version)" json:"version"` }
Document struct.
func NewDocument ¶
func NewDocument() *Document
func (*Document) CreateDocumentTreeForHtml ¶
func (*Document) FindByFieldFirst ¶
根据指定字段查询一条文档.
func (*Document) FindDocumentTree ¶
func (m *Document) FindDocumentTree(book_id int) ([]*DocumentTree, error)
获取项目的文档树状结构
func (*Document) RecursiveDocument ¶
递归删除一个文档.
func (*Document) TableNameWithPrefix ¶
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)
type DocumentSelected ¶
type DocumentTree ¶
type Logger ¶
type Logger struct { LoggerId int64 `orm:"pk;auto;unique;column(logger_id)" json:"logger_id"` MemberId int `orm:"column(member_id);type(int)" json:"member_id"` // 日志类别:operate 操作日志/ system 系统日志/ exception 异常日志 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;unique;column(member_id)" json:"member_id"` Account string `orm:"size(100);unique;column(account)" json:"account"` Password string `orm:"size(1000);column(password)" json:"-"` 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:"size(1000);column(avatar)" json:"avatar"` //用户角色:0 超级管理员 /1 管理员/ 2 普通用户 . Role int `orm:"column(role);type(int);default(1);index" json:"role"` 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"` }
func (*Member) FindByFieldFirst ¶
func (*Member) FindToPager ¶
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"` }
func NewMemberRelationshipResult ¶
func NewMemberRelationshipResult() *MemberRelationshipResult
func (*MemberRelationshipResult) FindForUsersByBookId ¶
func (m *MemberRelationshipResult) FindForUsersByBookId(book_id, 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 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) InsertMulti ¶
func (*Option) InsertOrUpdate ¶
func (*Option) TableNameWithPrefix ¶
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) 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(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)
Click to show internal directories.
Click to hide internal directories.