institutionunclaimedlogic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package public
  2. import (
  3. "app.yhyue.com/moapp/jybase/encrypt"
  4. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
  6. "context"
  7. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/svc"
  8. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/api/medical/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type InstitutionUnclaimedLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewInstitutionUnclaimedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstitutionUnclaimedLogic {
  17. return &InstitutionUnclaimedLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *InstitutionUnclaimedLogic) InstitutionUnclaimed(req *types.ClaimReq) (resp *types.ClaimResp, err error) {
  24. rs, err := l.svcCtx.Medical.UnClaimed(l.ctx, &medical.ClaimReq{
  25. UserId: int64(req.UserId),
  26. EntId: encrypt.SE.DecodeString(req.EntId),
  27. Type: entity.TypeInstitution,
  28. AppId: req.AppId,
  29. })
  30. if err != nil || rs == nil {
  31. errMsg := ""
  32. if err == entity.RepeatErr || err == entity.OperateErr || err == entity.EntNoFoundErr {
  33. errMsg = err.Error()
  34. } else {
  35. errMsg = entity.OperateErr.Error()
  36. }
  37. return &types.ClaimResp{
  38. Error_msg: errMsg,
  39. Error_code: entity.ERRORCODE,
  40. ResourceNum: 0,
  41. ResourceIds: 0,
  42. }, nil
  43. }
  44. return &types.ClaimResp{
  45. Error_msg: rs.ErrorMsg,
  46. Error_code: int(rs.ErrorCode),
  47. ResourceIds: int(rs.ResourceIds),
  48. ResourceNum: int(rs.ResourceNum),
  49. }, nil
  50. }