model.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package response
  2. type Response struct {
  3. Msg string `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"`
  4. Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
  5. Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
  6. RequestId string `protobuf:"bytes,1,opt,name=requestId,proto3" json:"requestId,omitempty"`
  7. }
  8. type response struct {
  9. Response
  10. Data interface{} `json:"data"`
  11. }
  12. type Page struct {
  13. Count int `json:"total"`
  14. PageIndex int `json:"pageIndex"`
  15. PageSize int `json:"pageSize"`
  16. }
  17. type page struct {
  18. Page
  19. List interface{} `json:"rows"`
  20. }
  21. func (e *response) SetData(data interface{}) {
  22. e.Data = data
  23. }
  24. func (e *response) Clone() Responses {
  25. return &response{
  26. Response: e.Response,
  27. Data: e.Data,
  28. }
  29. }
  30. func (e *response) SetTraceID(id string) {
  31. e.RequestId = id
  32. }
  33. func (e *response) SetMsg(s string) {
  34. e.Msg = s
  35. }
  36. func (e *response) SetCode(code int32) {
  37. e.Code = code
  38. }
  39. func (e *response) SetSuccess(success bool) {
  40. if !success {
  41. e.Status = "error"
  42. }
  43. }