作者 赵彬吉

update

... ... @@ -69,13 +69,11 @@ class EmailController extends BaseController
public function set_smtp(Smtp $smtp)
{
$this->request->validate([
'project_id' => ['required'],
'email' => ['required', 'email', 'max:200'],
'password' => ['required', 'max:200'],
'host' => ['required', 'max:200', 'regex:/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/'],
'from_name' => ['required', 'max:200'],
], [
'project_id.required' => '参数异常',
'email.required' => '邮箱必须',
'email.email' => '邮箱格式错误',
'password.required' => '授权码/密码必须',
... ... @@ -83,7 +81,7 @@ class EmailController extends BaseController
'host.regex' => 'smtp格式错误',
'from_name.required' => '发信人昵称必须',
]);
$info = $smtp->read(['project_id' => $this->param['project_id']]);
$info = $smtp->read(['project_id' => $this->project['id']]);
if (!$info) {
$smtp->add($this->param);
} else {
... ... @@ -93,7 +91,7 @@ class EmailController extends BaseController
}
public function get_smtp(Smtp $smtp){
$info = $smtp->read(['project_id' => $this->param['project_id']]);
$info = $smtp->read(['project_id' => $this->project['id']]);
$this->response($info);
}
... ...
... ... @@ -53,33 +53,6 @@ class QueryListener
$log = $log.' [ RunTime:'.$event->time.'ms ] ';
Log::debug($log);
}
//监听api_no是TM咋个被改的
if (Str::contains($event->sql, 'update') && Str::contains($event->sql, '`api_no` =')) {
//记录debug 根据这个溯源
$trace = debug_backtrace();
$traces = [];
foreach ($trace as $index => $caller) {
if ($index === 0) {
continue; // 跳过当前方法的调用信息
}
$file = $caller['file'];
$line = $caller['line'];
$class = $caller['class'];
$method = $caller['function'];
$traces[] = "Method $method called from $class in file $file at line $line\n";
}
//用户信息 哪个改的 还是脚本跑的
$token = request()->header('token');
Log::channel('test')->info('api_no updated', [
'sql' => $event->sql,
'bindings' => $event->bindings,
'route' => Route::current(),
'request' => request()->all(),
'a_info' => Cache::get(Common::MANAGE_TOKEN . $token),
'b_info' => Cache::get($token),
'trace' => $traces
]);
}
}catch (\Exception $exception){
Log::error('log sql error:'.$exception->getMessage());
}
... ...