From 2b1565b3bab1de52cd1c22a9197ae78d4ded093c Mon Sep 17 00:00:00 2001 From: Webster Zhang Date: Sun, 21 May 2023 11:47:41 +0800 Subject: [PATCH] Add mock data when debug switch is on and empty result --- gin/services/queue.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gin/services/queue.go b/gin/services/queue.go index ce15bff..e85be76 100644 --- a/gin/services/queue.go +++ b/gin/services/queue.go @@ -7,6 +7,7 @@ import ( goredis "github.com/redis/go-redis/v9" "log" "math" + "vatprc-queue/config" "vatprc-queue/redis" ) @@ -47,6 +48,12 @@ func GetQueueResult(airport string, withExtra bool) []QueueResult { Extra: extra, } } + + if config.File.Section("app").Key("debug").MustBool(false) && len(result) == 0 { + result = append(result, QueueResult{Status: 1, Callsign: "DEBUG1", Extra: &QueueExtra{Cid: "1", Departure: "TEST", Arrival: "TEST"}}) + result = append(result, QueueResult{Status: 1, Callsign: "DEBUG2", Extra: &QueueExtra{Cid: "2", Departure: "TEST", Arrival: "TEST"}}) + result = append(result, QueueResult{Status: 1, Callsign: "DEBUG3", Extra: &QueueExtra{Cid: "3", Departure: "TEST", Arrival: "TEST"}}) + } return result }