responsebean.go 474 B

12345678910111213141516171819202122
  1. //@File responsebean.go
  2. //@Time 2022/04/26
  3. //@Author #Suyghur,
  4. package result
  5. type ResponseBean struct {
  6. Code int32 `json:"code"`
  7. Msg string `json:"msg"`
  8. Data interface{} `json:"data"`
  9. }
  10. func Success(data interface{}) *ResponseBean {
  11. if data == nil {
  12. data = map[string]interface{}{}
  13. }
  14. return &ResponseBean{0, "success", data}
  15. }
  16. func Error(code int32, msg string) *ResponseBean {
  17. return &ResponseBean{code, msg, map[string]interface{}{}}
  18. }