Skip to content

Commit

Permalink
修复搜索BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
lifei6671 committed May 9, 2017
1 parent d012624 commit ace9768
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions models/document_search_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit ace9768

Please sign in to comment.