model.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package app
  2. type Response struct {
  3. Code int `json:"code"`
  4. Message string `json:"message"`
  5. // 数据集
  6. Data interface{} `json:"data"`
  7. }
  8. type AliResponse struct {
  9. Code int `json:"code"`
  10. Message string `json:"message"`
  11. // 数据集
  12. Data interface{} `json:"data"`
  13. }
  14. type ApiBaseOutputHead struct {
  15. Code int `json:"code" example:"200"`
  16. Msg string `json:"msg"`
  17. }
  18. type Page struct {
  19. List interface{} `json:"rows"`
  20. Count int `json:"count"`
  21. PageIndex int `json:"pageIndex"`
  22. PageSize int `json:"pageSize"`
  23. }
  24. type PageResponse struct {
  25. ApiBaseOutputHead ApiBaseOutputHead `json:"apiBaseOutputHead"`
  26. //Data interface{} `json:"data"`
  27. // 代码
  28. //Code int `json:"code" example:"200"`
  29. // 数据集
  30. Data Page `json:"data"`
  31. // 消息
  32. //Msg string `json:"msg"`
  33. }
  34. type PageRes struct {
  35. // 代码
  36. Code int `json:"code"`
  37. // 数据集
  38. Data Page `json:"data"`
  39. // 消息
  40. Msg string `json:"message"`
  41. }
  42. func (res *Response) ReturnOK() *Response {
  43. res.Code = 200
  44. return res
  45. }
  46. func (res *Response) ReturnError(code int) *Response {
  47. res.Code = code
  48. return res
  49. }
  50. func (res *PageResponse) ReturnOK() *PageResponse {
  51. res.ApiBaseOutputHead.Code = 200
  52. return res
  53. }