Initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\data\Logs as DataLogs;
|
||||
use app\common\traits\ServiceTrait;
|
||||
use think\Log;
|
||||
|
||||
class DataLogService
|
||||
{
|
||||
use ServiceTrait;
|
||||
|
||||
/** @var DataLogs */
|
||||
public static $Model = DataLogs::class;
|
||||
|
||||
/**
|
||||
* @param $table
|
||||
* @param $log_table
|
||||
* @param $log_table_id
|
||||
* @param $before_data
|
||||
* @param $after_data
|
||||
* @param string $remark
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function addLog($table, $log_table, $log_table_id, $before_data, $after_data, string $remark = '')
|
||||
{
|
||||
$data = [
|
||||
'table' => $table,
|
||||
'log_table' => $log_table,
|
||||
'log_table_id' => $log_table_id,
|
||||
'before_data' => $before_data,
|
||||
'after_data' => $after_data,
|
||||
'remark' => $remark,
|
||||
];
|
||||
|
||||
$res = self::create($data);
|
||||
if (!$res) {
|
||||
Log::info(__CLASS__ . ' 写入数据变动日志失败:' . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
exception('写入数据变动日志失败');
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user