f
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package tianyuan
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
tianyuanlogic "tyc-server/app/main/api/internal/logic/tianyuan"
|
||||
"tyc-server/app/main/api/internal/svc"
|
||||
"tyc-server/common/result"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// VehicleCallbackHandler 天远车辆类接口异步回调入口
|
||||
// 约定:第三方在回调 URL 上携带 order_no / api_id 等标识,例如:/api/v1/tianyuan/vehicle/callback?order_no=Q_xxx&api_id=QCXG1U4U
|
||||
// 回调 Body 为该接口最终的 JSON 结果。
|
||||
func VehicleCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := tianyuanlogic.NewVehicleCallbackLogic(r.Context(), svcCtx)
|
||||
if err := l.Handle(r); err != nil {
|
||||
// 对第三方尽量返回 200,避免无限重试,这里使用统一 result 封装错误
|
||||
result.HttpResult(r, w, map[string]interface{}{
|
||||
"code": 500,
|
||||
"msg": "fail",
|
||||
}, err)
|
||||
return
|
||||
}
|
||||
|
||||
httpx.OkJson(w, map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user