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

Method Transfer

controllers/BookController.go:382–415  ·  view source on GitHub ↗

Transfer 转让书籍.

()

Source from the content-addressed store, hash-verified

380
381// Transfer 转让书籍.
382func (this *BookController) Transfer() {
383
384 account := this.GetString("account")
385 if account == "" {
386 this.JsonResult(6004, "接受者账号不能为空")
387 }
388
389 member, err := models.NewMember().FindByAccount(account)
390 if err != nil {
391 logs.Error("FindByAccount => ", err)
392 this.JsonResult(6005, "接受用户不存在")
393 }
394
395 if member.Status != 0 {
396 this.JsonResult(6006, "接受用户已被禁用")
397 }
398
399 if member.MemberId == this.Member.MemberId {
400 this.JsonResult(6007, "不能转让给自己")
401 }
402
403 bookResult, err := this.IsPermission()
404 if err != nil {
405 this.JsonResult(6001, err.Error())
406 }
407
408 err = models.NewRelationship().Transfer(bookResult.BookId, this.Member.MemberId, member.MemberId)
409 if err != nil {
410 logs.Error("Transfer => ", err)
411 this.JsonResult(6008, err.Error())
412 }
413
414 this.JsonResult(0, "ok")
415}
416
417// 上传书籍封面.
418func (this *BookController) UploadCover() {

Callers

nothing calls this directly

Calls 5

IsPermissionMethod · 0.95
NewMemberFunction · 0.92
NewRelationshipFunction · 0.92
JsonResultMethod · 0.80
FindByAccountMethod · 0.80

Tested by

no test coverage detected