From 906191624ce59b4746a0c799f850635814c2ecc9 Mon Sep 17 00:00:00 2001 From: Minho Date: Fri, 5 May 2017 15:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=83=BD=E6=90=9C=E7=B4=A2=E7=9A=84=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/enumerate.go | 9 ++++++- controllers/manager.go | 2 ++ main.go | 6 +++-- models/document_search_result.go | 10 ++++--- views/account/register.tpl | 4 +-- views/manager/edit_book.tpl | 46 +++++++++++++++++--------------- views/search/index.tpl | 3 +++ 7 files changed, 50 insertions(+), 30 deletions(-) diff --git a/conf/enumerate.go b/conf/enumerate.go index 9d2ae5fd..02f5f89a 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -39,6 +39,10 @@ const ( BookObserver = 3 ) +var ( + VERSION string +) + // app_key func GetAppKey() (string) { return beego.AppConfig.DefaultString("app_key","godoc") @@ -47,6 +51,7 @@ func GetAppKey() (string) { func GetDatabasePrefix() string { return beego.AppConfig.DefaultString("db_prefix","md_") } + //获取默认头像 func GetDefaultAvatar() string { return beego.AppConfig.DefaultString("avatar","/static/images/headimgurl.jpg") @@ -79,6 +84,7 @@ func GetUploadFileExt() []string { } return exts } + //判断是否是允许商城的文件类型. func IsAllowUploadFileExt(ext string) bool { @@ -97,5 +103,6 @@ func IsAllowUploadFileExt(ext string) bool { //获取当前版本. func Version() string { - return "v0.1" + + return VERSION } \ No newline at end of file diff --git a/controllers/manager.go b/controllers/manager.go index 0bd8a4e0..f51ef9bf 100644 --- a/controllers/manager.go +++ b/controllers/manager.go @@ -222,6 +222,7 @@ func (c *ManagerController) EditBook() { description := strings.TrimSpace(c.GetString("description","")) comment_status := c.GetString("comment_status") tag := strings.TrimSpace(c.GetString("label")) + order_index ,_ := c.GetInt("order_index",0) if strings.Count(description,"") > 500 { c.JsonResult(6004,"项目描述不能大于500字") @@ -241,6 +242,7 @@ func (c *ManagerController) EditBook() { book.Description = description book.CommentStatus = comment_status book.Label = tag + book.OrderIndex = order_index if err := book.Update();err != nil { c.JsonResult(6006,"保存失败") diff --git a/main.go b/main.go index 34bf2285..cc0ae305 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "github.com/lifei6671/godoc/controllers" + "github.com/lifei6671/godoc/conf" ) var ( @@ -23,6 +24,8 @@ func main() { fmt.Printf("MinDoc version => %s\nbuild time => %s\nstart directory => %s\n%s\n", VERSION, BUILD_TIME, os.Args[0],GO_VERSION) + conf.VERSION = VERSION + commands.RegisterDataBase() commands.RegisterModel() commands.RegisterLogger() @@ -31,9 +34,8 @@ func main() { beego.SetStaticPath("uploads","uploads") - - beego.ErrorController(&controllers.ErrorController{}) + beego.Run() } diff --git a/models/document_search_result.go b/models/document_search_result.go index 51c15880..589acaec 100644 --- a/models/document_search_result.go +++ b/models/document_search_result.go @@ -55,21 +55,23 @@ WHERE book.privately_owned = 0 AND (doc.document_name LIKE ? OR doc.release LIKE sql1 := `SELECT count(doc.document_id) as total_count FROM md_documents AS doc LEFT JOIN md_books as book ON doc.book_id = book.book_id LEFT JOIN md_relationship AS rel ON doc.book_id = rel.book_id AND role_id = 0 -WHERE (book.privately_owned = 0 OR rel.relationship_id > 0) AND (doc.document_name LIKE ? OR doc.release LIKE ?) ` + LEFT JOIN md_relationship AS rel1 ON doc.book_id = rel1.book_id AND rel1.member_id = ? +WHERE (book.privately_owned = 0 OR rel1.relationship_id > 0) AND (doc.document_name LIKE ? OR doc.release LIKE ?) ` sql2 := `SELECT doc.document_id,doc.modify_time,doc.create_time,doc.document_name,doc.identify,doc.release as description,doc.modify_time,book.identify as book_identify,book.book_name,rel.member_id,member.account AS author FROM md_documents AS doc LEFT JOIN md_books as book ON doc.book_id = book.book_id LEFT JOIN md_relationship AS rel ON book.book_id = rel.book_id AND role_id = 0 LEFT JOIN md_members as member ON rel.member_id = member.member_id -WHERE (book.privately_owned = 0 OR rel.relationship_id > 0) AND (doc.document_name LIKE ? OR doc.release LIKE ?) + LEFT JOIN md_relationship AS rel1 ON doc.book_id = rel1.book_id AND rel1.member_id = ? +WHERE (book.privately_owned = 0 OR rel1.relationship_id > 0) AND (doc.document_name LIKE ? OR doc.release LIKE ?) ORDER BY doc.document_id DESC LIMIT ?,? ` - err = o.Raw(sql1,keyword,keyword).QueryRow(&total_count) + err = o.Raw(sql1,member_id,keyword,keyword).QueryRow(&total_count) if err != nil{ return } - _,err = o.Raw(sql2,keyword,keyword,offset,page_size).QueryRows(&search_result) + _,err = o.Raw(sql2,member_id,keyword,keyword,offset,page_size).QueryRows(&search_result) if err != nil { return } diff --git a/views/account/register.tpl b/views/account/register.tpl index f5d72355..a4bf791a 100644 --- a/views/account/register.tpl +++ b/views/account/register.tpl @@ -65,7 +65,7 @@ - {{if ne .ENABLED_CAPTCHA "false"}} +
@@ -76,7 +76,7 @@
- {{end}} +
diff --git a/views/manager/edit_book.tpl b/views/manager/edit_book.tpl index f42ea05a..187350a6 100644 --- a/views/manager/edit_book.tpl +++ b/views/manager/edit_book.tpl @@ -51,37 +51,41 @@
- + +
+
+ + +

只能是数字,序号越大排序越靠前

- +

描述信息不超过500个字符

+

最多允许添加10个标签,多个标签请用“;”分割

- {{/* -
- -
- - - - -
-
- */}} + {{/*{*
*} + {**} + {*
*} + {**} + {**} + {**} + {**} + {*
*} + {*
*} */}} {{if eq .Model.PrivatelyOwned 1}}
diff --git a/views/search/index.tpl b/views/search/index.tpl index 743c0046..66881029 100644 --- a/views/search/index.tpl +++ b/views/search/index.tpl @@ -47,6 +47,9 @@ 暂无相关搜索结果
{{end}} +