'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'account_id' => 'integer', 'code' => 'integer']; /** * 登录记录日志 * Author: cfn * @param array $data * @return bool */ public static function loginRecord(array $data): bool { return self::insert($data); } public static function recordLog(RequestInterface $request, mixed $admin, string $flag, mixed $response): bool { $code = 0; $content = ""; if ($response instanceof Response) { $content = $response->getBody()->getContents(); if ($body = json_decode($content, true)) { $code = $body['code'] ?? 200; } } return self::insert([ 'account_type' => $admin['account_type'], 'belong_id' => $admin['belong_id'], 'account_id' => $admin['account_id'], 'username' => $admin['username'], 'create_time' => date("Y-m-d H:i:s"), 'ua' => Ip::ua(), 'ip' => Ip::ip(), 'flag' => $flag, 'title' => Menu::getTitleByCache(strtolower($request->getMethod()), $flag, $admin['account_type']), 'method' => strtolower($request->getMethod()), 'code' => $code, 'request' => json_encode($request->all(),JSON_UNESCAPED_UNICODE), 'response' => $content ]); } }