MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Transfer

Method Transfer

controllers/ManagerController.go:600–643  ·  view source on GitHub ↗

Transfer 转让书籍.

()

Source from the content-addressed store, hash-verified

598
599// Transfer 转让书籍.
600func (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
645func (this *ManagerController) Comments() {
646 status := this.GetString("status", "0")

Callers

nothing calls this directly

Calls 8

NewMemberFunction · 0.92
NewBookFunction · 0.92
NewRelationshipFunction · 0.92
JsonResultMethod · 0.80
FindByAccountMethod · 0.80
IsAdministratorMethod · 0.80
FindFounderMethod · 0.80
FindByFieldFirstMethod · 0.45

Tested by

no test coverage detected