fmt all go file

This commit is contained in:
lealife
2015-11-13 17:58:41 +08:00
parent cba69444a8
commit 7809d00787
100 changed files with 3375 additions and 3331 deletions

View File

@ -1,14 +1,13 @@
package service
import (
"github.com/leanote/leanote/app/db"
"github.com/leanote/leanote/app/info"
. "github.com/leanote/leanote/app/lea"
"github.com/leanote/leanote/app/db"
"gopkg.in/mgo.v2/bson"
"time"
)
type UpgradeService struct {
}
@ -16,7 +15,7 @@ type UpgradeService struct {
func (this *UpgradeService) UpgradeBlog() bool {
notes := []info.Note{}
db.ListByQ(db.Notes, bson.M{"IsBlog": true}, &notes)
// PublicTime, RecommendTime = UpdatedTime
for _, note := range notes {
if note.IsBlog && note.PublicTime.Year() < 100 {
@ -24,7 +23,7 @@ func (this *UpgradeService) UpgradeBlog() bool {
Log(note.NoteId.Hex())
}
}
return true
}
@ -40,25 +39,25 @@ func (this *UpgradeService) UpgradeBetaToBeta2(userId string) (ok bool, msg stri
if configService.GetGlobalStringConfig("UpgradeBetaToBeta2") != "" {
return false, "Leanote have been upgraded"
}
// 1. aboutMe -> page
userBlogs := []info.UserBlog{}
db.ListByQ(db.UserBlogs, bson.M{}, &userBlogs)
for _, userBlog := range userBlogs {
blogService.AddOrUpdateSingle(userBlog.UserId.Hex(), "", "About Me", userBlog.AboutMe)
}
// 2. 默认主题, 给admin用户
themeService.UpgradeThemeBeta2()
// 3. UrlTitles
// 3.1 note
notes := []info.Note{}
db.ListByQ(db.Notes, bson.M{}, &notes)
for _, note := range notes {
data := bson.M{}
data := bson.M{}
noteId := note.NoteId.Hex()
// PublicTime, RecommendTime = UpdatedTime
if note.IsBlog && note.PublicTime.Year() < 100 {
@ -70,7 +69,7 @@ func (this *UpgradeService) UpgradeBetaToBeta2(userId string) (ok bool, msg stri
db.UpdateByIdAndUserIdMap2(db.Notes, note.NoteId, note.UserId, data)
Log(noteId)
}
// 3.2
Log("notebook")
notebooks := []info.Notebook{}
@ -82,24 +81,24 @@ func (this *UpgradeService) UpgradeBetaToBeta2(userId string) (ok bool, msg stri
db.UpdateByIdAndUserIdMap2(db.Notebooks, notebook.NotebookId, notebook.UserId, data)
Log(notebookId)
}
// 3.3 single
/*
singles := []info.BlogSingle{}
db.ListByQ(db.BlogSingles, bson.M{}, &singles)
for _, single := range singles {
singleId := single.SingleId.Hex()
blogService.UpdateSingleUrlTitle(single.UserId.Hex(), singleId, single.Title)
Log(singleId)
}
singles := []info.BlogSingle{}
db.ListByQ(db.BlogSingles, bson.M{}, &singles)
for _, single := range singles {
singleId := single.SingleId.Hex()
blogService.UpdateSingleUrlTitle(single.UserId.Hex(), singleId, single.Title)
Log(singleId)
}
*/
// 删除索引
db.ShareNotes.DropIndex("UserId", "ToUserId", "NoteId")
ok = true
msg = "success"
configService.UpdateGlobalStringConfig(userId, "UpgradeBetaToBeta2", "1")
return
}
@ -134,8 +133,8 @@ func (this *UpgradeService) moveTag() {
func (this *UpgradeService) setNotebookUsn() {
usnI := 1
notebooks := []info.Notebook{}
db.ListByQWithFields(db.Notebooks, bson.M{}, []string{"UserId"}, &notebooks)
db.ListByQWithFields(db.Notebooks, bson.M{}, []string{"UserId"}, &notebooks)
for _, notebook := range notebooks {
db.UpdateByQField(db.Notebooks, bson.M{"_id": notebook.NotebookId}, "Usn", usnI)
usnI++
@ -145,8 +144,8 @@ func (this *UpgradeService) setNotebookUsn() {
func (this *UpgradeService) setNoteUsn() {
usnI := 1
notes := []info.Note{}
db.ListByQWithFields(db.Notes, bson.M{}, []string{"UserId"}, &notes)
db.ListByQWithFields(db.Notes, bson.M{}, []string{"UserId"}, &notes)
for _, note := range notes {
db.UpdateByQField(db.Notes, bson.M{"_id": note.NoteId}, "Usn", usnI)
usnI++
@ -158,25 +157,25 @@ func (this *UpgradeService) Api(userId string) (ok bool, msg string) {
if configService.GetGlobalStringConfig("UpgradeBetaToBeta4") != "" {
return false, "Leanote have been upgraded"
}
// user
db.UpdateByQField(db.Users, bson.M{}, "Usn", 200000)
// notebook
db.UpdateByQField(db.Notebooks, bson.M{}, "IsDeleted", false)
this.setNotebookUsn();
this.setNotebookUsn()
// note
// 1-N
db.UpdateByQField(db.Notes, bson.M{}, "IsDeleted", false)
this.setNoteUsn();
this.setNoteUsn()
// tag
// 1-N
/// tag, 要重新插入, 将之前的Tag表迁移到NoteTag中
this.moveTag();
this.moveTag()
configService.UpdateGlobalStringConfig(userId, "UpgradeBetaToBeta4", "1")
return true, ""
}