提交 fba1975d authored 作者: mooncake9527's avatar mooncake9527

update

上级 d7d3be58
......@@ -40,21 +40,23 @@ func GenerateApiID(ctx context.Context, bizTag string) (xsf.ID, error) {
return xsf.ID(-1), ErrNoXsfAddr
}
url := fmt.Sprintf(`http://%s/api/leaf?biz_tag=%s`, xsfAddr, bizTag)
reply := &IDReply{}
if err := api.cli.NewRequest().OmitLog().SetRetry(3).
var id xsf.ID
reply := &IDReply{
Data: &id,
}
// if err := api.cli.NewRequest().OmitLog().SetRetry(3).
if err := api.cli.NewRequest().SetRetry(3).
SetContentType("application/json").SetURL(url).GET(ctx).BindJSON(reply).Err(); err != nil {
return xsf.ID(-1), err
}
if reply.Code == 0 {
return xsf.ParseInt64(reply.Data.ID), nil
if reply.Code == 1 {
return id, nil
}
return xsf.ID(-1), errors.New(reply.Msg)
}
type IDReply struct {
Code int `json:"code"`
Data struct {
ID int64 `json:"id"`
} `json:"data"`
Msg string `json:"msg"`
Code int `json:"code"`
Data any `json:"data"`
Msg string `json:"msg"`
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论