From 949680fc450a89d14a148d39c82d10d7c1e21222 Mon Sep 17 00:00:00 2001 From: Mingcai SHEN Date: Fri, 25 Mar 2022 16:49:03 +0800 Subject: [PATCH] Updated. --- .gitignore | 1 + helper.go | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4df69a3..4d7e2ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ *.exe +sport_rec_demo diff --git a/helper.go b/helper.go index b8c3ce1..43ee5bd 100644 --- a/helper.go +++ b/helper.go @@ -6,11 +6,15 @@ import ( ) type StatusResult struct { - Code string `json:"code"` - Message string `json:"msg"` - Scene string `json:"scene,omitempty"` - SequenceId int `json:"sequenceId,omitempty"` - Timestamp int64 `json:"timestamp"` + Code string `json:"code"` + Message string `json:"msg"` + Timestamp int64 `json:"timestamp"` +} + +type StatusResultEx struct { + StatusResult + Scene string `json:"scene"` + SequenceId int `json:"sequenceId"` } func failureResponse(ctx *fiber.Ctx, code string, msg string, stat int) error { @@ -28,13 +32,14 @@ func successResponse(ctx *fiber.Ctx, msg string) error { func successResponseEx(ctx *fiber.Ctx, msg string, scene string, seq int) error { var ret = make(map[string]interface{}) - ret["status"] = StatusResult{ - Code: "0", - Message: msg, - Timestamp: time.Now().Unix(), + ret["status"] = StatusResultEx{ + StatusResult: StatusResult{ + Code: "0", + Message: msg, + Timestamp: time.Now().Unix(), + }, SequenceId: seq, Scene: scene, } - return ctx.JSON(ret) }