controller 支持传递时间

This commit is contained in:
lealife
2015-11-28 13:47:59 +08:00
parent 6a1e84da0c
commit d13447e6d0
2 changed files with 30 additions and 16 deletions

View File

@ -3,7 +3,6 @@ package controllers
import ( import (
"github.com/revel/revel" "github.com/revel/revel"
// "encoding/json" // "encoding/json"
"fmt"
"github.com/leanote/leanote/app/info" "github.com/leanote/leanote/app/info"
. "github.com/leanote/leanote/app/lea" . "github.com/leanote/leanote/app/lea"
"gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2/bson"
@ -14,6 +13,7 @@ import (
"time" "time"
// "github.com/leanote/leanote/app/types" // "github.com/leanote/leanote/app/types"
// "io/ioutil" // "io/ioutil"
"fmt"
// "bytes" // "bytes"
// "os" // "os"
) )
@ -248,7 +248,8 @@ func (c Note) UpdateNoteOrContent(noteOrContent NoteOrContent) revel.Result {
// noteService.UpdateNoteContent(noteOrContent.UserId, c.GetUserId(), // noteService.UpdateNoteContent(noteOrContent.UserId, c.GetUserId(),
// noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract) // noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract)
contentOk, contentMsg, afterContentUsn = noteService.UpdateNoteContent(c.GetUserId(), contentOk, contentMsg, afterContentUsn = noteService.UpdateNoteContent(c.GetUserId(),
noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract, needUpdateNote, -1) noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract,
needUpdateNote, -1, time.Now())
} }
Log(afterContentUsn) Log(afterContentUsn)

View File

@ -85,7 +85,6 @@ func (c ApiNote) GetTrashNotes() revel.Result {
"Title": "asdfadsf--=", "Title": "asdfadsf--=",
"Desc": "", "Desc": "",
"Tags": [ "Tags": [
""
], ],
"Abstract": "", "Abstract": "",
"Content": "", "Content": "",
@ -95,7 +94,7 @@ func (c ApiNote) GetTrashNotes() revel.Result {
"Usn": 8, "Usn": 8,
"Files": [ "Files": [
{ {
"FileId": "551975d599c37b970f000002", "FileId": "551975d599c37b970f000000",
"LocalFileId": "", "LocalFileId": "",
"Type": "", "Type": "",
"Title": "", "Title": "",
@ -103,18 +102,18 @@ func (c ApiNote) GetTrashNotes() revel.Result {
"IsAttach": false "IsAttach": false
}, },
{ {
"FileId": "551975de99c37b970f000003", "FileId": "551975de99c37b970f000001",
"LocalFileId": "", "LocalFileId": "",
"Type": "doc", "Type": "doc",
"Title": "李铁-简历-ali-print-en.doc", "Title": "李铁-print-en.doc",
"HasBody": false, "HasBody": false,
"IsAttach": true "IsAttach": true
}, },
{ {
"FileId": "551975de99c37b970f000004", "FileId": "551975de99c37b970f000002",
"LocalFileId": "", "LocalFileId": "",
"Type": "doc", "Type": "doc",
"Title": "李铁-简历-ali-print.doc", "Title": "李铁-print.doc",
"HasBody": false, "HasBody": false,
"IsAttach": true "IsAttach": true
} }
@ -327,15 +326,20 @@ func (c ApiNote) AddNote(noteOrContent info.ApiNote) revel.Result {
Tags: noteOrContent.Tags, Tags: noteOrContent.Tags,
Desc: noteOrContent.Desc, Desc: noteOrContent.Desc,
// ImgSrc: noteOrContent.ImgSrc, // ImgSrc: noteOrContent.ImgSrc,
IsBlog: noteOrContent.IsBlog, IsBlog: noteOrContent.IsBlog,
IsMarkdown: noteOrContent.IsMarkdown, IsMarkdown: noteOrContent.IsMarkdown,
AttachNum: attachNum, AttachNum: attachNum,
CreatedTime: noteOrContent.CreatedTime,
UpdatedTime: noteOrContent.UpdatedTime,
} }
noteContent := info.NoteContent{NoteId: note.NoteId, noteContent := info.NoteContent{NoteId: note.NoteId,
UserId: userId, UserId: userId,
IsBlog: note.IsBlog, IsBlog: note.IsBlog,
Content: noteOrContent.Content, Content: noteOrContent.Content,
Abstract: noteOrContent.Abstract} Abstract: noteOrContent.Abstract,
CreatedTime: noteOrContent.CreatedTime,
UpdatedTime: noteOrContent.UpdatedTime,
}
// 通过内容得到Desc, abstract // 通过内容得到Desc, abstract
if noteOrContent.Abstract == "" { if noteOrContent.Abstract == "" {
@ -447,6 +451,7 @@ func (c ApiNote) UpdateNote(noteOrContent info.ApiNote) revel.Result {
// Log("after upload") // Log("after upload")
// LogJ(noteOrContent.Files) // LogJ(noteOrContent.Files)
} }
// 移到外面来, 删除最后一个file时也要处理, 不然总删不掉 // 移到外面来, 删除最后一个file时也要处理, 不然总删不掉
@ -509,6 +514,8 @@ func (c ApiNote) UpdateNote(noteOrContent info.ApiNote) revel.Result {
} }
} }
noteUpdate["UpdatedTime"] = noteOrContent.UpdatedTime
afterNoteUsn := 0 afterNoteUsn := 0
noteOk := false noteOk := false
noteMsg := "" noteMsg := ""
@ -532,10 +539,16 @@ func (c ApiNote) UpdateNote(noteOrContent info.ApiNote) revel.Result {
if noteOrContent.Abstract == "" { if noteOrContent.Abstract == "" {
noteOrContent.Abstract = SubStringHTML(noteOrContent.Content, 200, "") noteOrContent.Abstract = SubStringHTML(noteOrContent.Content, 200, "")
} }
// Log("--------> afte fixed") // Log("--------> afte fixed")
// Log(noteOrContent.Content) // Log(noteOrContent.Content)
contentOk, contentMsg, afterContentUsn = noteService.UpdateNoteContent(c.getUserId(), contentOk, contentMsg, afterContentUsn = noteService.UpdateNoteContent(c.getUserId(),
noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract, needUpdateNote, noteOrContent.Usn) noteOrContent.NoteId,
noteOrContent.Content,
noteOrContent.Abstract,
needUpdateNote,
noteOrContent.Usn,
noteOrContent.UpdatedTime)
} }
if needUpdateNote { if needUpdateNote {