feat(token): add batch API for fetching token keys
Add new endpoint POST /api/token/batch/keys to fetch multiple token keys in a single request, improving performance when exporting or copying multiple tokens. - Backend: Add GetTokenKeysBatch controller and GetTokenKeysByIds model - Backend: Add route with CriticalRateLimit and DisableCache middleware - Frontend: Add fetchTokenKeysBatch helper function - Frontend: Update useTokensData to use batch API for token export
This commit is contained in:
@@ -481,3 +481,11 @@ func BatchDeleteTokens(ids []int, userId int) (int, error) {
|
||||
|
||||
return len(tokens), nil
|
||||
}
|
||||
|
||||
func GetTokenKeysByIds(ids []int, userId int) ([]Token, error) {
|
||||
var tokens []Token
|
||||
err := DB.Select("id", commonKeyCol).
|
||||
Where("user_id = ? AND id IN (?)", userId, ids).
|
||||
Find(&tokens).Error
|
||||
return tokens, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user