Browse Source

增加通用函数

master
xyiege 1 year ago
parent
commit
210f8449fc
  1. 14
      app/common.php

14
app/common.php

@ -2,6 +2,7 @@
// 应用公共文件
use app\common\service\AuthService;
use cores\exception\BaseException;
use think\facade\Cache;
if (!function_exists('__url')) {
@ -121,4 +122,17 @@ if (!function_exists('auth')) {
return $check;
}
}
/**
* 输出错误信息
* @param string $message 报错信息
* @param int|null $status 状态码,默认为配置文件status.error
* @param array $data 附加数据
* @throws BaseException
*/
function throwError(string $message, ?int $status = null, array $data = [])
{
is_null($status) && $status = config('status.error');
throw new BaseException(['status' => $status, 'message' => $message, 'data' => $data]);
}
Loading…
Cancel
Save