判断是否具有管理员或管理员以上权限
()
| 916 | |
| 917 | // 判断是否具有管理员或管理员以上权限 |
| 918 | func (this *BookController) IsPermission() (*models.BookResult, error) { |
| 919 | |
| 920 | identify := this.GetString("identify") |
| 921 | |
| 922 | book, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId) |
| 923 | if err != nil { |
| 924 | if err == models.ErrPermissionDenied { |
| 925 | return book, errors.New("权限不足") |
| 926 | } |
| 927 | if err == orm.ErrNoRows { |
| 928 | return book, errors.New("书籍不存在") |
| 929 | } |
| 930 | return book, err |
| 931 | } |
| 932 | |
| 933 | if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder { |
| 934 | return book, errors.New("权限不足") |
| 935 | } |
| 936 | return book, nil |
| 937 | } |
| 938 | |
| 939 | // 从github等拉取下载markdown书籍 |
| 940 | func (this *BookController) DownloadProject() { |
no test coverage detected