ServiceErrorCode.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.diagbot.exception;
  2. /**
  3. * @Description: 本服务错误码
  4. * 系统码(3位) + 等级码(1位) + 4位顺序号
  5. * 系统码 通用码 000;用户中心 100; 管理中心 200;
  6. * @author: gaodm
  7. * @time: 2018/9/10 11:11
  8. */
  9. public enum ServiceErrorCode implements ErrorCode {
  10. USER_NOT_FOUND("10020000", "该账号暂未注册或已被禁用,请联系管理员"),
  11. USER_PASSWORD_ERROR("10020001", "账号或密码不正确"),
  12. GET_TOKEN_FAIL("10020002", "获取token失败"),
  13. TOKEN_IS_NOT_MATCH_USER("10020003", "请使用自己的token进行接口请求"),
  14. LONGIN_ERROE("10020012", "您的账号在其它地方已登录,您已被迫下线,请重新登录。如非本人授权,登录后请及时修改密码。"),
  15. USER_POWER_UP("10020012", "您的权限已被管理员修改,您已被迫下线,请重新登录。"),
  16. LONGIN_TOKEN_ERROE("10020013", "登录异常"),
  17. SMS_SEND_ERROR("10020004", "短信发送错误"),
  18. USER_BIND_ERROR("10020005", "用户手机号已经绑定无需再次验证"),
  19. USER_UN_BIND_ERROR("10020006", "用户手机号未绑定无需解绑"),
  20. VERIFYCODE_ERROR("10020007", "图片验证码生成错误"),
  21. USER_EXIST("10020008", "该账号已注册"),
  22. EMAIL_IS_NULL("10020009", "请输入邮箱");
  23. private String code;
  24. private String msg;
  25. ServiceErrorCode(String code, String msg) {
  26. this.code = code;
  27. this.msg = msg;
  28. }
  29. public String getCode() {
  30. return code;
  31. }
  32. public String getMsg() {
  33. return msg;
  34. }
  35. public static ServiceErrorCode codeOf(String code) {
  36. for (ServiceErrorCode state : values()) {
  37. if (state.getCode() == code) {
  38. return state;
  39. }
  40. }
  41. return null;
  42. }
  43. }