From 7c8e509c95c2af0c0d076b13fbbc5aa63a06cb69 Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Sat, 07 Nov 2026 19:35:38 +0800
Subject: [PATCH] chore: 删除无用的测试工具及相关文件

---
 server/handlers/games.go |   41 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/server/handlers/games.go b/server/handlers/games.go
index 6b0f3d4..e2fabf5 100644
--- a/server/handlers/games.go
+++ b/server/handlers/games.go
@@ -3,6 +3,7 @@
 import (
 	"net/http"
 	"strconv"
+	"strings"
 	"time"
 
 	"gamebox-server/config"
@@ -101,6 +102,33 @@
 	c.JSON(http.StatusOK, gin.H{"code": 0, "data": tools})
 }
 
+// ToolDownloadInfo 工具下载信息(无需会员校验,返回格式与游戏下载一致)
+func ToolDownloadInfo(c *gin.Context) {
+	var tool models.Tool
+	if err := config.DB.First(&tool, c.Param("id")).Error; err != nil {
+		c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "工具不存在"})
+		return
+	}
+	if tool.FileURL == "" {
+		c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "该工具暂无下载文件,请联系管理员上传"})
+		return
+	}
+	// 压缩包文件名取 URL 最后一段
+	fileName := tool.FileURL
+	if idx := strings.LastIndex(tool.FileURL, "/"); idx >= 0 && idx < len(tool.FileURL)-1 {
+		fileName = tool.FileURL[idx+1:]
+	}
+	if q := strings.Index(fileName, "?"); q > 0 {
+		fileName = fileName[:q]
+	}
+	files := []gin.H{{"name": fileName, "url": tool.FileURL, "size": tool.Size}}
+	c.JSON(http.StatusOK, gin.H{"code": 0, "data": gin.H{
+		"name":       tool.Name,
+		"files":      files,
+		"launch_exe": tool.LaunchExe,
+	}})
+}
+
 // GetAnnouncements 公告
 func GetAnnouncements(c *gin.Context) {
 	var anns []models.Announcement
@@ -200,11 +228,18 @@
 		c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "游戏不存在"})
 		return
 	}
-	// 校验会员是否有效(永久卡 expired_at 为 NULL)
+	// 校验会员是否有效(永久卡 expired_at 为 NULL;冻结的密钥视为无效)
 	var keys []models.MemberKey
-	config.DB.Where("user_id = ? AND (expired_at IS NULL OR expired_at > ?)", userID, time.Now()).Find(&keys)
+	config.DB.Where("user_id = ? AND frozen = ? AND (expired_at IS NULL OR expired_at > ?)", userID, false, time.Now()).Find(&keys)
 	if len(keys) == 0 {
-		c.JSON(http.StatusOK, gin.H{"code": 2, "msg": "您的会员已到期,无法下载游戏。请激活新的会员密钥!"})
+		// 用户绑定的密钥被冻结时给出精确提示
+		var frozenCount int64
+		config.DB.Model(&models.MemberKey{}).Where("user_id = ? AND frozen = ?", userID, true).Count(&frozenCount)
+		if frozenCount > 0 {
+			c.JSON(http.StatusOK, gin.H{"code": 2, "msg": "您的密钥已被冻结,无法下载,请联系管理员激活密钥!"})
+		} else {
+			c.JSON(http.StatusOK, gin.H{"code": 2, "msg": "您的会员已到期,无法下载游戏。请激活新的会员密钥!"})
+		}
 		return
 	}
 	// 加入资源库 & 下载计数

--
Gitblit v1.10.0