model.go 1.0 KB

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