BaseMiddleware.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\http\middleware;
  12. use app\Request;
  13. use crmeb\interfaces\MiddlewareInterface;
  14. /**
  15. * Class BaseMiddleware
  16. * @package app\api\middleware
  17. */
  18. class BaseMiddleware implements MiddlewareInterface
  19. {
  20. /**
  21. * @param Request $request
  22. * @param \Closure $next
  23. * @param bool $force
  24. * @return mixed
  25. * @author 吴汐
  26. * @email 442384644@qq.com
  27. * @date 2023/04/07
  28. */
  29. public function handle(Request $request, \Closure $next, bool $force = true)
  30. {
  31. if (!$request->hasMacro('uid')) {
  32. $request->macro('uid', function(){ return 0; });
  33. }
  34. if (!$request->hasMacro('adminId')) {
  35. $request->macro('adminId', function(){ return 0; });
  36. }
  37. if (!$request->hasMacro('kefuId')) {
  38. $request->macro('kefuId', function(){ return 0; });
  39. }
  40. return $next($request);
  41. }
  42. }