CommonErrorCode.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.diagbot.exception;
  2. /**
  3. * @Description: 通用错误码
  4. * 系统码(3位) + 等级码(1位) + 4位顺序号
  5. * 系统码 通用码 000;用户中心 100; 管理中心 200;
  6. * @author: gaodm
  7. * @time: 2018/8/1 14:56
  8. */
  9. public enum CommonErrorCode implements ErrorCode {
  10. OK("0", "操作成功"),
  11. FAIL("-1", "操作失败"),
  12. RPC_ERROR("-2","远程调度失败"),
  13. NOT_EXISTS ("00020001", "该数据不存在!"),
  14. INSERT_DATA_FAILED("00020002", "数据库写入失败!"),
  15. UPDATE_INFO_FAIL("00020003", "更新数据失败!"),
  16. PARAM_IS_NULL("00020004", "传入的参数为空!"),
  17. PARAM_IS_ERROR("00020005", "传入的参数为错误!"),
  18. STATUS_IS_ERROR("00020006", "参数状态错误!");
  19. private String code;
  20. private String msg;
  21. CommonErrorCode(String code, String msg) {
  22. this.code = code;
  23. this.msg = msg;
  24. }
  25. public String getCode() {
  26. return code;
  27. }
  28. public String getMsg() {
  29. return msg;
  30. }
  31. public static CommonErrorCode codeOf(String code) {
  32. for (CommonErrorCode state : values()) {
  33. if (state.getCode() == code) {
  34. return state;
  35. }
  36. }
  37. return null;
  38. }
  39. }