🐛 Fix preloading issue

This commit is contained in:
LittleSheep 2024-08-26 00:33:57 +08:00
parent 1bdeba58bc
commit 51a53a25da
2 changed files with 6 additions and 5 deletions

6
.idea/workspace.xml generated
View File

@ -4,7 +4,7 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix api key missing account id"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Preload api key's ticket">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/bot_token_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/bot_token_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/bot_token_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/bot_token_api.go" afterDir="false" />
</list> </list>
@ -153,7 +153,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":arrow_up: Upgrade dealer" />
<MESSAGE value=":sparkles: Support stream controller event emit" /> <MESSAGE value=":sparkles: Support stream controller event emit" />
<MESSAGE value=":recycle: Use dealer postman instead of built-in feature to deliver email and notify" /> <MESSAGE value=":recycle: Use dealer postman instead of built-in feature to deliver email and notify" />
<MESSAGE value=":bug: Fix push notification to wrong person" /> <MESSAGE value=":bug: Fix push notification to wrong person" />
@ -178,7 +177,8 @@
<MESSAGE value=":bug: Fix path parameters misplaced" /> <MESSAGE value=":bug: Fix path parameters misplaced" />
<MESSAGE value=":bug: Fix api key wasn't in auto maintain range" /> <MESSAGE value=":bug: Fix api key wasn't in auto maintain range" />
<MESSAGE value=":bug: Fix api key missing account id" /> <MESSAGE value=":bug: Fix api key missing account id" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix api key missing account id" /> <MESSAGE value=":sparkles: Preload api key's ticket" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Preload api key's ticket" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -7,6 +7,7 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts" "git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services" "git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"gorm.io/gorm"
) )
func listBotKeys(c *fiber.Ctx) error { func listBotKeys(c *fiber.Ctx) error {
@ -15,7 +16,7 @@ func listBotKeys(c *fiber.Ctx) error {
} }
user := c.Locals("user").(models.Account) user := c.Locals("user").(models.Account)
tx := database.C.Preload("Ticket") var tx *gorm.DB
botId, _ := c.ParamsInt("botId", 0) botId, _ := c.ParamsInt("botId", 0)
if botId > 0 { if botId > 0 {
@ -35,7 +36,7 @@ func listBotKeys(c *fiber.Ctx) error {
} }
var keys []models.ApiKey var keys []models.ApiKey
if err := tx.Find(&keys).Error; err != nil { if err := tx.Preload("Ticket").Find(&keys).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }