github.com/cloudwego/kitex@v0.9.0/pkg/generic/thrift/base.go (about)

     1  /*
     2   * Copyright 2021 CloudWeGo Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package thrift
    18  
    19  import (
    20  	"fmt"
    21  
    22  	"github.com/apache/thrift/lib/go/thrift"
    23  )
    24  
    25  type TrafficEnv struct {
    26  	Open bool `thrift:"Open,1" json:"Open"`
    27  
    28  	Env string `thrift:"Env,2" json:"Env"`
    29  }
    30  
    31  func NewTrafficEnv() *TrafficEnv {
    32  	return &TrafficEnv{
    33  		Open: false,
    34  		Env:  "",
    35  	}
    36  }
    37  
    38  func (p *TrafficEnv) GetOpen() bool {
    39  	return p.Open
    40  }
    41  
    42  func (p *TrafficEnv) GetEnv() string {
    43  	return p.Env
    44  }
    45  
    46  func (p *TrafficEnv) SetOpen(val bool) {
    47  	p.Open = val
    48  }
    49  
    50  func (p *TrafficEnv) SetEnv(val string) {
    51  	p.Env = val
    52  }
    53  
    54  var fieldIDToName_TrafficEnv = map[int16]string{
    55  	1: "Open",
    56  	2: "Env",
    57  }
    58  
    59  func (p *TrafficEnv) Read(iprot thrift.TProtocol) (err error) {
    60  	var fieldTypeId thrift.TType
    61  	var fieldId int16
    62  
    63  	if _, err = iprot.ReadStructBegin(); err != nil {
    64  		goto ReadStructBeginError
    65  	}
    66  
    67  	for {
    68  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
    69  		if err != nil {
    70  			goto ReadFieldBeginError
    71  		}
    72  		if fieldTypeId == thrift.STOP {
    73  			break
    74  		}
    75  
    76  		switch fieldId {
    77  		case 1:
    78  			if fieldTypeId == thrift.BOOL {
    79  				if err = p.ReadField1(iprot); err != nil {
    80  					goto ReadFieldError
    81  				}
    82  			} else {
    83  				if err = iprot.Skip(fieldTypeId); err != nil {
    84  					goto SkipFieldError
    85  				}
    86  			}
    87  		case 2:
    88  			if fieldTypeId == thrift.STRING {
    89  				if err = p.ReadField2(iprot); err != nil {
    90  					goto ReadFieldError
    91  				}
    92  			} else {
    93  				if err = iprot.Skip(fieldTypeId); err != nil {
    94  					goto SkipFieldError
    95  				}
    96  			}
    97  		default:
    98  			if err = iprot.Skip(fieldTypeId); err != nil {
    99  				goto SkipFieldError
   100  			}
   101  		}
   102  
   103  		if err = iprot.ReadFieldEnd(); err != nil {
   104  			goto ReadFieldEndError
   105  		}
   106  	}
   107  	if err = iprot.ReadStructEnd(); err != nil {
   108  		goto ReadStructEndError
   109  	}
   110  
   111  	return nil
   112  ReadStructBeginError:
   113  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   114  ReadFieldBeginError:
   115  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   116  ReadFieldError:
   117  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TrafficEnv[fieldId]), err)
   118  SkipFieldError:
   119  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   120  
   121  ReadFieldEndError:
   122  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   123  ReadStructEndError:
   124  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   125  }
   126  
   127  func (p *TrafficEnv) ReadField1(iprot thrift.TProtocol) error {
   128  	if v, err := iprot.ReadBool(); err != nil {
   129  		return err
   130  	} else {
   131  		p.Open = v
   132  	}
   133  	return nil
   134  }
   135  
   136  func (p *TrafficEnv) ReadField2(iprot thrift.TProtocol) error {
   137  	if v, err := iprot.ReadString(); err != nil {
   138  		return err
   139  	} else {
   140  		p.Env = v
   141  	}
   142  	return nil
   143  }
   144  
   145  func (p *TrafficEnv) Write(oprot thrift.TProtocol) (err error) {
   146  	var fieldId int16
   147  	if err = oprot.WriteStructBegin("TrafficEnv"); err != nil {
   148  		goto WriteStructBeginError
   149  	}
   150  	if p != nil {
   151  		if err = p.writeField1(oprot); err != nil {
   152  			fieldId = 1
   153  			goto WriteFieldError
   154  		}
   155  		if err = p.writeField2(oprot); err != nil {
   156  			fieldId = 2
   157  			goto WriteFieldError
   158  		}
   159  
   160  	}
   161  	if err = oprot.WriteFieldStop(); err != nil {
   162  		goto WriteFieldStopError
   163  	}
   164  	if err = oprot.WriteStructEnd(); err != nil {
   165  		goto WriteStructEndError
   166  	}
   167  	return nil
   168  WriteStructBeginError:
   169  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   170  WriteFieldError:
   171  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   172  WriteFieldStopError:
   173  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   174  WriteStructEndError:
   175  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   176  }
   177  
   178  func (p *TrafficEnv) writeField1(oprot thrift.TProtocol) (err error) {
   179  	if err = oprot.WriteFieldBegin("Open", thrift.BOOL, 1); err != nil {
   180  		goto WriteFieldBeginError
   181  	}
   182  	if err := oprot.WriteBool(p.Open); err != nil {
   183  		return err
   184  	}
   185  	if err = oprot.WriteFieldEnd(); err != nil {
   186  		goto WriteFieldEndError
   187  	}
   188  	return nil
   189  WriteFieldBeginError:
   190  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   191  WriteFieldEndError:
   192  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   193  }
   194  
   195  func (p *TrafficEnv) writeField2(oprot thrift.TProtocol) (err error) {
   196  	if err = oprot.WriteFieldBegin("Env", thrift.STRING, 2); err != nil {
   197  		goto WriteFieldBeginError
   198  	}
   199  	if err := oprot.WriteString(p.Env); err != nil {
   200  		return err
   201  	}
   202  	if err = oprot.WriteFieldEnd(); err != nil {
   203  		goto WriteFieldEndError
   204  	}
   205  	return nil
   206  WriteFieldBeginError:
   207  	return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
   208  WriteFieldEndError:
   209  	return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
   210  }
   211  
   212  func (p *TrafficEnv) String() string {
   213  	if p == nil {
   214  		return "<nil>"
   215  	}
   216  	return fmt.Sprintf("TrafficEnv(%+v)", *p)
   217  }
   218  
   219  type Base struct {
   220  	LogID string `thrift:"LogID,1" json:"LogID"`
   221  
   222  	Caller string `thrift:"Caller,2" json:"Caller"`
   223  
   224  	Addr string `thrift:"Addr,3" json:"Addr"`
   225  
   226  	Client string `thrift:"Client,4" json:"Client"`
   227  
   228  	TrafficEnv *TrafficEnv `thrift:"TrafficEnv,5" json:"TrafficEnv,omitempty"`
   229  
   230  	Extra map[string]string `thrift:"Extra,6" json:"Extra,omitempty"`
   231  }
   232  
   233  func NewBase() *Base {
   234  	return &Base{
   235  		LogID:  "",
   236  		Caller: "",
   237  		Addr:   "",
   238  		Client: "",
   239  	}
   240  }
   241  
   242  func (p *Base) GetLogID() string {
   243  	return p.LogID
   244  }
   245  
   246  func (p *Base) GetCaller() string {
   247  	return p.Caller
   248  }
   249  
   250  func (p *Base) GetAddr() string {
   251  	return p.Addr
   252  }
   253  
   254  func (p *Base) GetClient() string {
   255  	return p.Client
   256  }
   257  
   258  var Base_TrafficEnv_DEFAULT *TrafficEnv
   259  
   260  func (p *Base) GetTrafficEnv() *TrafficEnv {
   261  	if !p.IsSetTrafficEnv() {
   262  		return Base_TrafficEnv_DEFAULT
   263  	}
   264  	return p.TrafficEnv
   265  }
   266  
   267  var Base_Extra_DEFAULT map[string]string
   268  
   269  func (p *Base) GetExtra() map[string]string {
   270  	if !p.IsSetExtra() {
   271  		return Base_Extra_DEFAULT
   272  	}
   273  	return p.Extra
   274  }
   275  
   276  func (p *Base) SetLogID(val string) {
   277  	p.LogID = val
   278  }
   279  
   280  func (p *Base) SetCaller(val string) {
   281  	p.Caller = val
   282  }
   283  
   284  func (p *Base) SetAddr(val string) {
   285  	p.Addr = val
   286  }
   287  
   288  func (p *Base) SetClient(val string) {
   289  	p.Client = val
   290  }
   291  
   292  func (p *Base) SetTrafficEnv(val *TrafficEnv) {
   293  	p.TrafficEnv = val
   294  }
   295  
   296  func (p *Base) SetExtra(val map[string]string) {
   297  	p.Extra = val
   298  }
   299  
   300  var fieldIDToName_Base = map[int16]string{
   301  	1: "LogID",
   302  	2: "Caller",
   303  	3: "Addr",
   304  	4: "Client",
   305  	5: "TrafficEnv",
   306  	6: "Extra",
   307  }
   308  
   309  func (p *Base) IsSetTrafficEnv() bool {
   310  	return p.TrafficEnv != nil
   311  }
   312  
   313  func (p *Base) IsSetExtra() bool {
   314  	return p.Extra != nil
   315  }
   316  
   317  func (p *Base) Read(iprot thrift.TProtocol) (err error) {
   318  	var fieldTypeId thrift.TType
   319  	var fieldId int16
   320  
   321  	if _, err = iprot.ReadStructBegin(); err != nil {
   322  		goto ReadStructBeginError
   323  	}
   324  
   325  	for {
   326  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   327  		if err != nil {
   328  			goto ReadFieldBeginError
   329  		}
   330  		if fieldTypeId == thrift.STOP {
   331  			break
   332  		}
   333  
   334  		switch fieldId {
   335  		case 1:
   336  			if fieldTypeId == thrift.STRING {
   337  				if err = p.ReadField1(iprot); err != nil {
   338  					goto ReadFieldError
   339  				}
   340  			} else {
   341  				if err = iprot.Skip(fieldTypeId); err != nil {
   342  					goto SkipFieldError
   343  				}
   344  			}
   345  		case 2:
   346  			if fieldTypeId == thrift.STRING {
   347  				if err = p.ReadField2(iprot); err != nil {
   348  					goto ReadFieldError
   349  				}
   350  			} else {
   351  				if err = iprot.Skip(fieldTypeId); err != nil {
   352  					goto SkipFieldError
   353  				}
   354  			}
   355  		case 3:
   356  			if fieldTypeId == thrift.STRING {
   357  				if err = p.ReadField3(iprot); err != nil {
   358  					goto ReadFieldError
   359  				}
   360  			} else {
   361  				if err = iprot.Skip(fieldTypeId); err != nil {
   362  					goto SkipFieldError
   363  				}
   364  			}
   365  		case 4:
   366  			if fieldTypeId == thrift.STRING {
   367  				if err = p.ReadField4(iprot); err != nil {
   368  					goto ReadFieldError
   369  				}
   370  			} else {
   371  				if err = iprot.Skip(fieldTypeId); err != nil {
   372  					goto SkipFieldError
   373  				}
   374  			}
   375  		case 5:
   376  			if fieldTypeId == thrift.STRUCT {
   377  				if err = p.ReadField5(iprot); err != nil {
   378  					goto ReadFieldError
   379  				}
   380  			} else {
   381  				if err = iprot.Skip(fieldTypeId); err != nil {
   382  					goto SkipFieldError
   383  				}
   384  			}
   385  		case 6:
   386  			if fieldTypeId == thrift.MAP {
   387  				if err = p.ReadField6(iprot); err != nil {
   388  					goto ReadFieldError
   389  				}
   390  			} else {
   391  				if err = iprot.Skip(fieldTypeId); err != nil {
   392  					goto SkipFieldError
   393  				}
   394  			}
   395  		default:
   396  			if err = iprot.Skip(fieldTypeId); err != nil {
   397  				goto SkipFieldError
   398  			}
   399  		}
   400  
   401  		if err = iprot.ReadFieldEnd(); err != nil {
   402  			goto ReadFieldEndError
   403  		}
   404  	}
   405  	if err = iprot.ReadStructEnd(); err != nil {
   406  		goto ReadStructEndError
   407  	}
   408  
   409  	return nil
   410  ReadStructBeginError:
   411  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   412  ReadFieldBeginError:
   413  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   414  ReadFieldError:
   415  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Base[fieldId]), err)
   416  SkipFieldError:
   417  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   418  
   419  ReadFieldEndError:
   420  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   421  ReadStructEndError:
   422  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   423  }
   424  
   425  func (p *Base) ReadField1(iprot thrift.TProtocol) error {
   426  	if v, err := iprot.ReadString(); err != nil {
   427  		return err
   428  	} else {
   429  		p.LogID = v
   430  	}
   431  	return nil
   432  }
   433  
   434  func (p *Base) ReadField2(iprot thrift.TProtocol) error {
   435  	if v, err := iprot.ReadString(); err != nil {
   436  		return err
   437  	} else {
   438  		p.Caller = v
   439  	}
   440  	return nil
   441  }
   442  
   443  func (p *Base) ReadField3(iprot thrift.TProtocol) error {
   444  	if v, err := iprot.ReadString(); err != nil {
   445  		return err
   446  	} else {
   447  		p.Addr = v
   448  	}
   449  	return nil
   450  }
   451  
   452  func (p *Base) ReadField4(iprot thrift.TProtocol) error {
   453  	if v, err := iprot.ReadString(); err != nil {
   454  		return err
   455  	} else {
   456  		p.Client = v
   457  	}
   458  	return nil
   459  }
   460  
   461  func (p *Base) ReadField5(iprot thrift.TProtocol) error {
   462  	p.TrafficEnv = NewTrafficEnv()
   463  	if err := p.TrafficEnv.Read(iprot); err != nil {
   464  		return err
   465  	}
   466  	return nil
   467  }
   468  
   469  func (p *Base) ReadField6(iprot thrift.TProtocol) error {
   470  	_, _, size, err := iprot.ReadMapBegin()
   471  	if err != nil {
   472  		return err
   473  	}
   474  	p.Extra = make(map[string]string, size)
   475  	for i := 0; i < size; i++ {
   476  		var _key string
   477  		if v, err := iprot.ReadString(); err != nil {
   478  			return err
   479  		} else {
   480  			_key = v
   481  		}
   482  
   483  		var _val string
   484  		if v, err := iprot.ReadString(); err != nil {
   485  			return err
   486  		} else {
   487  			_val = v
   488  		}
   489  
   490  		p.Extra[_key] = _val
   491  	}
   492  	if err := iprot.ReadMapEnd(); err != nil {
   493  		return err
   494  	}
   495  	return nil
   496  }
   497  
   498  func (p *Base) Write(oprot thrift.TProtocol) (err error) {
   499  	var fieldId int16
   500  	if err = oprot.WriteStructBegin("Base"); err != nil {
   501  		goto WriteStructBeginError
   502  	}
   503  	if p != nil {
   504  		if err = p.writeField1(oprot); err != nil {
   505  			fieldId = 1
   506  			goto WriteFieldError
   507  		}
   508  		if err = p.writeField2(oprot); err != nil {
   509  			fieldId = 2
   510  			goto WriteFieldError
   511  		}
   512  		if err = p.writeField3(oprot); err != nil {
   513  			fieldId = 3
   514  			goto WriteFieldError
   515  		}
   516  		if err = p.writeField4(oprot); err != nil {
   517  			fieldId = 4
   518  			goto WriteFieldError
   519  		}
   520  		if err = p.writeField5(oprot); err != nil {
   521  			fieldId = 5
   522  			goto WriteFieldError
   523  		}
   524  		if err = p.writeField6(oprot); err != nil {
   525  			fieldId = 6
   526  			goto WriteFieldError
   527  		}
   528  
   529  	}
   530  	if err = oprot.WriteFieldStop(); err != nil {
   531  		goto WriteFieldStopError
   532  	}
   533  	if err = oprot.WriteStructEnd(); err != nil {
   534  		goto WriteStructEndError
   535  	}
   536  	return nil
   537  WriteStructBeginError:
   538  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   539  WriteFieldError:
   540  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   541  WriteFieldStopError:
   542  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   543  WriteStructEndError:
   544  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   545  }
   546  
   547  func (p *Base) writeField1(oprot thrift.TProtocol) (err error) {
   548  	if err = oprot.WriteFieldBegin("LogID", thrift.STRING, 1); err != nil {
   549  		goto WriteFieldBeginError
   550  	}
   551  	if err := oprot.WriteString(p.LogID); err != nil {
   552  		return err
   553  	}
   554  	if err = oprot.WriteFieldEnd(); err != nil {
   555  		goto WriteFieldEndError
   556  	}
   557  	return nil
   558  WriteFieldBeginError:
   559  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   560  WriteFieldEndError:
   561  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   562  }
   563  
   564  func (p *Base) writeField2(oprot thrift.TProtocol) (err error) {
   565  	if err = oprot.WriteFieldBegin("Caller", thrift.STRING, 2); err != nil {
   566  		goto WriteFieldBeginError
   567  	}
   568  	if err := oprot.WriteString(p.Caller); err != nil {
   569  		return err
   570  	}
   571  	if err = oprot.WriteFieldEnd(); err != nil {
   572  		goto WriteFieldEndError
   573  	}
   574  	return nil
   575  WriteFieldBeginError:
   576  	return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
   577  WriteFieldEndError:
   578  	return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
   579  }
   580  
   581  func (p *Base) writeField3(oprot thrift.TProtocol) (err error) {
   582  	if err = oprot.WriteFieldBegin("Addr", thrift.STRING, 3); err != nil {
   583  		goto WriteFieldBeginError
   584  	}
   585  	if err := oprot.WriteString(p.Addr); err != nil {
   586  		return err
   587  	}
   588  	if err = oprot.WriteFieldEnd(); err != nil {
   589  		goto WriteFieldEndError
   590  	}
   591  	return nil
   592  WriteFieldBeginError:
   593  	return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
   594  WriteFieldEndError:
   595  	return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
   596  }
   597  
   598  func (p *Base) writeField4(oprot thrift.TProtocol) (err error) {
   599  	if err = oprot.WriteFieldBegin("Client", thrift.STRING, 4); err != nil {
   600  		goto WriteFieldBeginError
   601  	}
   602  	if err := oprot.WriteString(p.Client); err != nil {
   603  		return err
   604  	}
   605  	if err = oprot.WriteFieldEnd(); err != nil {
   606  		goto WriteFieldEndError
   607  	}
   608  	return nil
   609  WriteFieldBeginError:
   610  	return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err)
   611  WriteFieldEndError:
   612  	return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err)
   613  }
   614  
   615  func (p *Base) writeField5(oprot thrift.TProtocol) (err error) {
   616  	if p.IsSetTrafficEnv() {
   617  		if err = oprot.WriteFieldBegin("TrafficEnv", thrift.STRUCT, 5); err != nil {
   618  			goto WriteFieldBeginError
   619  		}
   620  		if err := p.TrafficEnv.Write(oprot); err != nil {
   621  			return err
   622  		}
   623  		if err = oprot.WriteFieldEnd(); err != nil {
   624  			goto WriteFieldEndError
   625  		}
   626  	}
   627  	return nil
   628  WriteFieldBeginError:
   629  	return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err)
   630  WriteFieldEndError:
   631  	return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err)
   632  }
   633  
   634  func (p *Base) writeField6(oprot thrift.TProtocol) (err error) {
   635  	if p.IsSetExtra() {
   636  		if err = oprot.WriteFieldBegin("Extra", thrift.MAP, 6); err != nil {
   637  			goto WriteFieldBeginError
   638  		}
   639  		if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Extra)); err != nil {
   640  			return err
   641  		}
   642  		for k, v := range p.Extra {
   643  
   644  			if err := oprot.WriteString(k); err != nil {
   645  				return err
   646  			}
   647  
   648  			if err := oprot.WriteString(v); err != nil {
   649  				return err
   650  			}
   651  		}
   652  		if err := oprot.WriteMapEnd(); err != nil {
   653  			return err
   654  		}
   655  		if err = oprot.WriteFieldEnd(); err != nil {
   656  			goto WriteFieldEndError
   657  		}
   658  	}
   659  	return nil
   660  WriteFieldBeginError:
   661  	return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err)
   662  WriteFieldEndError:
   663  	return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err)
   664  }
   665  
   666  func (p *Base) String() string {
   667  	if p == nil {
   668  		return "<nil>"
   669  	}
   670  	return fmt.Sprintf("Base(%+v)", *p)
   671  }
   672  
   673  type BaseResp struct {
   674  	StatusMessage string `thrift:"StatusMessage,1" json:"StatusMessage"`
   675  
   676  	StatusCode int32 `thrift:"StatusCode,2" json:"StatusCode"`
   677  
   678  	Extra map[string]string `thrift:"Extra,3" json:"Extra,omitempty"`
   679  }
   680  
   681  func NewBaseResp() *BaseResp {
   682  	return &BaseResp{
   683  		StatusMessage: "",
   684  		StatusCode:    0,
   685  	}
   686  }
   687  
   688  func (p *BaseResp) GetStatusMessage() string {
   689  	return p.StatusMessage
   690  }
   691  
   692  func (p *BaseResp) GetStatusCode() int32 {
   693  	return p.StatusCode
   694  }
   695  
   696  var BaseResp_Extra_DEFAULT map[string]string
   697  
   698  func (p *BaseResp) GetExtra() map[string]string {
   699  	if !p.IsSetExtra() {
   700  		return BaseResp_Extra_DEFAULT
   701  	}
   702  	return p.Extra
   703  }
   704  
   705  func (p *BaseResp) SetStatusMessage(val string) {
   706  	p.StatusMessage = val
   707  }
   708  
   709  func (p *BaseResp) SetStatusCode(val int32) {
   710  	p.StatusCode = val
   711  }
   712  
   713  func (p *BaseResp) SetExtra(val map[string]string) {
   714  	p.Extra = val
   715  }
   716  
   717  var fieldIDToName_BaseResp = map[int16]string{
   718  	1: "StatusMessage",
   719  	2: "StatusCode",
   720  	3: "Extra",
   721  }
   722  
   723  func (p *BaseResp) IsSetExtra() bool {
   724  	return p.Extra != nil
   725  }
   726  
   727  func (p *BaseResp) Read(iprot thrift.TProtocol) (err error) {
   728  	var fieldTypeId thrift.TType
   729  	var fieldId int16
   730  
   731  	if _, err = iprot.ReadStructBegin(); err != nil {
   732  		goto ReadStructBeginError
   733  	}
   734  
   735  	for {
   736  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   737  		if err != nil {
   738  			goto ReadFieldBeginError
   739  		}
   740  		if fieldTypeId == thrift.STOP {
   741  			break
   742  		}
   743  
   744  		switch fieldId {
   745  		case 1:
   746  			if fieldTypeId == thrift.STRING {
   747  				if err = p.ReadField1(iprot); err != nil {
   748  					goto ReadFieldError
   749  				}
   750  			} else {
   751  				if err = iprot.Skip(fieldTypeId); err != nil {
   752  					goto SkipFieldError
   753  				}
   754  			}
   755  		case 2:
   756  			if fieldTypeId == thrift.I32 {
   757  				if err = p.ReadField2(iprot); err != nil {
   758  					goto ReadFieldError
   759  				}
   760  			} else {
   761  				if err = iprot.Skip(fieldTypeId); err != nil {
   762  					goto SkipFieldError
   763  				}
   764  			}
   765  		case 3:
   766  			if fieldTypeId == thrift.MAP {
   767  				if err = p.ReadField3(iprot); err != nil {
   768  					goto ReadFieldError
   769  				}
   770  			} else {
   771  				if err = iprot.Skip(fieldTypeId); err != nil {
   772  					goto SkipFieldError
   773  				}
   774  			}
   775  		default:
   776  			if err = iprot.Skip(fieldTypeId); err != nil {
   777  				goto SkipFieldError
   778  			}
   779  		}
   780  
   781  		if err = iprot.ReadFieldEnd(); err != nil {
   782  			goto ReadFieldEndError
   783  		}
   784  	}
   785  	if err = iprot.ReadStructEnd(); err != nil {
   786  		goto ReadStructEndError
   787  	}
   788  
   789  	return nil
   790  ReadStructBeginError:
   791  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   792  ReadFieldBeginError:
   793  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   794  ReadFieldError:
   795  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaseResp[fieldId]), err)
   796  SkipFieldError:
   797  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   798  
   799  ReadFieldEndError:
   800  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   801  ReadStructEndError:
   802  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   803  }
   804  
   805  func (p *BaseResp) ReadField1(iprot thrift.TProtocol) error {
   806  	if v, err := iprot.ReadString(); err != nil {
   807  		return err
   808  	} else {
   809  		p.StatusMessage = v
   810  	}
   811  	return nil
   812  }
   813  
   814  func (p *BaseResp) ReadField2(iprot thrift.TProtocol) error {
   815  	if v, err := iprot.ReadI32(); err != nil {
   816  		return err
   817  	} else {
   818  		p.StatusCode = v
   819  	}
   820  	return nil
   821  }
   822  
   823  func (p *BaseResp) ReadField3(iprot thrift.TProtocol) error {
   824  	_, _, size, err := iprot.ReadMapBegin()
   825  	if err != nil {
   826  		return err
   827  	}
   828  	p.Extra = make(map[string]string, size)
   829  	for i := 0; i < size; i++ {
   830  		var _key string
   831  		if v, err := iprot.ReadString(); err != nil {
   832  			return err
   833  		} else {
   834  			_key = v
   835  		}
   836  
   837  		var _val string
   838  		if v, err := iprot.ReadString(); err != nil {
   839  			return err
   840  		} else {
   841  			_val = v
   842  		}
   843  
   844  		p.Extra[_key] = _val
   845  	}
   846  	if err := iprot.ReadMapEnd(); err != nil {
   847  		return err
   848  	}
   849  	return nil
   850  }
   851  
   852  func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) {
   853  	var fieldId int16
   854  	if err = oprot.WriteStructBegin("BaseResp"); err != nil {
   855  		goto WriteStructBeginError
   856  	}
   857  	if p != nil {
   858  		if err = p.writeField1(oprot); err != nil {
   859  			fieldId = 1
   860  			goto WriteFieldError
   861  		}
   862  		if err = p.writeField2(oprot); err != nil {
   863  			fieldId = 2
   864  			goto WriteFieldError
   865  		}
   866  		if err = p.writeField3(oprot); err != nil {
   867  			fieldId = 3
   868  			goto WriteFieldError
   869  		}
   870  
   871  	}
   872  	if err = oprot.WriteFieldStop(); err != nil {
   873  		goto WriteFieldStopError
   874  	}
   875  	if err = oprot.WriteStructEnd(); err != nil {
   876  		goto WriteStructEndError
   877  	}
   878  	return nil
   879  WriteStructBeginError:
   880  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   881  WriteFieldError:
   882  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   883  WriteFieldStopError:
   884  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   885  WriteStructEndError:
   886  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   887  }
   888  
   889  func (p *BaseResp) writeField1(oprot thrift.TProtocol) (err error) {
   890  	if err = oprot.WriteFieldBegin("StatusMessage", thrift.STRING, 1); err != nil {
   891  		goto WriteFieldBeginError
   892  	}
   893  	if err := oprot.WriteString(p.StatusMessage); err != nil {
   894  		return err
   895  	}
   896  	if err = oprot.WriteFieldEnd(); err != nil {
   897  		goto WriteFieldEndError
   898  	}
   899  	return nil
   900  WriteFieldBeginError:
   901  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   902  WriteFieldEndError:
   903  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   904  }
   905  
   906  func (p *BaseResp) writeField2(oprot thrift.TProtocol) (err error) {
   907  	if err = oprot.WriteFieldBegin("StatusCode", thrift.I32, 2); err != nil {
   908  		goto WriteFieldBeginError
   909  	}
   910  	if err := oprot.WriteI32(p.StatusCode); err != nil {
   911  		return err
   912  	}
   913  	if err = oprot.WriteFieldEnd(); err != nil {
   914  		goto WriteFieldEndError
   915  	}
   916  	return nil
   917  WriteFieldBeginError:
   918  	return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
   919  WriteFieldEndError:
   920  	return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
   921  }
   922  
   923  func (p *BaseResp) writeField3(oprot thrift.TProtocol) (err error) {
   924  	if p.IsSetExtra() {
   925  		if err = oprot.WriteFieldBegin("Extra", thrift.MAP, 3); err != nil {
   926  			goto WriteFieldBeginError
   927  		}
   928  		if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Extra)); err != nil {
   929  			return err
   930  		}
   931  		for k, v := range p.Extra {
   932  
   933  			if err := oprot.WriteString(k); err != nil {
   934  				return err
   935  			}
   936  
   937  			if err := oprot.WriteString(v); err != nil {
   938  				return err
   939  			}
   940  		}
   941  		if err := oprot.WriteMapEnd(); err != nil {
   942  			return err
   943  		}
   944  		if err = oprot.WriteFieldEnd(); err != nil {
   945  			goto WriteFieldEndError
   946  		}
   947  	}
   948  	return nil
   949  WriteFieldBeginError:
   950  	return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
   951  WriteFieldEndError:
   952  	return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
   953  }
   954  
   955  func (p *BaseResp) String() string {
   956  	if p == nil {
   957  		return "<nil>"
   958  	}
   959  	return fmt.Sprintf("BaseResp(%+v)", *p)
   960  }