Base.php 1.0 KB

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. private $apikey = "32a1ff74699ff2d6ce4c497cb94cb5c8";//密钥
  22. /**
  23. * 构造函数
  24. * Base constructor.
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();//继承父类构造函数
  29. $this->checkSignOpen=true;
  30. if ($this->checkSignOpen) {
  31. $checkRes=$this->checkApiSign();
  32. if($checkRes['code']!==0){
  33. //如果签名校验未通过
  34. $msg=$checkRes['msg']?$checkRes['msg']:ErrorCode::getError($checkRes['code']);
  35. $this->error($checkRes['code'],$msg);
  36. }
  37. }
  38. }
  39. }