response.go 580 B

1234567891011121314151617181920212223242526272829
  1. package types
  2. type DifySandboxResponse struct {
  3. // Code is the code of the response
  4. Code int `json:"code"`
  5. // Message is the message of the response
  6. Message string `json:"message"`
  7. // Data is the data of the response
  8. Data interface{} `json:"data"`
  9. }
  10. func SuccessResponse(data interface{}) *DifySandboxResponse {
  11. return &DifySandboxResponse{
  12. Code: 0,
  13. Message: "success",
  14. Data: data,
  15. }
  16. }
  17. func ErrorResponse(code int, message string) *DifySandboxResponse {
  18. if code >= 0 {
  19. code = -1
  20. }
  21. return &DifySandboxResponse{
  22. Code: code,
  23. Message: message,
  24. }
  25. }