Base.php 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. 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. }