v1.1.1: 安装统计时间统一为北京时间(UTC+8)
- MySQL 默认时区 +08:00, PHP Asia/Shanghai - 历史安装时间 UTC→+8 转换 - 安装/版本接口与页面按北京时间展示
This commit is contained in:
1 parent
e809b7a903
commit
d4ed9c3dcf
10 files changed
+118
-19
No files matched your search
@@ -50,6 +50,9 @@ class InstallationController extends Controller
|
||||
$params
|
||||
);
|
||||
|
||||
$timeFields = ['installed_at', 'last_online_at', 'deleted_at', 'created_at', 'updated_at'];
|
||||
$list = array_map(static fn (array $row): array => beijingTimeFields($row, $timeFields), $list);
|
||||
|
||||
$this->success([
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
@@ -67,7 +70,15 @@ class InstallationController extends Controller
|
||||
$user = $this->getCurrentUser() ?: [];
|
||||
$projectId = !empty($_GET['project_id']) ? (int) $_GET['project_id'] : null;
|
||||
|
||||
$this->success(InstallationService::stats($user, $projectId));
|
||||
$stats = InstallationService::stats($user, $projectId);
|
||||
$stats['last_online_at'] = beijingTime($stats['last_online_at'] ?? null);
|
||||
if (!empty($stats['projects']) && is_array($stats['projects'])) {
|
||||
foreach ($stats['projects'] as $i => $row) {
|
||||
$stats['projects'][$i] = beijingTimeFields($row, ['last_online_at']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->success($stats);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +105,7 @@ class InstallationController extends Controller
|
||||
$this->error('无权访问该安装记录', 403);
|
||||
}
|
||||
|
||||
$row = beijingTimeFields($row, ['installed_at', 'last_online_at', 'deleted_at', 'created_at', 'updated_at']);
|
||||
$this->success($row);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ class ProjectVersionController extends Controller
|
||||
[$projectId]
|
||||
);
|
||||
|
||||
$list = array_map(
|
||||
static fn (array $row): array => beijingTimeFields($row, ['created_at', 'updated_at']),
|
||||
$list
|
||||
);
|
||||
|
||||
$this->success($list);
|
||||
}
|
||||
|
||||
@@ -61,6 +66,7 @@ class ProjectVersionController extends Controller
|
||||
$this->error('版本不存在', 404);
|
||||
}
|
||||
|
||||
$row = beijingTimeFields($row, ['created_at', 'updated_at']);
|
||||
$this->success($row);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user