package mixrepoimpl import ( "context" "github.com/go-kratos/kratos/v2/log" "net/http" "time" "voucher/internal/biz/kog" "voucher/internal/biz/mixrepos" "voucher/internal/conf" "voucher/internal/pkg/request" ) // KxMixRepoImpl kog 空港 type KxMixRepoImpl struct { bc *conf.Bootstrap } func NewKxMixRepoImpl(bc *conf.Bootstrap) mixrepos.KxMixRepo { return &KxMixRepoImpl{bc: bc} } func (s *KxMixRepoImpl) Request(ctx context.Context, req *kog.Notice) error { body, err := req.Marshal() if err != nil { return err } h := http.Header{ "Content-Type": []string{"application/json"}, } url := s.bc.Cmb.KxNoticeUrl _, bodyBytes, err := request.Post(ctx, url, body, request.WithHeaders(h), request.WithTimeout(time.Second*20)) if err != nil { log.Errorf("请求kx报错,url:%s,body:%s,err:%v", url, string(body), err) return nil } log.Warnf("请求kx,url:%s,reqBody:%s,respBody:%s", url, string(body), string(bodyBytes)) return nil }