fix: guard api key database access

This commit is contained in:
QiuSW
2026-09-12 09:30:16 +08:00
parent 158d03ae92
commit 432dcf6e60
+3
View File
@@ -20,6 +20,9 @@ type APIKey struct{ api.Api }
func (e APIKey) List(c *gin.Context) {
e.MakeContext(c)
db := primaryDB()
if db == nil {
return false
}
rows := make([]models.APIKey, 0)
if err := db.Order("id desc").Find(&rows).Error; err != nil {
e.Error(500, err, "读取密钥失败,请重试")