feat: 版本推送默认展示全部项目版本; 公告列表显示关联项目
This commit is contained in:
1 parent
c4b00cbf85
commit
5b73d0921d
6 files changed
+71
-20
No files matched your search
@@ -29,27 +29,33 @@ class AnnouncementController extends Controller
|
||||
$params = [];
|
||||
|
||||
if ($keyword !== '') {
|
||||
$where .= ' AND (title LIKE ? OR content LIKE ?)';
|
||||
$where .= ' AND (a.title LIKE ? OR a.content LIKE ?)';
|
||||
$params[] = "%{$keyword}%";
|
||||
$params[] = "%{$keyword}%";
|
||||
}
|
||||
if ($type !== '' && in_array($type, ['system', 'update', 'promo', 'notice'], true)) {
|
||||
$where .= ' AND type = ?';
|
||||
$where .= ' AND a.type = ?';
|
||||
$params[] = $type;
|
||||
}
|
||||
if ($target !== '' && in_array($target, ['all', 'admin', 'agent', 'client'], true)) {
|
||||
$where .= ' AND target = ?';
|
||||
$where .= ' AND a.target = ?';
|
||||
$params[] = $target;
|
||||
}
|
||||
if ($status !== '') {
|
||||
$where .= ' AND status = ?';
|
||||
$where .= ' AND a.status = ?';
|
||||
$params[] = (int) $status;
|
||||
}
|
||||
|
||||
$total = (int) $db->fetchColumn("SELECT COUNT(*) FROM {$db->table('announcements')} {$where}", $params);
|
||||
$total = (int) $db->fetchColumn(
|
||||
"SELECT COUNT(*) FROM {$db->table('announcements')} a {$where}",
|
||||
$params
|
||||
);
|
||||
$list = $db->fetchAll(
|
||||
"SELECT * FROM {$db->table('announcements')} {$where}
|
||||
ORDER BY is_top DESC, id DESC
|
||||
"SELECT a.*, p.name AS project_name
|
||||
FROM {$db->table('announcements')} a
|
||||
LEFT JOIN {$db->table('projects')} p ON p.id = a.project_id
|
||||
{$where}
|
||||
ORDER BY a.is_top DESC, a.id DESC
|
||||
LIMIT {$offset}, {$pageSize}",
|
||||
$params
|
||||
);
|
||||
|
||||
@@ -14,6 +14,42 @@ class ProjectVersionController extends Controller
|
||||
private const ALLOWED_EXT = ['zip', 'tar', 'gz', 'tgz', '7z', 'exe', 'dmg', 'apk', 'msi', 'pkg', 'rar', 'bin'];
|
||||
private const MAX_SIZE = 200 * 1024 * 1024; // 200MB
|
||||
|
||||
/**
|
||||
* 全部版本列表(跨项目,管理页默认展示)
|
||||
* GET /api/versions?project_id=
|
||||
*/
|
||||
public function allList(): void
|
||||
{
|
||||
$user = $this->getCurrentUser() ?: [];
|
||||
$projectId = !empty($_GET['project_id']) ? (int) $_GET['project_id'] : null;
|
||||
|
||||
$db = Database::getInstance();
|
||||
$scope = VersionService::scope($user);
|
||||
$where = $scope['where'];
|
||||
$params = $scope['params'];
|
||||
|
||||
if ($projectId) {
|
||||
$where .= ' AND v.project_id = ?';
|
||||
$params[] = $projectId;
|
||||
}
|
||||
|
||||
$list = $db->fetchAll(
|
||||
"SELECT v.*, p.name AS project_name
|
||||
FROM {$db->table('project_versions')} v
|
||||
LEFT JOIN {$db->table('projects')} p ON p.id = v.project_id
|
||||
WHERE {$where}
|
||||
ORDER BY v.id DESC",
|
||||
$params
|
||||
);
|
||||
|
||||
$list = array_map(
|
||||
static fn (array $row): array => beijingTimeFields($row, ['created_at', 'updated_at']),
|
||||
$list
|
||||
);
|
||||
|
||||
$this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本列表
|
||||
* GET /api/projects/{projectId}/versions
|
||||
|
||||
Reference in new issue
Block a user