删除参与者.
()
| 114 | |
| 115 | // 删除参与者. |
| 116 | func (this *BookMemberController) RemoveMember() { |
| 117 | identify := this.GetString("identify") |
| 118 | memberId, _ := this.GetInt("member_id", 0) |
| 119 | |
| 120 | if identify == "" || memberId <= 0 { |
| 121 | this.JsonResult(6001, "参数错误") |
| 122 | } |
| 123 | if memberId == this.Member.MemberId { |
| 124 | this.JsonResult(6006, "不能删除自己") |
| 125 | } |
| 126 | book, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId) |
| 127 | |
| 128 | if err != nil { |
| 129 | if err == models.ErrPermissionDenied { |
| 130 | this.JsonResult(403, "权限不足") |
| 131 | } |
| 132 | if err == orm.ErrNoRows { |
| 133 | this.JsonResult(404, "书籍不存在") |
| 134 | } |
| 135 | this.JsonResult(6002, err.Error()) |
| 136 | } |
| 137 | //如果不是创始人也不是管理员则不能操作 |
| 138 | if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin { |
| 139 | this.JsonResult(403, "权限不足") |
| 140 | } |
| 141 | |
| 142 | err = models.NewRelationship().DeleteByBookIdAndMemberId(book.BookId, memberId) |
| 143 | if err != nil { |
| 144 | this.JsonResult(6007, err.Error()) |
| 145 | } |
| 146 | this.JsonResult(0, "ok") |
| 147 | } |
| 148 | |
| 149 | func (this *BookMemberController) IsPermission() (*models.BookResult, error) { |
| 150 | identify := this.GetString("identify") |
nothing calls this directly
no test coverage detected