doccollectlogic.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jy_docs/services/model"
  4. "context"
  5. "log"
  6. "app.yhyue.com/moapp/jy_docs/rpc/userlib/internal/svc"
  7. "app.yhyue.com/moapp/jy_docs/rpc/userlib/userlib"
  8. userLibService "app.yhyue.com/moapp/jy_docs/services/userlib"
  9. "github.com/tal-tech/go-zero/core/logx"
  10. )
  11. type DocCollectLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewDocCollectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocCollectLogic {
  17. return &DocCollectLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. func (l *DocCollectLogic) DocCollect(in *userlib.UserCollectRequest) (*userlib.UserCollectResponse, error) {
  24. // todo: add your logic here and delete this line
  25. b := userLibService.UserDocCollect(
  26. &model.UserDoc{
  27. UserId: in.UserId,
  28. DocId: in.DocId,
  29. }, int(in.Cost))
  30. log.Printf("用户文档收藏,userId:[%s],docId:[%s] 是否成功:[%v]", in.UserId, in.DocId, b)
  31. return &userlib.UserCollectResponse{
  32. Code: 200,
  33. Message: "success",
  34. }, nil
  35. }