ResponseCodeEnum.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Jiannei/lumen-api-starter.
  4. *
  5. * (c) Jiannei <longjian.huang@foxmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace App\Repositories\Enums;
  11. use Jiannei\Enum\Laravel\Repositories\Enums\HttpStatusCodeEnum;
  12. class ResponseCodeEnum extends HttpStatusCodeEnum
  13. {
  14. // 业务操作正确码:1xx、2xx、3xx 开头,后拼接 3 位
  15. // 200 + 001 => 200001,也就是有 001 ~ 999 个编号可以用来表示业务成功的情况,当然你可以根据实际需求继续增加位数,但必须要求是 200 开头
  16. // 举个栗子:你可以定义 001 ~ 099 表示系统状态;100 ~ 199 表示授权业务;200 ~ 299 表示用户业务...
  17. const SERVICE_REGISTER_SUCCESS = 200101;
  18. const SERVICE_LOGIN_SUCCESS = 200102;
  19. //没有绑定手机号
  20. const SERVICE_NO_WECHAT = 200201;
  21. // 客户端错误码:400 ~ 499 开头,后拼接 3 位
  22. const CLIENT_PARAMETER_ERROR = 400001;
  23. const CLIENT_CREATED_ERROR = 400002;
  24. const CLIENT_DELETED_ERROR = 400003;
  25. const CLIENT_VALIDATION_ERROR = 422001; // 表单验证错误
  26. // 服务端操作错误码:500 ~ 599 开头,后拼接 3 位
  27. const SYSTEM_ERROR = 500001;
  28. const SYSTEM_UNAVAILABLE = 500002;
  29. const SYSTEM_CACHE_CONFIG_ERROR = 500003;
  30. const SYSTEM_CACHE_MISSED_ERROR = 500004;
  31. const SYSTEM_CONFIG_ERROR = 500005;
  32. // 业务操作错误码(外部服务或内部服务调用...)
  33. const SERVICE_REGISTER_ERROR = 500101;
  34. const SERVICE_LOGIN_ERROR = 500102;
  35. //没有权限
  36. const SERVICE_NO_PERMISSION = 500103;
  37. //业务错误
  38. // const SERVICE_OPERATION_ERROR = 500104;
  39. const SERVICE_OPERATION_ERROR = 501;
  40. }