finclip-app-manager/infrastructure/client/grpc/mop_purchasing_rights_manag...

43 lines
1.0 KiB
Go
Raw Normal View History

2023-10-31 14:07:26 +08:00
package grpc
import (
"context"
"errors"
"finclip-app-manager/infrastructure/config"
pb "finclip-app-manager/infrastructure/protobuf/golang"
)
func PurchasingGetIdStatus(ctx context.Context, id string) (int, error) {
rsp := &pb.QueryBusinessStatusRsp{}
var err error
for i := 0; i < 2; i++ {
conn, err1 := GetGrpcConnManager().GetConn(config.GetConfig().ConsulAddr, "mop-purchasing-rights-manager", "tag="+config.GetConfig().ConsulTag)
if err1 != nil {
err = err1
continue
}
c := pb.NewMopPurchasingRightsManagerClient(conn)
req := pb.QueryBusinessStatusReq{}
req.BusinessId = id
rsp, err = c.QueryBusinessStatus(ctx, &req)
if err != nil {
log.Errorf("PurchasingGetIdStatus err=%s", err.Error())
continue
} else {
err = nil
break
}
}
if err != nil {
return 0, err
}
if rsp.Result.Httpcode != 200 {
log.Errorf("PurchasingGetIdStatus status code err:%+v", rsp)
return 0, errors.New(rsp.Result.Error)
}
log.Debugf("PurchasingGetIdStatus rsp:%+v", rsp)
return int(rsp.Data.Status), nil
}