voucher/internal/data/mixrepoimpl/kx.go

56 lines
1.5 KiB
Go

package mixrepoimpl
import (
"context"
"github.com/go-kratos/kratos/v2/log"
"voucher/internal/biz/kog"
"voucher/internal/biz/mixrepos"
"voucher/internal/conf"
)
// 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 {
log.Errorf("请求kx Marshal 报错:%s", err.Error())
return err
}
log.Warnf("请求kx,reqBody:%s", string(body))
//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 err
//}
//
//log.Warnf("请求kx,url:%s,reqBody:%s,respBody:%s", url, string(body), string(bodyBytes))
//var response *v1.CmbReply
//if err = json.Unmarshal(bodyBytes, &response); err != nil {
// log.Errorf("请求kx返回数据解析报错:%s,url:%s,reqBody:%s,respBody:%s", err.Error(), url, string(bodyBytes))
// return err
//}
//
//if response.RespCode != vo.CmbResponseStatusSuccess.GetValue() {
// log.Errorf("请求kx返回报错:msg:%s,url:%s,respBody:%s", response.RespMsg, url, string(bodyBytes))
// return fmt.Errorf(response.RespMsg)
//}
return nil
}