<?php /** * Created by PhpStorm. * User: yckj_lzj * Date: 2020-05-21 * Time: 11:45 */ namespace app\index\controller; use app\index\ErrorCode; use think\exception\HttpResponseException; use think\exception\ValidateException; use think\facade\Log; use think\Response; /** * 控制器基类,所有控制器要继承 * Class Base * @package app\index\controller */ class Base extends \app\common\controller\Base { private $apikey = "32a1ff74699ff2d6ce4c497cb94cb5c8";//密钥 protected $checkSignOpen = true;//是否校验签名,true校验,false不校验 /** * 构造函数 * Base constructor. */ public function __construct() { parent::__construct();//继承父类构造函数 if ($this->checkSignOpen) { $checkRes=$this->checkApiSign(); if($checkRes['code']!==0){ //如果签名校验未通过 $msg=$checkRes['msg']?$checkRes['msg']:ErrorCode::getError($checkRes['code']); $this->error($checkRes['code'],$msg); } } } }