Transfer 转让书籍.
()
| 598 | |
| 599 | // Transfer 转让书籍. |
| 600 | func (this *ManagerController) Transfer() { |
| 601 | account := this.GetString("account") |
| 602 | if account == "" { |
| 603 | this.JsonResult(6004, "接受者账号不能为空") |
| 604 | } |
| 605 | |
| 606 | member, err := models.NewMember().FindByAccount(account) |
| 607 | if err != nil { |
| 608 | beego.Error("FindByAccount => ", err) |
| 609 | this.JsonResult(6005, "接受用户不存在") |
| 610 | } |
| 611 | |
| 612 | if member.Status != 0 { |
| 613 | this.JsonResult(6006, "接受用户已被禁用") |
| 614 | } |
| 615 | |
| 616 | if !this.Member.IsAdministrator() { |
| 617 | this.Abort("404") |
| 618 | } |
| 619 | |
| 620 | identify := this.GetString("identify") |
| 621 | |
| 622 | book, err := models.NewBook().FindByFieldFirst("identify", identify) |
| 623 | if err != nil { |
| 624 | this.JsonResult(6001, err.Error()) |
| 625 | } |
| 626 | |
| 627 | rel, err := models.NewRelationship().FindFounder(book.BookId) |
| 628 | if err != nil { |
| 629 | beego.Error("FindFounder => ", err) |
| 630 | this.JsonResult(6009, "查询书籍创始人失败") |
| 631 | } |
| 632 | |
| 633 | if member.MemberId == rel.MemberId { |
| 634 | this.JsonResult(6007, "不能转让给自己") |
| 635 | } |
| 636 | |
| 637 | err = models.NewRelationship().Transfer(book.BookId, rel.MemberId, member.MemberId) |
| 638 | if err != nil { |
| 639 | beego.Error("Transfer => ", err) |
| 640 | this.JsonResult(6008, err.Error()) |
| 641 | } |
| 642 | this.JsonResult(0, "ok") |
| 643 | } |
| 644 | |
| 645 | func (this *ManagerController) Comments() { |
| 646 | status := this.GetString("status", "0") |
nothing calls this directly
no test coverage detected