base.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package models
  2. type BaseResponse struct {
  3. Ret int
  4. Msg string
  5. ErrMsg string
  6. ErrCode string
  7. Data interface{}
  8. Success bool `description:"true 执行成功,false 执行失败"`
  9. IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
  10. IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
  11. }
  12. type BaseResponseRef struct {
  13. Ret int
  14. Msg string
  15. ErrMsg string
  16. ErrCode string
  17. Data string
  18. }
  19. type BaseResponseResult struct {
  20. Ret int `description:"状态:200 成功,408 重新登录,403:为失败"`
  21. Msg string `description:"提示信息,对用户展示"`
  22. ErrMsg string `description:"错误信息,供开发定位问题"`
  23. ErrCode string `description:"错误编码,预留"`
  24. Data string `description:"返回数据,json格式字符串"`
  25. }
  26. func (r *BaseResponse) Init() *BaseResponse {
  27. return &BaseResponse{Ret: 403, IsSendEmail: true}
  28. }
  29. type BaseRequest struct {
  30. }
  31. func (br *BaseRequest) Init() *BaseRequest {
  32. return &BaseRequest{}
  33. }
  34. type ResultData struct {
  35. Code int `json:"code" description:"状态码"`
  36. Msg string `json:"msg" description:"提示信息"`
  37. Data interface{} `json:"data" description:"返回数据"`
  38. ErrMsg string `json:"-" description:"错误信息,不用返回给前端,只是做日志记录"`
  39. }