mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-10-21 11:27:26 +08:00
1、实现富文本编辑器
2、实现文档转换为PDF、MOBI、EPUB、Word格式 3、实现登录后跳转到来源地址
This commit is contained in:
@@ -23,14 +23,14 @@ type DocumentHistory struct {
|
||||
}
|
||||
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// TableName 获取对应数据库表名.
|
||||
@@ -50,12 +50,13 @@ func (m *DocumentHistory) TableNameWithPrefix() string {
|
||||
func NewDocumentHistory() *DocumentHistory {
|
||||
return &DocumentHistory{}
|
||||
}
|
||||
func (m *DocumentHistory) Find(id int) (*DocumentHistory,error) {
|
||||
func (m *DocumentHistory) Find(id int) (*DocumentHistory, error) {
|
||||
o := orm.NewOrm()
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("history_id",id).One(m)
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("history_id", id).One(m)
|
||||
|
||||
return m,err
|
||||
return m, err
|
||||
}
|
||||
|
||||
//清空指定文档的历史.
|
||||
func (m *DocumentHistory) Clear(doc_id int) error {
|
||||
o := orm.NewOrm()
|
||||
@@ -66,19 +67,19 @@ func (m *DocumentHistory) Clear(doc_id int) error {
|
||||
}
|
||||
|
||||
//删除历史.
|
||||
func (m *DocumentHistory) Delete(history_id,doc_id int) error {
|
||||
func (m *DocumentHistory) Delete(history_id, doc_id int) error {
|
||||
o := orm.NewOrm()
|
||||
|
||||
_, err := o.QueryTable(m.TableNameWithPrefix()).Filter("history_id",history_id).Filter("document_id",doc_id).Delete()
|
||||
_, err := o.QueryTable(m.TableNameWithPrefix()).Filter("history_id", history_id).Filter("document_id", doc_id).Delete()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
//恢复指定历史的文档.
|
||||
func (m *DocumentHistory) Restore(history_id,doc_id,uid int) error {
|
||||
func (m *DocumentHistory) Restore(history_id, doc_id, uid int) error {
|
||||
o := orm.NewOrm()
|
||||
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("history_id", history_id).Filter("document_id",doc_id).One(m)
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("history_id", history_id).Filter("document_id", doc_id).One(m)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -113,17 +114,18 @@ func (m *DocumentHistory) Restore(history_id,doc_id,uid int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *DocumentHistory) InsertOrUpdate() (history *DocumentHistory,err error) {
|
||||
func (m *DocumentHistory) InsertOrUpdate() (history *DocumentHistory, err error) {
|
||||
o := orm.NewOrm()
|
||||
history = m
|
||||
|
||||
if m.HistoryId > 0 {
|
||||
_,err = o.Update(m)
|
||||
}else{
|
||||
_,err = o.Insert(m)
|
||||
_, err = o.Update(m)
|
||||
} else {
|
||||
_, err = o.Insert(m)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//分页查询指定文档的历史.
|
||||
func (m *DocumentHistory) FindToPager(doc_id, page_index, page_size int) (docs []*DocumentHistorySimpleResult, totalCount int, err error) {
|
||||
|
||||
@@ -139,7 +141,7 @@ LEFT JOIN md_members AS m1 ON history.member_id = m1.member_id
|
||||
LEFT JOIN md_members AS m2 ON history.modify_at = m2.member_id
|
||||
WHERE history.document_id = ? ORDER BY history.history_id DESC LIMIT ?,?;`
|
||||
|
||||
_, err = o.Raw(sql,doc_id,offset,page_size).QueryRows(&docs)
|
||||
_, err = o.Raw(sql, doc_id, offset, page_size).QueryRows(&docs)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
|
Reference in New Issue
Block a user