|
@@ -19,6 +19,7 @@ if (!function_exists('fail')) {
|
|
|
'msg' => is_array($message) ? json_encode($message) : $message,
|
|
|
];
|
|
|
|
|
|
+ request_log_update($result);
|
|
|
// 如果未设置类型则自动判断
|
|
|
$type = 'json';
|
|
|
$response = \think\Response::create($result, $type, 200);
|
|
@@ -39,6 +40,7 @@ if (!function_exists('succ')) {
|
|
|
'msg' => $message,
|
|
|
];
|
|
|
|
|
|
+ request_log_update($result);
|
|
|
// 如果未设置类型则自动判断
|
|
|
$type = 'json';
|
|
|
$response = \think\Response::create($result, $type, 200);
|
|
@@ -291,4 +293,21 @@ if (!function_exists('generate_no')) {
|
|
|
$milliseconds = round(($u_timestamp - $timestamp) * 100); // 改这里的数值控制毫秒位数
|
|
|
return $pre . $date . date(preg_replace('`(?<!\\\\)u`', $milliseconds, 'u'), $timestamp);
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+function request_log_update($log_result){
|
|
|
+
|
|
|
+ /*if ($this->logType === 1){
|
|
|
+ if (strlen(json_encode($log_result['data'])) > 1000) {
|
|
|
+ $log_result['data'] = '数据太多,不记录';
|
|
|
+ }
|
|
|
+ LogUtil::info('result', 'Api-Middleware-Log', 'request_log', $log_result);
|
|
|
+ }else{*/
|
|
|
+ if(defined('API_REQUEST_ID')) { //记录app正常返回结果
|
|
|
+ if(strlen(json_encode($log_result['data'])) > 1000) {
|
|
|
+ $log_result['data'] = '数据太多,不记录';
|
|
|
+ }
|
|
|
+ db('api_request_log')->where('id',API_REQUEST_ID)->update(['result'=>json_encode($log_result)]);
|
|
|
+ }
|
|
|
+ /*}*/
|
|
|
}
|