This commit is contained in:
2025-11-18 09:37:05 +08:00
parent 61b2ccf106
commit a3e5568f93
27 changed files with 1055 additions and 46 deletions

View File

@@ -5,17 +5,15 @@ use app\exception\MyBusinessException;
use support\exception\BusinessException;
class ApiController
{
protected static $token = 'kiy7s194DXKSpP8CJtRpnYn5r5HrHQTf';
public function __construct()
{
$request = request();
$get_token = $request->header('token');
// 基类
if(empty($get_token)) {
throw new MyBusinessException('参数错误', 500);
}
if($get_token != self::$token) {
throw new MyBusinessException('参数错误', 500);
}
}
public function success($data = [])
{
return json(['code' => 1, 'msg' => 'success', 'data' => $data]);
}
public function error($msg = 'fail')
{
return json(['code' => 0, 'msg' => $msg]);
}
}