You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
2.3 KiB

2 years ago
  1. package constant
  2. type ErrorCode int
  3. type ErrCodeInfo struct {
  4. Code ErrorCode `json:"code"`
  5. Msg string `json:"msg"`
  6. }
  7. const (
  8. Success ErrorCode = 0 //成功 [SUCCESS]
  9. IllegalAccess ErrorCode = 600000 //未登陆或非法访问
  10. AuthorizationExpired ErrorCode = 600001 //授权已经过期
  11. ErrorInfo ErrorCode = 600002 //错误信息
  12. ParamInvalid ErrorCode = 601000 //无效的请求参数 [Invalid request parameters]
  13. ServerError ErrorCode = 601001 //服务器内部错误 [Server internal error]
  14. NotFound ErrorCode = 601002 //not found
  15. RecordNotFound ErrorCode = 601003 //记录没有发现
  16. ErrorUserNameOrPassword ErrorCode = 601004 //用户名或密码错误
  17. SaveFailed ErrorCode = 601005 //保存失败
  18. EncryptionDataFailed ErrorCode = 601006 //加密用户数据失败
  19. CheckSuccess ErrorCode = 601007 //检测配置成功
  20. CheckFail ErrorCode = 601008 //检测配置成功
  21. FireReqLimit ErrorCode = 601009 //请求达到限制阈值
  22. RepeatName ErrorCode = 604003 //该名称已存在
  23. )
  24. var ErrCode = map[ErrorCode]ErrCodeInfo{
  25. Success: ErrCodeInfo{Success, "SUCCESS"},
  26. IllegalAccess: ErrCodeInfo{IllegalAccess, "No login or illegal access"},
  27. AuthorizationExpired: ErrCodeInfo{AuthorizationExpired, "authorization expired"},
  28. ErrorInfo: ErrCodeInfo{ErrorInfo, "error message"},
  29. ParamInvalid: ErrCodeInfo{ParamInvalid, "Invalid request parameters"},
  30. ServerError: ErrCodeInfo{ServerError, "Server internal error"},
  31. NotFound: ErrCodeInfo{NotFound, "not found"},
  32. RecordNotFound: ErrCodeInfo{RecordNotFound, "record not found"},
  33. ErrorUserNameOrPassword: ErrCodeInfo{RecordNotFound, "error username or password"},
  34. SaveFailed: ErrCodeInfo{SaveFailed, "save failed"},
  35. EncryptionDataFailed: ErrCodeInfo{EncryptionDataFailed, "Encryption Data Failed"},
  36. CheckSuccess: ErrCodeInfo{EncryptionDataFailed, "check success"},
  37. CheckFail: ErrCodeInfo{EncryptionDataFailed, "check fail"},
  38. FireReqLimit: ErrCodeInfo{Code: FireReqLimit, Msg: "request times limit"},
  39. RepeatName: ErrCodeInfo{Code: RepeatName, Msg: "request param repeat name"},
  40. }