From a64a6c80e68adbbc225d7b9972ac2cf22b172c16 Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Mon, 26 Nov 2018 17:00:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dmysql=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/BookModel.go | 8 ++++---- models/Itemsets.go | 8 +++++--- models/TeamMember.go | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/models/BookModel.go b/models/BookModel.go index 8018760b..1ea3defc 100644 --- a/models/BookModel.go +++ b/models/BookModel.go @@ -482,7 +482,7 @@ FROM md_books AS book left join (select * from (select book_id,team_member_id,role_id 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` err = o.Raw(sql1, memberId, memberId).QueryRow(&totalCount) 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 * from (select book_id,team_member_id,role_id 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_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 ?,?` @@ -534,7 +534,7 @@ FROM md_books AS book left join (select * from (select book_id,team_member_id,role_id 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 ?` 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 (select * from (select book_id,team_member_id,role_id 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 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 diff --git a/models/Itemsets.go b/models/Itemsets.go index c3bd754a..d56ca56b 100644 --- a/models/Itemsets.go +++ b/models/Itemsets.go @@ -135,7 +135,7 @@ func (item *Itemsets) Include() (*Itemsets, error) { item.CreateTimeString = item.CreateTime.Format("2006-01-02 15:04:05") if item.MemberId > 0 { - if m,err := NewMember().Find(item.MemberId,"account","real_name");err == nil { + if m, err := NewMember().Find(item.MemberId, "account", "real_name"); err == nil { if m.RealName != "" { item.CreateName = m.RealName } else { @@ -213,6 +213,7 @@ func (item *Itemsets) FindItemsetsByItemKey(key string, pageIndex, pageSize, mem err = item.QueryTable().Filter("item_key", key).One(item) if err != nil { + beego.Error("查询项目空间时出错 ->", key, err) return nil, 0, err } offset := (pageIndex - 1) * pageSize @@ -224,18 +225,19 @@ FROM md_books AS book left join (select * from (select book_id,team_member_id,role_id 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)` err = o.Raw(sql1, memberId, memberId, item.ItemId).QueryRow(&totalCount) if err != nil { + beego.Error("查询项目空间时出错 ->", key, err) return } 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 (select * from (select book_id,team_member_id,role_id 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 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 diff --git a/models/TeamMember.go b/models/TeamMember.go index a70cfc44..d0cbfb67 100644 --- a/models/TeamMember.go +++ b/models/TeamMember.go @@ -207,7 +207,7 @@ func (m *TeamMember) FindNotJoinMemberByAccount(teamId int, account string, limi sql := `select member.member_id,member.account from md_members as member left join md_team_member as team on team.team_id = ? and member.member_id != team.member_id - where member.account like ? and team.member_id isnull + where member.account like ? and team.member_id is null order by member.member_id desc limit ?;`