()
| 147 | } |
| 148 | |
| 149 | func (this *BookMemberController) IsPermission() (*models.BookResult, error) { |
| 150 | identify := this.GetString("identify") |
| 151 | book, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId) |
| 152 | |
| 153 | if err != nil { |
| 154 | if err == models.ErrPermissionDenied { |
| 155 | return book, errors.New("权限不足") |
| 156 | } |
| 157 | if err == orm.ErrNoRows { |
| 158 | return book, errors.New("书籍不存在") |
| 159 | } |
| 160 | return book, err |
| 161 | } |
| 162 | if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder { |
| 163 | return book, errors.New("权限不足") |
| 164 | } |
| 165 | return book, nil |
| 166 | } |
no test coverage detected