Loading src/GlobalLog/AppOperateLogService.php +3 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ class AppOperateLogService ) { return $this->operateLogService->addOperateLog( make(RequestInterface::class)->header('hwq-request-id', ''), $this->config->get('app_name'), Auth::id() ?? 0, Auth::user()['name'] ?? '', Loading @@ -105,6 +106,7 @@ class AppOperateLogService /** * 添加系统操作日志 * * @param string $requestId 请求ID * @param string $action 方法全路径 * @param string $tableName 表名 * @param string $recordId 记录ID Loading @@ -128,6 +130,7 @@ class AppOperateLogService ) { return $this->operateLogService->addOperateLog( '', $this->config->get('app_name'), 0, 'system', Loading src/GlobalLog/Service/OperateLogService.php +8 −5 Original line number Diff line number Diff line Loading @@ -49,19 +49,19 @@ class OperateLogService } /** * 将数组转换成JSON * 生成唯一ID * * @param array $array 数组 * @return string */ public static function encodeArrayToJson(array $array): string public static function generateUniqueId(): string { return json_encode($array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); return sha1(uniqid('', true) . mt_rand(10000, 99999)); } /** * 添加操作日志 * * @param string $requestId 请求ID * @param string $appName 项目名称 * @param int $operatorId 操作人ID * @param string $operatorName 操作人名称 Loading @@ -78,6 +78,7 @@ class OperateLogService * @throws \Exception */ public function addOperateLog( string $requestId, string $appName, int $operatorId, string $operatorName, Loading @@ -93,6 +94,8 @@ class OperateLogService ): bool { $data = [ 'log_sn' => self::generateUniqueId(), 'request_id' => $requestId, 'app_name' => $appName, 'operator_id' => $operatorId, 'operator_name' => $operatorName, Loading @@ -108,6 +111,6 @@ class OperateLogService 'created_at' => date('Y-m-d H:i:s'), ]; return (bool)$this->queueService->push($this->queue, self::encodeArrayToJson($data)); return (bool)$this->queueService->push($this->queue, json_encode($data)); } } No newline at end of file src/GlobalLog/Service/RedisQueueService.php +0 −12 Original line number Diff line number Diff line Loading @@ -42,16 +42,4 @@ class RedisQueueService { return $this->redis->lPush($queue, $data); } /** * 从队列阻塞拉取 * * @param string $queue 队列名称 * @return int $timeout 超时秒数 * @throws \Exception */ public function blockPop(string $queue, int $timeout) { return $this->redis->brPop($queue, $timeout); } } No newline at end of file Loading
src/GlobalLog/AppOperateLogService.php +3 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ class AppOperateLogService ) { return $this->operateLogService->addOperateLog( make(RequestInterface::class)->header('hwq-request-id', ''), $this->config->get('app_name'), Auth::id() ?? 0, Auth::user()['name'] ?? '', Loading @@ -105,6 +106,7 @@ class AppOperateLogService /** * 添加系统操作日志 * * @param string $requestId 请求ID * @param string $action 方法全路径 * @param string $tableName 表名 * @param string $recordId 记录ID Loading @@ -128,6 +130,7 @@ class AppOperateLogService ) { return $this->operateLogService->addOperateLog( '', $this->config->get('app_name'), 0, 'system', Loading
src/GlobalLog/Service/OperateLogService.php +8 −5 Original line number Diff line number Diff line Loading @@ -49,19 +49,19 @@ class OperateLogService } /** * 将数组转换成JSON * 生成唯一ID * * @param array $array 数组 * @return string */ public static function encodeArrayToJson(array $array): string public static function generateUniqueId(): string { return json_encode($array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); return sha1(uniqid('', true) . mt_rand(10000, 99999)); } /** * 添加操作日志 * * @param string $requestId 请求ID * @param string $appName 项目名称 * @param int $operatorId 操作人ID * @param string $operatorName 操作人名称 Loading @@ -78,6 +78,7 @@ class OperateLogService * @throws \Exception */ public function addOperateLog( string $requestId, string $appName, int $operatorId, string $operatorName, Loading @@ -93,6 +94,8 @@ class OperateLogService ): bool { $data = [ 'log_sn' => self::generateUniqueId(), 'request_id' => $requestId, 'app_name' => $appName, 'operator_id' => $operatorId, 'operator_name' => $operatorName, Loading @@ -108,6 +111,6 @@ class OperateLogService 'created_at' => date('Y-m-d H:i:s'), ]; return (bool)$this->queueService->push($this->queue, self::encodeArrayToJson($data)); return (bool)$this->queueService->push($this->queue, json_encode($data)); } } No newline at end of file
src/GlobalLog/Service/RedisQueueService.php +0 −12 Original line number Diff line number Diff line Loading @@ -42,16 +42,4 @@ class RedisQueueService { return $this->redis->lPush($queue, $data); } /** * 从队列阻塞拉取 * * @param string $queue 队列名称 * @return int $timeout 超时秒数 * @throws \Exception */ public function blockPop(string $queue, int $timeout) { return $this->redis->brPop($queue, $timeout); } } No newline at end of file