LoginEnum.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace common\enums;
  3. /**
  4. *
  5. * Class LoginEnum
  6. * @package common\enums
  7. * @author qimall
  8. */
  9. class LoginEnum extends BaseEnum
  10. {
  11. const AUTHORIZED_LOGIN = -1000;
  12. const AUTHORIZED_MOBILE = -1001;
  13. /**
  14. * @return array
  15. */
  16. public static function getMap(): array
  17. {
  18. return [];
  19. }
  20. public static function getReplaceMap(): array
  21. {
  22. return [
  23. 'Your request was made with invalid credentials.' => '请登录'
  24. ];
  25. }
  26. public static function getMessageMap(): array
  27. {
  28. return [
  29. self::AUTHORIZED_LOGIN =>[
  30. '用户访问令牌已过期,请重新登录获取',
  31. '此openid未授权,请重新授权',
  32. 'Your request was made with invalid credentials.'
  33. ],
  34. self::AUTHORIZED_MOBILE => [
  35. '此用户未授权手机号码',
  36. ]
  37. ];
  38. }
  39. public static function checkMessage($message){
  40. $messages = self::getMessageMap();
  41. $code = '';
  42. foreach ($messages as $k => $message_arr){
  43. if(in_array($message,$message_arr)){
  44. $code = $k;
  45. break;
  46. }
  47. }
  48. return $code;
  49. }
  50. }