From 0069a9387faa22fcef5a710c85453ed605de1084 Mon Sep 17 00:00:00 2001 From: royeecai Date: Mon, 26 Apr 2021 13:19:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AD=E9=97=B4=E4=BB=B6?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E8=AE=B0=E5=BD=95=E6=93=8D=E4=BD=9C=E9=81=87?= =?UTF-8?q?=E5=88=B0=E9=94=99=E8=AF=AF=EF=BC=8C=E6=B2=A1=E6=9C=89=E5=9B=9E?= =?UTF-8?q?=E6=BB=9A=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/SystemLogService.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/admin/service/SystemLogService.php b/app/admin/service/SystemLogService.php index 1c788a9..7dce1dc 100644 --- a/app/admin/service/SystemLogService.php +++ b/app/admin/service/SystemLogService.php @@ -13,6 +13,7 @@ namespace app\admin\service; +use app\common\traits\JumpTrait; use think\facade\Db; use think\facade\Config; @@ -23,7 +24,7 @@ use think\facade\Config; */ class SystemLogService { - + use JumpTrait; /** * 当前实例 * @var object @@ -86,7 +87,9 @@ class SystemLogService Db::table($this->tableName)->insert($data); Db::commit(); } catch (\Exception $e) { - return $e->getMessage(); + Db::rollback(); + //返回错误抛出异常 + $this->error($e->getMessage()); } return true; } @@ -125,7 +128,7 @@ CREATE TABLE `{$this->tableName}` ( `title` varchar(100) DEFAULT '' COMMENT '日志标题', `content` text NOT NULL COMMENT '内容', `ip` varchar(50) NOT NULL DEFAULT '' COMMENT 'IP', - `useragent` varchar(255) DEFAULT '' COMMENT 'User-Agent', + `useragent` text null COMMENT 'User-Agent', `create_time` int(10) DEFAULT NULL COMMENT '操作时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=630 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='后台操作日志表 - {$this->tableSuffix}'; -- Gitee