minRole 最小的角色权限 conf.BookFounder conf.BookAdmin conf.BookEditor conf.BookObserver
(identify string, memberId int, minRole int)
| 122 | //conf.BookEditor |
| 123 | //conf.BookObserver |
| 124 | func (m *Book) HasProjectAccess(identify string, memberId int, minRole int) bool { |
| 125 | book := NewBook() |
| 126 | rel := NewRelationship() |
| 127 | o := orm.NewOrm() |
| 128 | o.QueryTable(book).Filter("identify", identify).One(book, "book_id") |
| 129 | if book.BookId <= 0 { |
| 130 | return false |
| 131 | } |
| 132 | o.QueryTable(rel).Filter("book_id", book.BookId).Filter("member_id", memberId).One(rel) |
| 133 | if rel.RelationshipId <= 0 { |
| 134 | return false |
| 135 | } |
| 136 | return rel.RoleId <= minRole |
| 137 | } |
| 138 | |
| 139 | func (m *Book) Sorted(limit int, orderField string) (books []Book) { |
| 140 | o := orm.NewOrm() |
no test coverage detected