From 79a71573904b7a52e6c4f2ae395d64e15c10f294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 24 Oct 2022 21:24:35 +0800 Subject: [PATCH] 1 --- controllers/tiktok_store.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/controllers/tiktok_store.go b/controllers/tiktok_store.go index df4a3c287..ff1cf7626 100644 --- a/controllers/tiktok_store.go +++ b/controllers/tiktok_store.go @@ -56,6 +56,17 @@ func PKCS5UnPadding(origData []byte) []byte { return origData[:(length - unfilledNum)] } +type Code struct { + MsgType int64 `json:"msg_type"` + msg struct { + ActionType int64 `json:"action_type"` + AppId int64 `json:"app_id"` + ShopId int64 `json:"shop_id"` + Code string `json:"code"` + CodeGenerateTime string `json:"code_generate_time"` + } +} + func (c *TiktokShopController) TokenMsg() { req := c.Ctx.Request var code []string @@ -77,11 +88,16 @@ func (c *TiktokShopController) TokenMsg() { case http.MethodGet: codeValues := req.URL.Query() codeList := codeValues.Get("code") - if err := json.Unmarshal([]byte(string(codeList)), &code); err != nil { + + codeResult := make([]Code, 0, 0) + if err := json.Unmarshal([]byte(string(codeList)), &codeResult); err != nil { c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail} c.ServeJSON() return } + for _, v := range codeResult { + code = append(code, v.msg.Code) + } } globals.SugarLogger.Debugf("code ==================%s", utils.Format4Output(code, false))