Parcourir la source

fix(log): 修改API日志删除命令的保留天数和时间格式

- 将日志保留天数从10天改为7天
- 将时间格式从 Y-m-d H:i:s 改为 Y-m-d
- 修正数据库查询的时间条件格式
shichen il y a 4 mois
Parent
commit
e424866271
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      app/command/DeleteApiLog.php

+ 2 - 2
app/command/DeleteApiLog.php

@@ -12,7 +12,7 @@ use think\facade\Db;
12 12
 class DeleteApiLog extends Command
13 13
 {
14 14
     // 上级
15
-    const DAY = 10;
15
+    const DAY = 7;
16 16
 
17 17
     protected function configure()
18 18
     {
@@ -33,7 +33,7 @@ class DeleteApiLog extends Command
33 33
     private function delete()
34 34
     {
35 35
         $time = time() - self::DAY * 24 * 60 * 60;
36
-        $time = date('Y-m-d H:i:s', $time);
36
+        $time = date('Y-m-d', $time);
37 37
         Db::name('api_request_log')->where('create_time', '<', $time)->limit(1000)->delete();
38 38
     }
39 39