1052 lines
29 KiB
Go
1052 lines
29 KiB
Go
// Code generated by thriftgo (0.3.18). DO NOT EDIT.
|
||
|
||
package weather_and_earthquake
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"github.com/apache/thrift/lib/go/thrift"
|
||
)
|
||
|
||
type QueryReq struct {
|
||
// 操作码
|
||
// 0: 查最新地震信息。
|
||
// 1: 默认情况,通过ip地址查看天气。此时不需要其他参数。
|
||
// 2: 通过提供的 LocationKey 查看天气。需要提供 LocationKey。
|
||
// 3: 通过地名查看天气。需要提供 Addr。
|
||
Op int32 `thrift:"Op,1" json:"Op" query:"op"`
|
||
LocationKey string `thrift:"LocationKey,2" json:"LocationKey" query:"key"`
|
||
Addr string `thrift:"Addr,3" json:"Addr" query:"addr"`
|
||
}
|
||
|
||
func NewQueryReq() *QueryReq {
|
||
return &QueryReq{}
|
||
}
|
||
|
||
func (p *QueryReq) InitDefault() {
|
||
}
|
||
|
||
func (p *QueryReq) GetOp() (v int32) {
|
||
return p.Op
|
||
}
|
||
|
||
func (p *QueryReq) GetLocationKey() (v string) {
|
||
return p.LocationKey
|
||
}
|
||
|
||
func (p *QueryReq) GetAddr() (v string) {
|
||
return p.Addr
|
||
}
|
||
|
||
var fieldIDToName_QueryReq = map[int16]string{
|
||
1: "Op",
|
||
2: "LocationKey",
|
||
3: "Addr",
|
||
}
|
||
|
||
func (p *QueryReq) Read(iprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldTypeId thrift.TType
|
||
var fieldId int16
|
||
|
||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||
goto ReadStructBeginError
|
||
}
|
||
|
||
for {
|
||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||
if err != nil {
|
||
goto ReadFieldBeginError
|
||
}
|
||
if fieldTypeId == thrift.STOP {
|
||
break
|
||
}
|
||
|
||
switch fieldId {
|
||
case 1:
|
||
if fieldTypeId == thrift.I32 {
|
||
if err = p.ReadField1(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 2:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField2(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 3:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField3(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
default:
|
||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
}
|
||
if err = iprot.ReadFieldEnd(); err != nil {
|
||
goto ReadFieldEndError
|
||
}
|
||
}
|
||
if err = iprot.ReadStructEnd(); err != nil {
|
||
goto ReadStructEndError
|
||
}
|
||
|
||
return nil
|
||
ReadStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||
ReadFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||
ReadFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_QueryReq[fieldId]), err)
|
||
SkipFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||
|
||
ReadFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||
ReadStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryReq) ReadField1(iprot thrift.TProtocol) error {
|
||
|
||
var _field int32
|
||
if v, err := iprot.ReadI32(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.Op = _field
|
||
return nil
|
||
}
|
||
func (p *QueryReq) ReadField2(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.LocationKey = _field
|
||
return nil
|
||
}
|
||
func (p *QueryReq) ReadField3(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.Addr = _field
|
||
return nil
|
||
}
|
||
|
||
func (p *QueryReq) Write(oprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldId int16
|
||
if err = oprot.WriteStructBegin("QueryReq"); err != nil {
|
||
goto WriteStructBeginError
|
||
}
|
||
if p != nil {
|
||
if err = p.writeField1(oprot); err != nil {
|
||
fieldId = 1
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField2(oprot); err != nil {
|
||
fieldId = 2
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField3(oprot); err != nil {
|
||
fieldId = 3
|
||
goto WriteFieldError
|
||
}
|
||
}
|
||
if err = oprot.WriteFieldStop(); err != nil {
|
||
goto WriteFieldStopError
|
||
}
|
||
if err = oprot.WriteStructEnd(); err != nil {
|
||
goto WriteStructEndError
|
||
}
|
||
return nil
|
||
WriteStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||
WriteFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||
WriteFieldStopError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||
WriteStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryReq) writeField1(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("Op", thrift.I32, 1); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteI32(p.Op); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryReq) writeField2(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("LocationKey", thrift.STRING, 2); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.LocationKey); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryReq) writeField3(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("Addr", thrift.STRING, 3); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.Addr); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryReq) String() string {
|
||
if p == nil {
|
||
return "<nil>"
|
||
}
|
||
return fmt.Sprintf("QueryReq(%+v)", *p)
|
||
|
||
}
|
||
|
||
type QueryResp struct {
|
||
// 0: 成功。如果是地震信息,就返回地震信息。如果是通过ip或者locationKey查询天气,就返回当前情况和预报。
|
||
// 如果是通过地点查询,表示查到地点,并且只有一个,且通过这个key查询到了天气情况。
|
||
// -1: 参数错误
|
||
// -2: 请求头参数错误
|
||
// -3: 签名校验失败
|
||
// 1: 查询天气失败
|
||
// 2: 查询地名失败
|
||
// 3: 根据地名查询到多个地址,需要确认。
|
||
Code int32 `thrift:"Code,1" form:"Code" json:"Code" query:"Code"`
|
||
LocationKey string `thrift:"LocationKey,2" form:"LocationKey" json:"LocationKey" query:"LocationKey"`
|
||
Locations string `thrift:"Locations,3" form:"Locations" json:"Locations" query:"Locations"`
|
||
CurrentConditions string `thrift:"CurrentConditions,4" form:"CurrentConditions" json:"CurrentConditions" query:"CurrentConditions"`
|
||
DailyForecasts string `thrift:"DailyForecasts,5" form:"DailyForecasts" json:"DailyForecasts" query:"DailyForecasts"`
|
||
EarthquakeInformations string `thrift:"EarthquakeInformations,6" form:"EarthquakeInformations" json:"EarthquakeInformations" query:"EarthquakeInformations"`
|
||
}
|
||
|
||
func NewQueryResp() *QueryResp {
|
||
return &QueryResp{}
|
||
}
|
||
|
||
func (p *QueryResp) InitDefault() {
|
||
}
|
||
|
||
func (p *QueryResp) GetCode() (v int32) {
|
||
return p.Code
|
||
}
|
||
|
||
func (p *QueryResp) GetLocationKey() (v string) {
|
||
return p.LocationKey
|
||
}
|
||
|
||
func (p *QueryResp) GetLocations() (v string) {
|
||
return p.Locations
|
||
}
|
||
|
||
func (p *QueryResp) GetCurrentConditions() (v string) {
|
||
return p.CurrentConditions
|
||
}
|
||
|
||
func (p *QueryResp) GetDailyForecasts() (v string) {
|
||
return p.DailyForecasts
|
||
}
|
||
|
||
func (p *QueryResp) GetEarthquakeInformations() (v string) {
|
||
return p.EarthquakeInformations
|
||
}
|
||
|
||
var fieldIDToName_QueryResp = map[int16]string{
|
||
1: "Code",
|
||
2: "LocationKey",
|
||
3: "Locations",
|
||
4: "CurrentConditions",
|
||
5: "DailyForecasts",
|
||
6: "EarthquakeInformations",
|
||
}
|
||
|
||
func (p *QueryResp) Read(iprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldTypeId thrift.TType
|
||
var fieldId int16
|
||
|
||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||
goto ReadStructBeginError
|
||
}
|
||
|
||
for {
|
||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||
if err != nil {
|
||
goto ReadFieldBeginError
|
||
}
|
||
if fieldTypeId == thrift.STOP {
|
||
break
|
||
}
|
||
|
||
switch fieldId {
|
||
case 1:
|
||
if fieldTypeId == thrift.I32 {
|
||
if err = p.ReadField1(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 2:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField2(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 3:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField3(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 4:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField4(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 5:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField5(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
case 6:
|
||
if fieldTypeId == thrift.STRING {
|
||
if err = p.ReadField6(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
default:
|
||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
}
|
||
if err = iprot.ReadFieldEnd(); err != nil {
|
||
goto ReadFieldEndError
|
||
}
|
||
}
|
||
if err = iprot.ReadStructEnd(); err != nil {
|
||
goto ReadStructEndError
|
||
}
|
||
|
||
return nil
|
||
ReadStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||
ReadFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||
ReadFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_QueryResp[fieldId]), err)
|
||
SkipFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||
|
||
ReadFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||
ReadStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) ReadField1(iprot thrift.TProtocol) error {
|
||
|
||
var _field int32
|
||
if v, err := iprot.ReadI32(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.Code = _field
|
||
return nil
|
||
}
|
||
func (p *QueryResp) ReadField2(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.LocationKey = _field
|
||
return nil
|
||
}
|
||
func (p *QueryResp) ReadField3(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.Locations = _field
|
||
return nil
|
||
}
|
||
func (p *QueryResp) ReadField4(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.CurrentConditions = _field
|
||
return nil
|
||
}
|
||
func (p *QueryResp) ReadField5(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.DailyForecasts = _field
|
||
return nil
|
||
}
|
||
func (p *QueryResp) ReadField6(iprot thrift.TProtocol) error {
|
||
|
||
var _field string
|
||
if v, err := iprot.ReadString(); err != nil {
|
||
return err
|
||
} else {
|
||
_field = v
|
||
}
|
||
p.EarthquakeInformations = _field
|
||
return nil
|
||
}
|
||
|
||
func (p *QueryResp) Write(oprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldId int16
|
||
if err = oprot.WriteStructBegin("QueryResp"); err != nil {
|
||
goto WriteStructBeginError
|
||
}
|
||
if p != nil {
|
||
if err = p.writeField1(oprot); err != nil {
|
||
fieldId = 1
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField2(oprot); err != nil {
|
||
fieldId = 2
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField3(oprot); err != nil {
|
||
fieldId = 3
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField4(oprot); err != nil {
|
||
fieldId = 4
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField5(oprot); err != nil {
|
||
fieldId = 5
|
||
goto WriteFieldError
|
||
}
|
||
if err = p.writeField6(oprot); err != nil {
|
||
fieldId = 6
|
||
goto WriteFieldError
|
||
}
|
||
}
|
||
if err = oprot.WriteFieldStop(); err != nil {
|
||
goto WriteFieldStopError
|
||
}
|
||
if err = oprot.WriteStructEnd(); err != nil {
|
||
goto WriteStructEndError
|
||
}
|
||
return nil
|
||
WriteStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||
WriteFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||
WriteFieldStopError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||
WriteStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) writeField1(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteI32(p.Code); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) writeField2(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("LocationKey", thrift.STRING, 2); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.LocationKey); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) writeField3(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("Locations", thrift.STRING, 3); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.Locations); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) writeField4(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("CurrentConditions", thrift.STRING, 4); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.CurrentConditions); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) writeField5(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("DailyForecasts", thrift.STRING, 5); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.DailyForecasts); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) writeField6(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("EarthquakeInformations", thrift.STRING, 6); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := oprot.WriteString(p.EarthquakeInformations); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err)
|
||
}
|
||
|
||
func (p *QueryResp) String() string {
|
||
if p == nil {
|
||
return "<nil>"
|
||
}
|
||
return fmt.Sprintf("QueryResp(%+v)", *p)
|
||
|
||
}
|
||
|
||
type WeatherAndEarthquakeService interface {
|
||
QueryMethod(ctx context.Context, request *QueryReq) (r *QueryResp, err error)
|
||
}
|
||
|
||
type WeatherAndEarthquakeServiceClient struct {
|
||
c thrift.TClient
|
||
}
|
||
|
||
func NewWeatherAndEarthquakeServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *WeatherAndEarthquakeServiceClient {
|
||
return &WeatherAndEarthquakeServiceClient{
|
||
c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
|
||
}
|
||
}
|
||
|
||
func NewWeatherAndEarthquakeServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *WeatherAndEarthquakeServiceClient {
|
||
return &WeatherAndEarthquakeServiceClient{
|
||
c: thrift.NewTStandardClient(iprot, oprot),
|
||
}
|
||
}
|
||
|
||
func NewWeatherAndEarthquakeServiceClient(c thrift.TClient) *WeatherAndEarthquakeServiceClient {
|
||
return &WeatherAndEarthquakeServiceClient{
|
||
c: c,
|
||
}
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceClient) Client_() thrift.TClient {
|
||
return p.c
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceClient) QueryMethod(ctx context.Context, request *QueryReq) (r *QueryResp, err error) {
|
||
var _args WeatherAndEarthquakeServiceQueryMethodArgs
|
||
_args.Request = request
|
||
var _result WeatherAndEarthquakeServiceQueryMethodResult
|
||
if err = p.Client_().Call(ctx, "QueryMethod", &_args, &_result); err != nil {
|
||
return
|
||
}
|
||
return _result.GetSuccess(), nil
|
||
}
|
||
|
||
type WeatherAndEarthquakeServiceProcessor struct {
|
||
processorMap map[string]thrift.TProcessorFunction
|
||
handler WeatherAndEarthquakeService
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
|
||
p.processorMap[key] = processor
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
|
||
processor, ok = p.processorMap[key]
|
||
return processor, ok
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
|
||
return p.processorMap
|
||
}
|
||
|
||
func NewWeatherAndEarthquakeServiceProcessor(handler WeatherAndEarthquakeService) *WeatherAndEarthquakeServiceProcessor {
|
||
self := &WeatherAndEarthquakeServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
|
||
self.AddToProcessorMap("QueryMethod", &weatherAndEarthquakeServiceProcessorQueryMethod{handler: handler})
|
||
return self
|
||
}
|
||
func (p *WeatherAndEarthquakeServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||
name, _, seqId, err := iprot.ReadMessageBegin()
|
||
if err != nil {
|
||
return false, err
|
||
}
|
||
if processor, ok := p.GetProcessorFunction(name); ok {
|
||
return processor.Process(ctx, seqId, iprot, oprot)
|
||
}
|
||
iprot.Skip(thrift.STRUCT)
|
||
iprot.ReadMessageEnd()
|
||
x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
|
||
oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
|
||
x.Write(oprot)
|
||
oprot.WriteMessageEnd()
|
||
oprot.Flush(ctx)
|
||
return false, x
|
||
}
|
||
|
||
type weatherAndEarthquakeServiceProcessorQueryMethod struct {
|
||
handler WeatherAndEarthquakeService
|
||
}
|
||
|
||
func (p *weatherAndEarthquakeServiceProcessorQueryMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||
args := WeatherAndEarthquakeServiceQueryMethodArgs{}
|
||
if err = args.Read(iprot); err != nil {
|
||
iprot.ReadMessageEnd()
|
||
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
|
||
oprot.WriteMessageBegin("QueryMethod", thrift.EXCEPTION, seqId)
|
||
x.Write(oprot)
|
||
oprot.WriteMessageEnd()
|
||
oprot.Flush(ctx)
|
||
return false, err
|
||
}
|
||
|
||
iprot.ReadMessageEnd()
|
||
var err2 error
|
||
result := WeatherAndEarthquakeServiceQueryMethodResult{}
|
||
var retval *QueryResp
|
||
if retval, err2 = p.handler.QueryMethod(ctx, args.Request); err2 != nil {
|
||
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing QueryMethod: "+err2.Error())
|
||
oprot.WriteMessageBegin("QueryMethod", thrift.EXCEPTION, seqId)
|
||
x.Write(oprot)
|
||
oprot.WriteMessageEnd()
|
||
oprot.Flush(ctx)
|
||
return true, err2
|
||
} else {
|
||
result.Success = retval
|
||
}
|
||
if err2 = oprot.WriteMessageBegin("QueryMethod", thrift.REPLY, seqId); err2 != nil {
|
||
err = err2
|
||
}
|
||
if err2 = result.Write(oprot); err == nil && err2 != nil {
|
||
err = err2
|
||
}
|
||
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
|
||
err = err2
|
||
}
|
||
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
|
||
err = err2
|
||
}
|
||
if err != nil {
|
||
return
|
||
}
|
||
return true, err
|
||
}
|
||
|
||
type WeatherAndEarthquakeServiceQueryMethodArgs struct {
|
||
Request *QueryReq `thrift:"request,1"`
|
||
}
|
||
|
||
func NewWeatherAndEarthquakeServiceQueryMethodArgs() *WeatherAndEarthquakeServiceQueryMethodArgs {
|
||
return &WeatherAndEarthquakeServiceQueryMethodArgs{}
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) InitDefault() {
|
||
}
|
||
|
||
var WeatherAndEarthquakeServiceQueryMethodArgs_Request_DEFAULT *QueryReq
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) GetRequest() (v *QueryReq) {
|
||
if !p.IsSetRequest() {
|
||
return WeatherAndEarthquakeServiceQueryMethodArgs_Request_DEFAULT
|
||
}
|
||
return p.Request
|
||
}
|
||
|
||
var fieldIDToName_WeatherAndEarthquakeServiceQueryMethodArgs = map[int16]string{
|
||
1: "request",
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) IsSetRequest() bool {
|
||
return p.Request != nil
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) Read(iprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldTypeId thrift.TType
|
||
var fieldId int16
|
||
|
||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||
goto ReadStructBeginError
|
||
}
|
||
|
||
for {
|
||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||
if err != nil {
|
||
goto ReadFieldBeginError
|
||
}
|
||
if fieldTypeId == thrift.STOP {
|
||
break
|
||
}
|
||
|
||
switch fieldId {
|
||
case 1:
|
||
if fieldTypeId == thrift.STRUCT {
|
||
if err = p.ReadField1(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
default:
|
||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
}
|
||
if err = iprot.ReadFieldEnd(); err != nil {
|
||
goto ReadFieldEndError
|
||
}
|
||
}
|
||
if err = iprot.ReadStructEnd(); err != nil {
|
||
goto ReadStructEndError
|
||
}
|
||
|
||
return nil
|
||
ReadStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||
ReadFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||
ReadFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_WeatherAndEarthquakeServiceQueryMethodArgs[fieldId]), err)
|
||
SkipFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||
|
||
ReadFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||
ReadStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) ReadField1(iprot thrift.TProtocol) error {
|
||
_field := NewQueryReq()
|
||
if err := _field.Read(iprot); err != nil {
|
||
return err
|
||
}
|
||
p.Request = _field
|
||
return nil
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) Write(oprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldId int16
|
||
if err = oprot.WriteStructBegin("QueryMethod_args"); err != nil {
|
||
goto WriteStructBeginError
|
||
}
|
||
if p != nil {
|
||
if err = p.writeField1(oprot); err != nil {
|
||
fieldId = 1
|
||
goto WriteFieldError
|
||
}
|
||
}
|
||
if err = oprot.WriteFieldStop(); err != nil {
|
||
goto WriteFieldStopError
|
||
}
|
||
if err = oprot.WriteStructEnd(); err != nil {
|
||
goto WriteStructEndError
|
||
}
|
||
return nil
|
||
WriteStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||
WriteFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||
WriteFieldStopError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||
WriteStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) writeField1(oprot thrift.TProtocol) (err error) {
|
||
if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := p.Request.Write(oprot); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodArgs) String() string {
|
||
if p == nil {
|
||
return "<nil>"
|
||
}
|
||
return fmt.Sprintf("WeatherAndEarthquakeServiceQueryMethodArgs(%+v)", *p)
|
||
|
||
}
|
||
|
||
type WeatherAndEarthquakeServiceQueryMethodResult struct {
|
||
Success *QueryResp `thrift:"success,0,optional"`
|
||
}
|
||
|
||
func NewWeatherAndEarthquakeServiceQueryMethodResult() *WeatherAndEarthquakeServiceQueryMethodResult {
|
||
return &WeatherAndEarthquakeServiceQueryMethodResult{}
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) InitDefault() {
|
||
}
|
||
|
||
var WeatherAndEarthquakeServiceQueryMethodResult_Success_DEFAULT *QueryResp
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) GetSuccess() (v *QueryResp) {
|
||
if !p.IsSetSuccess() {
|
||
return WeatherAndEarthquakeServiceQueryMethodResult_Success_DEFAULT
|
||
}
|
||
return p.Success
|
||
}
|
||
|
||
var fieldIDToName_WeatherAndEarthquakeServiceQueryMethodResult = map[int16]string{
|
||
0: "success",
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) IsSetSuccess() bool {
|
||
return p.Success != nil
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) Read(iprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldTypeId thrift.TType
|
||
var fieldId int16
|
||
|
||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||
goto ReadStructBeginError
|
||
}
|
||
|
||
for {
|
||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||
if err != nil {
|
||
goto ReadFieldBeginError
|
||
}
|
||
if fieldTypeId == thrift.STOP {
|
||
break
|
||
}
|
||
|
||
switch fieldId {
|
||
case 0:
|
||
if fieldTypeId == thrift.STRUCT {
|
||
if err = p.ReadField0(iprot); err != nil {
|
||
goto ReadFieldError
|
||
}
|
||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
default:
|
||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||
goto SkipFieldError
|
||
}
|
||
}
|
||
if err = iprot.ReadFieldEnd(); err != nil {
|
||
goto ReadFieldEndError
|
||
}
|
||
}
|
||
if err = iprot.ReadStructEnd(); err != nil {
|
||
goto ReadStructEndError
|
||
}
|
||
|
||
return nil
|
||
ReadStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||
ReadFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||
ReadFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_WeatherAndEarthquakeServiceQueryMethodResult[fieldId]), err)
|
||
SkipFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||
|
||
ReadFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||
ReadStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) ReadField0(iprot thrift.TProtocol) error {
|
||
_field := NewQueryResp()
|
||
if err := _field.Read(iprot); err != nil {
|
||
return err
|
||
}
|
||
p.Success = _field
|
||
return nil
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) Write(oprot thrift.TProtocol) (err error) {
|
||
|
||
var fieldId int16
|
||
if err = oprot.WriteStructBegin("QueryMethod_result"); err != nil {
|
||
goto WriteStructBeginError
|
||
}
|
||
if p != nil {
|
||
if err = p.writeField0(oprot); err != nil {
|
||
fieldId = 0
|
||
goto WriteFieldError
|
||
}
|
||
}
|
||
if err = oprot.WriteFieldStop(); err != nil {
|
||
goto WriteFieldStopError
|
||
}
|
||
if err = oprot.WriteStructEnd(); err != nil {
|
||
goto WriteStructEndError
|
||
}
|
||
return nil
|
||
WriteStructBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||
WriteFieldError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||
WriteFieldStopError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||
WriteStructEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) writeField0(oprot thrift.TProtocol) (err error) {
|
||
if p.IsSetSuccess() {
|
||
if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
|
||
goto WriteFieldBeginError
|
||
}
|
||
if err := p.Success.Write(oprot); err != nil {
|
||
return err
|
||
}
|
||
if err = oprot.WriteFieldEnd(); err != nil {
|
||
goto WriteFieldEndError
|
||
}
|
||
}
|
||
return nil
|
||
WriteFieldBeginError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
|
||
WriteFieldEndError:
|
||
return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
|
||
}
|
||
|
||
func (p *WeatherAndEarthquakeServiceQueryMethodResult) String() string {
|
||
if p == nil {
|
||
return "<nil>"
|
||
}
|
||
return fmt.Sprintf("WeatherAndEarthquakeServiceQueryMethodResult(%+v)", *p)
|
||
|
||
}
|