From b7bedb8dfc8b42d25ffabcbec40ef1c8bbd47da0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 29 Dec 2024 01:20:56 +0800 Subject: [PATCH] :sparkles: Index in list destination api --- pkg/internal/models/destination.go | 1 + pkg/internal/server/api/destinations_api.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/internal/models/destination.go b/pkg/internal/models/destination.go index 040f95c..e425c14 100644 --- a/pkg/internal/models/destination.go +++ b/pkg/internal/models/destination.go @@ -6,6 +6,7 @@ const ( ) type BaseDestination struct { + ID int `json:"id,omitempty"` // Auto filled with index, only for user Type string `json:"type"` Label string `json:"label"` Region string `json:"region"` diff --git a/pkg/internal/server/api/destinations_api.go b/pkg/internal/server/api/destinations_api.go index 4c105bd..2a326f8 100644 --- a/pkg/internal/server/api/destinations_api.go +++ b/pkg/internal/server/api/destinations_api.go @@ -12,6 +12,7 @@ func listDestination(c *fiber.Ctx) error { for _, value := range services.DestinationsByIndex { var parsed models.BaseDestination _ = jsoniter.Unmarshal(value.Raw, &parsed) + parsed.ID = value.Index destinations = append(destinations, parsed) } return c.JSON(destinations)