req_http.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/app/job/main/account-recovery/model"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. "go-common/library/net/metadata"
  10. )
  11. // CompareInfo compare info
  12. func (d *Dao) CompareInfo(c context.Context, rid int64) (err error) {
  13. params := url.Values{}
  14. params.Set("rid", strconv.FormatInt(rid, 10))
  15. res := new(model.CommonResq)
  16. if err = d.httpClient.Post(c, d.c.AccRecover.CompareURL, metadata.String(c, metadata.RemoteIP), params, &res); err != nil {
  17. log.Error("CompareInfo HTTP request err %v", err)
  18. return
  19. }
  20. if res.Code != 0 {
  21. log.Error("CompareInfo server err_code %d", res.Code)
  22. err = ecode.Int(int(res.Code))
  23. return
  24. }
  25. return
  26. }
  27. // SendMail send mail
  28. func (d *Dao) SendMail(c context.Context, rid, status int64) (err error) {
  29. params := url.Values{}
  30. params.Set("rid", strconv.FormatInt(rid, 10))
  31. params.Set("status", strconv.FormatInt(status, 10))
  32. res := new(model.CommonResq)
  33. if err = d.httpClient.Post(c, d.c.AccRecover.SendMailURL, metadata.String(c, metadata.RemoteIP), params, &res); err != nil {
  34. log.Error("SendMail HTTP request err %v", err)
  35. return
  36. }
  37. if res.Code != 0 {
  38. log.Error("SendMail server err_code %d", res.Code)
  39. err = ecode.Int(int(res.Code))
  40. return
  41. }
  42. return
  43. }