541469799@qq.com 8 місяців тому
батько
коміт
c40903354a

+ 2 - 1
app/index/controller/User.php

@@ -953,6 +953,7 @@ class User extends Controller
     public function pullAccessLogs()
     {
         $path = $this->request->param('path','');
+        $ip = strval($this->request->param('path','ip'));
 
         $from = $this->request->param('from');
         $to = $this->request->param('to');
@@ -975,7 +976,7 @@ class User extends Controller
             $toInt = time();
         }
 
-         $data = UserAccessLog::getAccessLog($path, $fromInt, $toInt, $page, $size);
+         $data = UserAccessLog::getAccessLog($path, $fromInt, $toInt, $page, $size, $ip);
 
         return $this->renderSuccess($data);
     }

+ 6 - 1
app/index/model/user/UserAccessLog.php

@@ -37,12 +37,17 @@ class UserAccessLog extends UserAccessLogModel
         return static::insert($data);
     }
 
-    public static function getAccessLog($path, $from, $to, $page = 1, $size = 50)
+    public static function getAccessLog($path, $from, $to, $page = 1, $size = 50, $ip = '')
     {
         $m = self::where('create_time', '>=', $from)->where('create_time', '<=', $to);
         if (!empty($path)) {
             $m = $m->where('path', $path);
         }
+
+        if (!empty($ip)) {
+            $m = $m->where('ip', $ip);
+        }
+
         $count = $m->count();
         $items = $m->page($page, $size)->select();