StatusCode.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package org.jeecg.common.util;
  2. public enum StatusCode {
  3. /**
  4. * 0 请求成功
  5. * -101 参数异常
  6. * -102 服务器异常
  7. * -103 数据不存在
  8. * -104 渠道不存在
  9. * -105 规则尚未配置
  10. * -106 规则为空
  11. * -107 同盾数据为空
  12. * -108 模型服务异常
  13. * -109 深度搜索服务异常
  14. * -201 探针数据为空
  15. */
  16. COMMON_SUCCESS("success", 0, true),
  17. COMMON_PARAM_ERROR("参数异常", -1, false),
  18. BYTEDANCE_VIDEO_UPLOAD_FAIL("今日头条视频文件上传失败", -201, false),
  19. IMAGE_NUMBER_SHORTAGE("今日头条图片文件上传失败", -202, false),
  20. BYTEDANCE_IMAGE_UPLOAD_FAIL("今日头条图片文件上传失败", -203, false),
  21. TEMPLATE_NAME_HAS_EXIST("模板名称已存在", -204, false),
  22. TEMPLATE_NAME_IS_NULL("模板名称为空", -205, false),
  23. COMMON_SERVER_ERROR("server error", -102, false),
  24. COMMON_DATA_HAS_EXIST_ERROR("data has exist", -103, false),
  25. COMMON_CHANNEL_NOT_EXIST_ERROR("channel not exist", -104, false),
  26. COMMON_RULEENGINE_HAS_NOT_CONFIGURED_ERROR("ruleEngine has not configured", -105, false),
  27. COMMON_RULE_PACKAGE_IS_NULL_ERROR("rulepackage is null", -106, false),
  28. COMMON_TONGDUN_DATA_IS_NULL_ERROR("tongdun data is null", -107, false),
  29. COMMON_MODEL_SERVICE_ERROR("model service error", -108, false),
  30. COMMON_DEEPSEARCH_ERROR("deep search error", -109, false),
  31. COMMON_APPLICATION_MOBILE_IS_NULL_ERROR("application mobile is null", -110, false),
  32. COMMON_TANZHEN_DATA_IS_NULL_ERROR("tanzhen data is null", -201, false),
  33. COMMON_RULE_ERROR_APPLICATION_IS_NULL("there is no error application", -202, false);
  34. private String desc;
  35. private int code;
  36. private boolean flag;
  37. StatusCode(String desc, int code, boolean flag) {
  38. this.desc = desc;
  39. this.code = code;
  40. this.flag = flag;
  41. }
  42. public static String getDesc(int code) {
  43. for (StatusCode error : StatusCode.values()) {
  44. if (error.getCode() == code) {
  45. return error.getDesc();
  46. }
  47. }
  48. return null;
  49. }
  50. public static Boolean getFlag(int code) {
  51. for (StatusCode error : StatusCode.values()) {
  52. if (error.getCode() == code) {
  53. return error.getFlag();
  54. }
  55. }
  56. return null;
  57. }
  58. public String getDesc() {
  59. return desc;
  60. }
  61. public void setDesc(String desc) {
  62. this.desc = desc;
  63. }
  64. public int getCode() {
  65. return code;
  66. }
  67. public void setCode(int code) {
  68. this.code = code;
  69. }
  70. public boolean getFlag() {
  71. return flag;
  72. }
  73. public void setFlag(boolean flag) {
  74. this.flag = flag;
  75. }
  76. }