Base.php 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yckj_lzj
  5. * Date: 2020-05-21
  6. * Time: 11:45
  7. */
  8. namespace app\index\controller;
  9. use app\index\ErrorCode;
  10. use think\exception\HttpResponseException;
  11. use think\exception\ValidateException;
  12. use think\facade\Log;
  13. use think\Response;
  14. /**
  15. * 控制器基类,所有控制器要继承
  16. * Class Base
  17. * @package app\index\controller
  18. */
  19. class Base extends \app\common\controller\Base
  20. {
  21. /**
  22. * 构造函数
  23. * Base constructor.
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();//继承父类构造函数
  28. $this->checkSignOpen=true;
  29. if ($this->checkSignOpen) {
  30. $checkRes=$this->checkApiSign();
  31. if($checkRes['code']!==0){
  32. //如果签名校验未通过
  33. $msg=$checkRes['msg']?$checkRes['msg']:ErrorCode::getError($checkRes['code']);
  34. $this->error($checkRes['code'],$msg);
  35. }
  36. }
  37. }
  38. }