diff --git a/README.md b/README.md index 4fb4b0a..856815e 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ php -S localhost:8000 "endpoints": { "/api?action=list": "获取应用列表,支持search、platform、age_rating、tag、page、limit参数。search:搜索关键词;platform:平台;age_rating:年龄分级;tag:标签;page:页码;limit:每页数量", "/api?action=app&id=1": "获取指定ID的应用详情,需传入app_id参数。包含应用基础信息、版本、图片、评价和标签信息", - "/api?action=favorite": "收藏应用(POST方法,需app_id和user_id参数)" + }, "example": "GET /api?action=list&search=游戏&limit=10" } diff --git a/api.php b/api.php index 353d3a5..2b64e76 100644 --- a/api.php +++ b/api.php @@ -15,7 +15,7 @@ if (!isset($_GET['action']) || $_GET['action'] === '') { 'endpoints' => [ '/api?action=list' => '获取应用列表,支持search、platform、age_rating、tag、page、limit参数。search:搜索关键词;platform:平台;age_rating:年龄分级;tag:标签;page:页码;limit:每页数量', '/api?action=app&id=1' => '获取指定ID的应用详情,需传入app_id参数。包含应用基础信息、版本、图片、评价和标签信息', - '/api?action=favorite' => '收藏应用(POST方法,需app_id和user_id参数)' + ], 'example' => 'GET /api?action=list&search=游戏&limit=10' ]); @@ -218,42 +218,6 @@ if (isset($_GET['action'])) { exit; } - // 处理用户收藏应用 - elseif ($action === 'favorite' && isset($_GET['app_id']) && is_numeric($_GET['app_id']) && isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $requestMethod === 'POST') { - $appId = $_GET['app_id']; - $userId = $_GET['user_id']; - - $stmt = $conn->prepare("INSERT IGNORE INTO user_favorites (user_id, app_id) VALUES (?, ?)"); - $stmt->bind_param("ii", $userId, $appId); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'App added to favorites']); - } else { - http_response_code(500); - echo json_encode(['error' => 'Failed to add to favorites']); - } - $stmt->close(); - exit; - } - - // 获取用户收藏列表 - elseif ($action === 'favorites' && isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $requestMethod === 'GET') { - $userId = $_GET['user_id']; - - $sql = "SELECT apps.* FROM user_favorites JOIN apps ON user_favorites.app_id = apps.id WHERE user_favorites.user_id = $userId"; - $result = $conn->query($sql); - - $favorites = []; - if ($result->num_rows > 0) { - while ($row = $result->fetch_assoc()) { - $favorites[] = $row; - } - } - - echo json_encode($favorites); - exit; - } - // 获取所有标签 elseif ($action === 'tags' && $requestMethod === 'GET') { $sql = "SELECT id, name FROM tags ORDER BY name"; diff --git a/app_store.sql b/app_store.sql index 30e8755..9f0c647 100644 --- a/app_store.sql +++ b/app_store.sql @@ -160,16 +160,7 @@ CREATE TABLE IF NOT EXISTS download_history ( FOREIGN KEY (version_id) REFERENCES app_versions(id) ON DELETE CASCADE ); --- 创建用户收藏表 -CREATE TABLE IF NOT EXISTS user_favorites ( - id INT AUTO_INCREMENT PRIMARY KEY, - user_id INT NOT NULL, - app_id INT NOT NULL, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY unique_favorite (user_id, app_id), - FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE -); + -- 创建公告表 CREATE TABLE IF NOT EXISTS announcements ( diff --git a/developer_apps.php b/developer_apps.php index 15917d7..8bde11a 100644 --- a/developer_apps.php +++ b/developer_apps.php @@ -189,7 +189,7 @@ $resultApps = $conn->query($sqlApps);

查看详情 - + diff --git a/index.php b/index.php index cc90e7e..1b67ac1 100644 --- a/index.php +++ b/index.php @@ -309,7 +309,7 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno echo '

平台: '. implode(', ', $platforms) . '

'; echo '

评分: '. round($row['avg_rating'] ?? 0, 1) . '/5

'; echo '查看详情'; - echo ''; + echo ''; } } else { diff --git a/remove_favorite_feature.sql b/remove_favorite_feature.sql new file mode 100644 index 0000000..1c3280d --- /dev/null +++ b/remove_favorite_feature.sql @@ -0,0 +1,2 @@ +-- 删除收藏功能相关表 +DROP TABLE IF EXISTS user_favorites; \ No newline at end of file diff --git a/version_list.php b/version_list.php index 4131a78..fd6547a 100644 --- a/version_list.php +++ b/version_list.php @@ -139,7 +139,7 @@ while ($row = $result->fetch_assoc()) {
版本
发布日期:

- + - - +