resp.go 479 B

123456789101112131415161718192021222324252627
  1. package utils
  2. import "git.i2edu.net/i2/i2-bill-api/internal/types"
  3. func ReturnHTTPSuccess(val interface{}) *types.Response {
  4. rtndata := types.Response{
  5. Code: 200,
  6. Data: val,
  7. }
  8. return &rtndata
  9. }
  10. func ReturnHTTPFail(err error) *types.Response {
  11. rtndata := types.Response{
  12. Code: 500,
  13. Msg: err.Error(),
  14. }
  15. return &rtndata
  16. }
  17. func ReturnHTTPUnauthorized(err error) *types.Response {
  18. rtndata := types.Response{
  19. Code: 401,
  20. Msg: err.Error(),
  21. }
  22. return &rtndata
  23. }