docdownloadlogic.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jy_docs/rpc/userlib/internal/svc"
  4. "app.yhyue.com/moapp/jy_docs/rpc/userlib/userlib"
  5. "app.yhyue.com/moapp/jy_docs/services/model"
  6. userLibService "app.yhyue.com/moapp/jy_docs/services/userlib"
  7. "context"
  8. "log"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type DocDownloadLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewDocDownloadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocDownloadLogic {
  17. return &DocDownloadLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. //转存操作
  24. func (l *DocDownloadLogic) DocDownload(in *userlib.UserCollectRequest) (*userlib.UserCollectResponse, error) {
  25. b, msg := userLibService.UserDocDownload(
  26. &model.UserDoc{
  27. UserId: in.UserId,
  28. DocId: in.DocId,
  29. AppId: in.AppId,
  30. }, int(in.Cost))
  31. log.Printf("用户文档转存,userId:[%s],docId:[%s],cost:[%d],是否成功:[%v]", in.UserId, in.DocId,in.Cost, b)
  32. if b {
  33. return &userlib.UserCollectResponse{
  34. Code: int32(1),
  35. Message: msg,
  36. }, nil
  37. } else {
  38. return &userlib.UserCollectResponse{
  39. Code: int32(0),
  40. Message: msg,
  41. }, nil
  42. }
  43. }