fix:修复mysql兼容问题

pull/425/head
lifei6671 2018-11-26 17:00:40 +08:00
parent 76f1d74632
commit a64a6c80e6
3 changed files with 10 additions and 8 deletions

View File

@ -482,7 +482,7 @@ FROM md_books AS book
left join (select * left join (select *
from (select book_id,team_member_id,role_id from (select book_id,team_member_id,role_id
from md_team_relationship as mtr from md_team_relationship as mtr
left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id) as team on team.book_id=book.book_id left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id,t.team_member_id,t.book_id) as team on team.book_id=book.book_id
WHERE relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0` WHERE relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0`
err = o.Raw(sql1, memberId, memberId).QueryRow(&totalCount) err = o.Raw(sql1, memberId, memberId).QueryRow(&totalCount)
if err != nil { if err != nil {
@ -493,7 +493,7 @@ WHERE relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0
left join (select * left join (select *
from (select book_id,team_member_id,role_id from (select book_id,team_member_id,role_id
from md_team_relationship as mtr from md_team_relationship as mtr
left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id) as team on team.book_id=book.book_id left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id,t.team_member_id,t.book_id) as team on team.book_id=book.book_id
LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0 LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0
LEFT JOIN md_members AS member ON rel1.member_id = member.member_id LEFT JOIN md_members AS member ON rel1.member_id = member.member_id
WHERE rel.relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0 ORDER BY order_index ,book.book_id DESC LIMIT ?,?` WHERE rel.relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0 ORDER BY order_index ,book.book_id DESC LIMIT ?,?`
@ -534,7 +534,7 @@ FROM md_books AS book
left join (select * left join (select *
from (select book_id,team_member_id,role_id from (select book_id,team_member_id,role_id
from md_team_relationship as mtr from md_team_relationship as mtr
left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id) as team on team.book_id = book.book_id left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id,t.team_member_id,t.book_id) as team on team.book_id = book.book_id
WHERE (relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0) AND book.label LIKE ?` WHERE (relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0) AND book.label LIKE ?`
err = o.Raw(sql1, memberId, memberId, keyword).QueryRow(&totalCount) err = o.Raw(sql1, memberId, memberId, keyword).QueryRow(&totalCount)
@ -545,7 +545,7 @@ WHERE (relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id >
LEFT JOIN md_relationship AS rel ON rel.book_id = book.book_id AND rel.member_id = ? LEFT JOIN md_relationship AS rel ON rel.book_id = book.book_id AND rel.member_id = ?
left join (select * from (select book_id,team_member_id,role_id left join (select * from (select book_id,team_member_id,role_id
from md_team_relationship as mtr from md_team_relationship as mtr
left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id) as team left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id,t.team_member_id,t.book_id) as team
on team.book_id = book.book_id on team.book_id = book.book_id
LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0 LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0
LEFT JOIN md_members AS member ON rel1.member_id = member.member_id LEFT JOIN md_members AS member ON rel1.member_id = member.member_id

View File

@ -213,6 +213,7 @@ func (item *Itemsets) FindItemsetsByItemKey(key string, pageIndex, pageSize, mem
err = item.QueryTable().Filter("item_key", key).One(item) err = item.QueryTable().Filter("item_key", key).One(item)
if err != nil { if err != nil {
beego.Error("查询项目空间时出错 ->", key, err)
return nil, 0, err return nil, 0, err
} }
offset := (pageIndex - 1) * pageSize offset := (pageIndex - 1) * pageSize
@ -224,18 +225,19 @@ FROM md_books AS book
left join (select * left join (select *
from (select book_id,team_member_id,role_id from (select book_id,team_member_id,role_id
from md_team_relationship as mtr from md_team_relationship as mtr
left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id) as team on team.book_id = book.book_id left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id,t.team_member_id,t.book_id) as team on team.book_id = book.book_id
WHERE book.item_id = ? AND (relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0)` WHERE book.item_id = ? AND (relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id > 0)`
err = o.Raw(sql1, memberId, memberId, item.ItemId).QueryRow(&totalCount) err = o.Raw(sql1, memberId, memberId, item.ItemId).QueryRow(&totalCount)
if err != nil { if err != nil {
beego.Error("查询项目空间时出错 ->", key, err)
return return
} }
sql2 := `SELECT book.*,rel1.*,member.account AS create_name FROM md_books AS book sql2 := `SELECT book.*,rel1.*,member.account AS create_name FROM md_books AS book
LEFT JOIN md_relationship AS rel ON rel.book_id = book.book_id AND rel.member_id = ? LEFT JOIN md_relationship AS rel ON rel.book_id = book.book_id AND rel.member_id = ?
left join (select * from (select book_id,team_member_id,role_id left join (select * from (select book_id,team_member_id,role_id
from md_team_relationship as mtr from md_team_relationship as mtr
left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id) as team left join md_team_member as mtm on mtm.team_id=mtr.team_id and mtm.member_id=? order by role_id desc )as t group by t.book_id,t.team_member_id,t.book_id) as team
on team.book_id = book.book_id on team.book_id = book.book_id
LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0 LEFT JOIN md_relationship AS rel1 ON rel1.book_id = book.book_id AND rel1.role_id = 0
LEFT JOIN md_members AS member ON rel1.member_id = member.member_id LEFT JOIN md_members AS member ON rel1.member_id = member.member_id