package third import ( "context" "go-template/business/dto" "go-template/business/exception" "gitea.ckfah.com/cjjy/gocommon/pkg/cerror" "gitea.ckfah.com/cjjy/gocommon/pkg/logger" "gitea.ckfah.com/cjjy/gocommon/pkg/net/httpclent" ) type cityConfigThird struct { } func NewCityConfigThird() *cityConfigThird { return &cityConfigThird{} } func (*cityConfigThird) GetServerName() string { return "city-config" } // 统一抽象一个方法,方便管理 func (this *cityConfigThird) httpRequest(ctx context.Context, path string, params interface{}, result interface{}, options ...httpclent.Option) error { return httpclent.HttpRequestAndDecode(ctx, this.GetServerName(), path, params, result, options...) } // 获取城市信息 func (this *cityConfigThird) CityInfo(ctx context.Context, params *dto.CityInfoParams) (*dto.CityInfoResponse, cerror.Cerror) { path := "/city-config/city/info" response := new(dto.CityInfoResponse) err := this.httpRequest(ctx, path, params, response, httpclent.CloseRetry) if err != nil { // 三方日志要打印warn日志,如果必要的话才打印error日志 logger.Warnc(ctx, "[CityInfo] request err,params=%+v,err=%v", params, err) return nil, exception.CityInfoError(err) } return response, nil }