Skip to content

Commit

Permalink
Merge pull request mindoc-org#822 from haimait/master-sql-comment
Browse files Browse the repository at this point in the history
1.迁移表时添加字段注释 2.修复游客状态评论接口报空指针的问题
  • Loading branch information
gsw945 authored Oct 28, 2022
2 parents 4c6ef05 + 2862cb7 commit d430106
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 121 deletions.
9 changes: 6 additions & 3 deletions controllers/CommentController.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func (c *CommentController) Lists() {
page := pagination.PageUtil(int(count), pageIndex, conf.PageSize, comments)

var data struct {
DocId int `json:"doc_id"`
Page pagination.Page `json:"page"`
DocId int `json:"doc_id"`
Page pagination.Page `json:"page"`
}
data.DocId = docid
data.Page = page
Expand All @@ -43,6 +43,9 @@ func (c *CommentController) Create() {

m := models.NewComment()
m.DocumentId = id
if c.Member == nil {
c.JsonResult(1, "请先登录,再评论")
}
if len(c.Member.RealName) != 0 {
m.Author = c.Member.RealName
} else {
Expand All @@ -56,7 +59,7 @@ func (c *CommentController) Create() {
m.Insert()

var data struct {
DocId int `json:"doc_id"`
DocId int `json:"doc_id"`
}
data.DocId = id

Expand Down
20 changes: 10 additions & 10 deletions models/AttachmentModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ import (
// Attachment struct .
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"`
BookId int `orm:"column(book_id);type(int);description(所属book id)" json:"book_id"`
DocumentId int `orm:"column(document_id);type(int);null;description(所属文档id)" json:"doc_id"`
FileName string `orm:"column(file_name);size(255);description(文件名称)" json:"file_name"`
FilePath string `orm:"column(file_path);size(2000);description(文件路径)" json:"file_path"`
FileSize float64 `orm:"column(file_size);type(float);description(文件大小 字节)" json:"file_size"`
HttpPath string `orm:"column(http_path);size(2000);description(文件路径)" json:"http_path"`
FileExt string `orm:"column(file_ext);size(50);description(文件后缀)" json:"file_ext"`
CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add;description(创建时间)" json:"create_time"`
CreateAt int `orm:"column(create_at);type(int);description(创建人id)" json:"create_at"`
}

// TableName 获取对应数据库表名.
// TableName 获取对应上传附件数据库表名.
func (m *Attachment) TableName() string {
return "attachment"
}
Expand Down
30 changes: 15 additions & 15 deletions models/Blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,45 @@ import (
type Blog struct {
BlogId int `orm:"pk;auto;unique;column(blog_id)" json:"blog_id"`
//文章标题
BlogTitle string `orm:"column(blog_title);size(500)" json:"blog_title"`
BlogTitle string `orm:"column(blog_title);size(500);description(文章标题)" json:"blog_title"`
//文章标识
BlogIdentify string `orm:"column(blog_identify);size(100);unique" json:"blog_identify"`
BlogIdentify string `orm:"column(blog_identify);size(100);unique;description(文章标识)" json:"blog_identify"`
//排序序号
OrderIndex int `orm:"column(order_index);type(int);default(0)" json:"order_index"`
OrderIndex int `orm:"column(order_index);type(int);default(0);description(排序序号)" json:"order_index"`
//所属用户
MemberId int `orm:"column(member_id);type(int);default(0);index" json:"member_id"`
MemberId int `orm:"column(member_id);type(int);default(0);index;description(所属用户)" json:"member_id"`
//用户头像
MemberAvatar string `orm:"-" json:"member_avatar"`
//文章类型:0 普通文章/1 链接文章
BlogType int `orm:"column(blog_type);type(int);default(0)" json:"blog_type"`
BlogType int `orm:"column(blog_type);type(int);default(0);description(文章类型: 0普通文章/1 链接文章)" json:"blog_type"`
//链接到的项目中的文档ID
DocumentId int `orm:"column(document_id);type(int);default(0)" json:"document_id"`
DocumentId int `orm:"column(document_id);type(int);default(0);description(链接到的项目中的文档ID)" json:"document_id"`
//文章的标识
DocumentIdentify string `orm:"-" json:"document_identify"`
//关联文档的项目标识
BookIdentify string `orm:"-" json:"book_identify"`
//关联文档的项目ID
BookId int `orm:"-" json:"book_id"`
//文章摘要
BlogExcerpt string `orm:"column(blog_excerpt);size(1500)" json:"blog_excerpt"`
BlogExcerpt string `orm:"column(blog_excerpt);size(1500);description(文章摘要)" json:"blog_excerpt"`
//文章内容
BlogContent string `orm:"column(blog_content);type(text);null" json:"blog_content"`
BlogContent string `orm:"column(blog_content);type(text);null;description(文章内容)" json:"blog_content"`
//发布后的文章内容
BlogRelease string `orm:"column(blog_release);type(text);null" json:"blog_release"`
BlogRelease string `orm:"column(blog_release);type(text);null;description(发布后的文章内容)" json:"blog_release"`
//文章当前的状态,枚举enum(’publish’,’draft’,’password’)值,publish为已 发表,draft为草稿,password 为私人内容(不会被公开) 。默认为publish。
BlogStatus string `orm:"column(blog_status);size(100);default(publish)" json:"blog_status"`
BlogStatus string `orm:"column(blog_status);size(100);default(publish);description(状态:publish为已发表-默认,draft:草稿,password :私人内容-不会被公开)" json:"blog_status"`
//文章密码,varchar(100)值。文章编辑才可为文章设定一个密码,凭这个密码才能对文章进行重新强加或修改。
Password string `orm:"column(password);size(100)" json:"-"`
Password string `orm:"column(password);size(100);description(文章密码)" json:"-"`
//最后修改时间
Modified time.Time `orm:"column(modify_time);type(datetime);auto_now" json:"modify_time"`
Modified time.Time `orm:"column(modify_time);type(datetime);auto_now;description(最后修改时间)" json:"modify_time"`
//修改人id
ModifyAt int `orm:"column(modify_at);type(int)" json:"-"`
ModifyAt int `orm:"column(modify_at);type(int);description(修改人id)" json:"-"`
ModifyRealName string `orm:"-" json:"modify_real_name"`
//创建时间
Created time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
Created time.Time `orm:"column(create_time);type(datetime);auto_now_add;description(创建时间)" json:"create_time"`
CreateName string `orm:"-" json:"create_name"`
//版本号
Version int64 `orm:"type(bigint);column(version)" json:"version"`
Version int64 `orm:"type(bigint);column(version);description(版本号)" json:"version"`
//附件列表
AttachList []*Attachment `orm:"-" json:"attach_list"`
}
Expand Down
54 changes: 27 additions & 27 deletions models/BookModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,53 @@ var once = sync.Once{}
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"`
BookName string `orm:"column(book_name);size(500);description(名称)" json:"book_name"`
//所属项目空间
ItemId int `orm:"column(item_id);type(int);default(1)" json:"item_id"`
ItemId int `orm:"column(item_id);type(int);default(1);description(所属项目空间id)" json:"item_id"`
// Identify 项目唯一标识.
Identify string `orm:"column(identify);size(100);unique" json:"identify"`
Identify string `orm:"column(identify);size(100);unique;description(唯一标识)" json:"identify"`
//是否是自动发布 0 否/1 是
AutoRelease int `orm:"column(auto_release);type(int);default(0)" json:"auto_release"`
AutoRelease int `orm:"column(auto_release);type(int);default(0);description(是否是自动发布 0 否/1 是)" json:"auto_release"`
//是否开启下载功能 0 是/1 否
IsDownload int `orm:"column(is_download);type(int);default(0)" json:"is_download"`
OrderIndex int `orm:"column(order_index);type(int);default(0)" json:"order_index"`
IsDownload int `orm:"column(is_download);type(int);default(0);description(是否开启下载功能 0 是/1 否)" json:"is_download"`
OrderIndex int `orm:"column(order_index);type(int);default(0);description(排序)" json:"order_index"`
// Description 项目描述.
Description string `orm:"column(description);size(2000)" json:"description"`
Description string `orm:"column(description);size(2000);description(项目描述)" json:"description"`
//发行公司
Publisher string `orm:"column(publisher);size(500)" json:"publisher"`
Label string `orm:"column(label);size(500)" json:"label"`
Publisher string `orm:"column(publisher);size(500);description(发行公司)" json:"publisher"`
Label string `orm:"column(label);size(500);description(所属标签)" json:"label"`
// PrivatelyOwned 项目私有: 0 公开/ 1 私有
PrivatelyOwned int `orm:"column(privately_owned);type(int);default(0)" json:"privately_owned"`
PrivatelyOwned int `orm:"column(privately_owned);type(int);default(0);description(项目私有: 0 公开/ 1 私有)" json:"privately_owned"`
// 当项目是私有时的访问Token.
PrivateToken string `orm:"column(private_token);size(500);null" json:"private_token"`
PrivateToken string `orm:"column(private_token);size(500);null;description(当项目是私有时的访问Token)" json:"private_token"`
//访问密码.
BookPassword string `orm:"column(book_password);size(500);null" json:"book_password"`
BookPassword string `orm:"column(book_password);size(500);null;description(访问密码)" json:"book_password"`
//状态:0 正常/1 已删除
Status int `orm:"column(status);type(int);default(0)" json:"status"`
Status int `orm:"column(status);type(int);default(0);description(状态:0 正常/1 已删除)" json:"status"`
//默认的编辑器.
Editor string `orm:"column(editor);size(50)" json:"editor"`
Editor string `orm:"column(editor);size(50);description(默认的编辑器 markdown/html)" json:"editor"`
// DocCount 包含文档数量.
DocCount int `orm:"column(doc_count);type(int)" json:"doc_count"`
DocCount int `orm:"column(doc_count);type(int);description(包含文档数量)" 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"`
CommentStatus string `orm:"column(comment_status);size(20);default(open);description(评论设置的状态:open 为允许所有人评论,closed 为不允许评论, group_only 仅允许参与者评论 ,registered_only 仅允许注册者评论.)" json:"comment_status"`
CommentCount int `orm:"column(comment_count);type(int);description(评论数量)" json:"comment_count"`
//封面地址
Cover string `orm:"column(cover);size(1000)" json:"cover"`
Cover string `orm:"column(cover);size(1000);description(封面地址)" json:"cover"`
//主题风格
Theme string `orm:"column(theme);size(255);default(default)" json:"theme"`
Theme string `orm:"column(theme);size(255);default(default);description(主题风格)" json:"theme"`
// CreateTime 创建时间 .
CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"`
CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add;description(创建时间)" json:"create_time"`
//每个文档保存的历史记录数量,0 为不限制
HistoryCount int `orm:"column(history_count);type(int);default(0)" json:"history_count"`
HistoryCount int `orm:"column(history_count);type(int);default(0);description(每个文档保存的历史记录数量,0 为不限制)" json:"history_count"`
//是否启用分享,0启用/1不启用
IsEnableShare int `orm:"column(is_enable_share);type(int);default(0)" json:"is_enable_share"`
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"`
IsEnableShare int `orm:"column(is_enable_share);type(int);default(0);description(是否启用分享,0启用/1不启用)" json:"is_enable_share"`
MemberId int `orm:"column(member_id);size(100);description(作者id)" json:"member_id"`
ModifyTime time.Time `orm:"type(datetime);column(modify_time);null;auto_now;description(修改时间)" json:"modify_time"`
Version int64 `orm:"type(bigint);column(version);description(版本)" json:"version"`
//是否使用第一篇文章项目为默认首页,0 否/1 是
IsUseFirstDocument int `orm:"column(is_use_first_document);type(int);default(0)" json:"is_use_first_document"`
IsUseFirstDocument int `orm:"column(is_use_first_document);type(int);default(0);description(是否使用第一篇文章项目为默认首页,0 否/1 是)" json:"is_use_first_document"`
//是否开启自动保存:0 否/1 是
AutoSave int `orm:"column(auto_save);type(tinyint);default(0)" json:"auto_save"`
AutoSave int `orm:"column(auto_save);type(tinyint);default(0);description(是否开启自动保存:0 否/1 是)" json:"auto_save"`
}

func (book *Book) String() string {
Expand Down
24 changes: 12 additions & 12 deletions models/DocumentHistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import (

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"`
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
Action string `orm:"column(action);size(255);description(modify)" json:"action"`
ActionName string `orm:"column(action_name);size(255);description(修改文档)" json:"action_name"`
DocumentId int `orm:"column(document_id);type(int);index;description(关联文档id)" json:"doc_id"`
DocumentName string `orm:"column(document_name);size(500);description(关联文档id)" json:"doc_name"`
ParentId int `orm:"column(parent_id);type(int);index;default(0);description(父级文档id)" json:"parent_id"`
Markdown string `orm:"column(markdown);type(text);null;description(文档内容)" json:"markdown"`
Content string `orm:"column(content);type(text);null;description(文档内容)" json:"content"`
MemberId int `orm:"column(member_id);type(int);description(作者id)" json:"member_id"`
ModifyTime time.Time `orm:"column(modify_time);type(datetime);auto_now;description(修改时间)" json:"modify_time"`
ModifyAt int `orm:"column(modify_at);type(int);description(修改人id)" json:"-"`
Version int64 `orm:"type(bigint);column(version);description(版本)" json:"version"`
IsOpen int `orm:"column(is_open);type(int);default(0);description(是否展开子目录 0:阅读时关闭节点 1:阅读时展开节点 2:空目录 单击时会展开下级节点)" json:"is_open"`
}

type DocumentHistorySimpleResult struct {
Expand Down
30 changes: 15 additions & 15 deletions models/DocumentModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ import (
// Document struct.
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"`
DocumentName string `orm:"column(document_name);size(500);description(文档名称)" 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"`
Identify string `orm:"column(identify);size(100);index;null;default(null);description(唯一标识)" json:"identify"`
BookId int `orm:"column(book_id);type(int);index;description(关联bools表主键)" json:"book_id"`
ParentId int `orm:"column(parent_id);type(int);index;default(0);description(父级文档)" json:"parent_id"`
OrderSort int `orm:"column(order_sort);default(0);type(int);index;description(排序从小到大排序)" json:"order_sort"`
// Markdown markdown格式文档.
Markdown string `orm:"column(markdown);type(text);null" json:"markdown"`
Markdown string `orm:"column(markdown);type(text);null;description(markdown内容)" json:"markdown"`
// Release 发布后的Html格式内容.
Release string `orm:"column(release);type(text);null" json:"release"`
Release string `orm:"column(release);type(text);null;description(文章内容)" 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:"column(version);type(bigint);" json:"version"`
Content string `orm:"column(content);type(text);null;description(文章内容)" json:"content"`
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add;description(创建时间)" json:"create_time"`
MemberId int `orm:"column(member_id);type(int);description(关系用户id)" json:"member_id"`
ModifyTime time.Time `orm:"column(modify_time);type(datetime);auto_now;description(修改时间)" json:"modify_time"`
ModifyAt int `orm:"column(modify_at);type(int);description(修改人id)" json:"-"`
Version int64 `orm:"column(version);type(bigint);description(版本,关联历史文档里的version)" json:"version"`
//是否展开子目录:0 否/1 是 /2 空间节点,单击时展开下一级
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
ViewCount int `orm:"column(view_count);type(int)" json:"view_count"`
IsOpen int `orm:"column(is_open);type(int);default(0);description(是否展开子目录 0:阅读时关闭节点 1:阅读时展开节点 2:空目录 单击时会展开下级节点)" json:"is_open"`
ViewCount int `orm:"column(view_count);type(int);description(浏览量)" json:"view_count"`
AttachList []*Attachment `orm:"-" json:"attach"`
//i18n
Lang string `orm:"-"`
Expand Down
Loading

0 comments on commit d430106

Please sign in to comment.