删除一个用户,并将该用户的所有信息转移到超级管理员上.
()
| 340 | |
| 341 | // 删除一个用户,并将该用户的所有信息转移到超级管理员上. |
| 342 | func (this *ManagerController) DeleteMember() { |
| 343 | memberId, _ := this.GetInt("id", 0) |
| 344 | if memberId <= 0 { |
| 345 | this.JsonResult(404, "参数错误") |
| 346 | } |
| 347 | |
| 348 | member, err := models.NewMember().Find(memberId) |
| 349 | |
| 350 | if err != nil { |
| 351 | beego.Error(err) |
| 352 | this.JsonResult(500, "用户不存在") |
| 353 | } |
| 354 | if member.Role == conf.MemberSuperRole { |
| 355 | this.JsonResult(500, "不能删除超级管理员") |
| 356 | } |
| 357 | superMember, err := models.NewMember().FindByFieldFirst("role", 0) |
| 358 | |
| 359 | if err != nil { |
| 360 | beego.Error(err) |
| 361 | this.JsonResult(5001, "未能找到超级管理员") |
| 362 | } |
| 363 | |
| 364 | err = models.NewMember().Delete(memberId, superMember.MemberId) |
| 365 | if err != nil { |
| 366 | beego.Error(err) |
| 367 | this.JsonResult(5002, "删除失败") |
| 368 | } |
| 369 | |
| 370 | this.JsonResult(0, "ok") |
| 371 | } |
| 372 | |
| 373 | // 书籍列表. |
| 374 | func (this *ManagerController) Books() { |
nothing calls this directly
no test coverage detected