mirror of https://github.com/mindoc-org/mindoc.git
修复登录用户能搜索的私有项目的BUG
parent
da2dbf7146
commit
906191624c
|
@ -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
|
||||
}
|
|
@ -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,"保存失败")
|
||||
|
|
6
main.go
6
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<input type="email" class="form-control" placeholder="用户邮箱" name="email" id="email" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
{{if ne .ENABLED_CAPTCHA "false"}}
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group" style="float: left;width: 195px;">
|
||||
<div class="input-group-addon">
|
||||
|
@ -76,7 +76,7 @@
|
|||
<img id="captcha-img" style="width: 140px;height: 40px;display: inline-block;float: right" src="{{urlfor "AccountController.Captcha"}}" onclick="this.src='{{urlfor "AccountController.Captcha"}}?key=login&t='+(new Date()).getTime();" title="点击换一张">
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="form-group">
|
||||
<button type="submit" id="btnRegister" class="btn btn-success" style="width: 100%" data-loading-text="正在注册..." autocomplete="off">立即注册</button>
|
||||
</div>
|
||||
|
|
|
@ -51,37 +51,41 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>标识</label>
|
||||
<input type="text" class="form-control" value=" {{.BaseUrl}}{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" disabled>
|
||||
<input type="text" class="form-control" value=" {{.BaseUrl}}{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" disabled placeholder="项目标识">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>排序</label>
|
||||
<input type="number" min="0" class="form-control" value="{{.Model.OrderIndex}}" name="order_index" placeholder="项目排序">
|
||||
<p class="text">只能是数字,序号越大排序越靠前</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>描述</label>
|
||||
<textarea rows="3" class="form-control" name="description" style="height: 90px">{{.Model.Description}}</textarea>
|
||||
<textarea rows="3" class="form-control" name="description" style="height: 90px" placeholder="项目描述">{{.Model.Description}}</textarea>
|
||||
<p class="text">描述信息不超过500个字符</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>标签</label>
|
||||
<input type="text" class="form-control" name="label" placeholder="项目标签" value="{{.Model.Label}}">
|
||||
<p class="text">最多允许添加10个标签,多个标签请用“;”分割</p>
|
||||
</div>
|
||||
{{/*
|
||||
<div class="form-group">
|
||||
<label>开启评论</label>
|
||||
<div class="radio">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" {{if eq .Model.CommentStatus "open"}}checked{{end}} name="comment_status" value="open">允许所有人评论<span class="text"></span>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" {{if eq .Model.CommentStatus "closed"}}checked{{end}} name="comment_status" value="closed">关闭评论<span class="text"></span>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" {{if eq .Model.CommentStatus "group_only"}}checked{{end}} name="comment_status" value="group_only">仅允许参与者评论<span class="text"></span>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" {{if eq .Model.CommentStatus "registered_only"}}checked{{end}} name="comment_status" value="registered_only">仅允许注册者评论<span class="text"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
*/}}
|
||||
{{/*{*<div class="form-group">*}
|
||||
{*<label>开启评论</label>*}
|
||||
{*<div class="radio">*}
|
||||
{*<label class="radio-inline">*}
|
||||
{*<input type="radio" {{if eq .Model.CommentStatus "open"}}checked{{end}} name="comment_status" value="open">允许所有人评论<span class="text"></span>*}
|
||||
{*</label>*}
|
||||
{*<label class="radio-inline">*}
|
||||
{*<input type="radio" {{if eq .Model.CommentStatus "closed"}}checked{{end}} name="comment_status" value="closed">关闭评论<span class="text"></span>*}
|
||||
{*</label>*}
|
||||
{*<label class="radio-inline">*}
|
||||
{*<input type="radio" {{if eq .Model.CommentStatus "group_only"}}checked{{end}} name="comment_status" value="group_only">仅允许参与者评论<span class="text"></span>*}
|
||||
{*</label>*}
|
||||
{*<label class="radio-inline">*}
|
||||
{*<input type="radio" {{if eq .Model.CommentStatus "registered_only"}}checked{{end}} name="comment_status" value="registered_only">仅允许注册者评论<span class="text"></span>*}
|
||||
{*</label>*}
|
||||
{*</div>*}
|
||||
{*</div>*} */}}
|
||||
{{if eq .Model.PrivatelyOwned 1}}
|
||||
<div class="form-group">
|
||||
<label>访问令牌</label>
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
<span class="empty-text">暂无相关搜索结果</span>
|
||||
</div>
|
||||
{{end}}
|
||||
<nav>
|
||||
{{.PageHtml}}
|
||||
</nav>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue