unclaimedlogic.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package public
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
  6. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
  7. "context"
  8. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
  9. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type UnclaimedLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewUnclaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnclaimedLogic {
  18. return &UnclaimedLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. // Unclaimed 取消认领
  25. func (l *UnclaimedLogic) Unclaimed(req *types.UnclaimedReq) (resp *types.ClaimResp, err error) {
  26. rs, err := l.svcCtx.Medical.UnClaimed(l.ctx, &medical.UnclaimedReq{
  27. UserId: int64(req.UserId),
  28. Id: common.Int64All(encrypt.SE.DecodeString(req.Id)),
  29. })
  30. if err != nil || rs == nil {
  31. return &types.ClaimResp{
  32. Error_msg: "操作失败",
  33. Error_code: entity.ERRORCODE,
  34. ResourceNum: 0,
  35. ResourceIds: 0,
  36. }, nil
  37. }
  38. return &types.ClaimResp{
  39. Error_msg: rs.ErrorMsg,
  40. Error_code: int(rs.ErrorCode),
  41. ResourceIds: int(rs.ResourceIds),
  42. ResourceNum: int(rs.ResourceNum),
  43. }, nil
  44. }