credit.go 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dao
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "net/url"
  7. "go-common/app/admin/main/dm/model"
  8. "go-common/library/log"
  9. )
  10. const (
  11. _sendJudge = "/x/internal/credit/blocked/case/add"
  12. )
  13. // SendJudgement send to judgement
  14. func (d *Dao) SendJudgement(c context.Context, judges []*model.ReportJudge) (err error) {
  15. params := url.Values{}
  16. ret := struct {
  17. Code int64 `json:"code"`
  18. Message string `json:"message"`
  19. }{}
  20. data, err := json.Marshal(judges)
  21. if err != nil {
  22. log.Error("send judgement params(%s) create error(%v)", data, err)
  23. return
  24. }
  25. params.Set("data", string(data))
  26. if err = d.httpCli.Post(c, d.sendJudgeURI, "", params, &ret); err != nil {
  27. log.Error("send judgement request(data: %s) error(%v)", data, err)
  28. return
  29. }
  30. if ret.Code != 0 {
  31. err = fmt.Errorf("%v", ret)
  32. log.Error("send judgement request(data: %s) error(%v)", data, err)
  33. }
  34. return
  35. }