feat(admin): add admin endpoint to list user devices with JPush registration IDs
All checks were successful
Build Backend / build (push) Successful in 2m32s
Build Backend / build-docker (push) Successful in 6m22s

- Add AdminDeviceTokenResponse DTO including push_token (RegistrationID) for push debugging
- Add DeviceTokenToAdminResponse and DeviceTokensToAdminResponse converters
- Inject PushService into AdminUserHandler for retrieving user devices
- Register GET /api/v1/admin/users/:id/devices route for querying target user's device tokens
This commit is contained in:
lafay
2026-06-18 20:07:24 +08:00
parent 821e066446
commit cb85c62093
10 changed files with 116 additions and 23 deletions

View File

@@ -199,3 +199,34 @@ func DeviceTokensToResponse(tokens []*model.DeviceToken) []*DeviceTokenResponse
}
return result
}
// DeviceTokenToAdminResponse 将DeviceToken转换为管理端响应含 registration_id
func DeviceTokenToAdminResponse(token *model.DeviceToken) *AdminDeviceTokenResponse {
if token == nil {
return nil
}
resp := &AdminDeviceTokenResponse{
ID: token.ID,
UserID: token.UserID,
DeviceID: token.DeviceID,
DeviceType: string(token.DeviceType),
PushToken: token.PushToken,
IsActive: token.IsActive,
DeviceName: token.DeviceName,
CreatedAt: token.CreatedAt,
UpdatedAt: token.UpdatedAt,
}
if token.LastUsedAt != nil {
resp.LastUsedAt = *token.LastUsedAt
}
return resp
}
// DeviceTokensToAdminResponse 将DeviceToken列表转换为管理端响应列表
func DeviceTokensToAdminResponse(tokens []*model.DeviceToken) []*AdminDeviceTokenResponse {
result := make([]*AdminDeviceTokenResponse, 0, len(tokens))
for _, token := range tokens {
result = append(result, DeviceTokenToAdminResponse(token))
}
return result
}