Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2022-10-24 19:33:48 +08:00

View File

@@ -9,6 +9,8 @@ import (
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego/server/web" "github.com/astaxie/beego/server/web"
"io/ioutil"
"net/http"
"time" "time"
) )
@@ -17,20 +19,39 @@ type TiktokShopController struct {
} }
func (c *TiktokShopController) TokenMsg() { func (c *TiktokShopController) TokenMsg() {
codeValues := c.Ctx.Request.URL.Query() req := c.Ctx.Request
globals.SugarLogger.Debugf("codeValues=====%s", utils.Format4Output(codeValues, false))
codeList := codeValues.Get("code")
globals.SugarLogger.Debugf("codeList=====%s", utils.Format4Output(codeList, false))
globals.SugarLogger.Debugf("codeValues.Get(\"code\")%s", utils.Format4Output(codeValues.Get("Code"), false))
var code []string var code []string
if err := json.Unmarshal([]byte(string(codeList)), &code); err != nil { switch req.Method {
globals.SugarLogger.Debugf("codeList=====err%s", utils.Format4Output(err, false)) case http.MethodPost:
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail} data, err := ioutil.ReadAll(req.Body)
c.ServeJSON() if err != nil {
return globals.SugarLogger.Debugf("MethodPost=====err%s", utils.Format4Output(err, false))
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
c.ServeJSON()
return
}
globals.SugarLogger.Debugf("data=====err%s", string(data))
if err := json.Unmarshal(data, &code); err != nil {
globals.SugarLogger.Debugf("Unmarshal=====err%s", utils.Format4Output(err, false))
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
c.ServeJSON()
return
}
case http.MethodGet:
codeValues := req.URL.Query()
globals.SugarLogger.Debugf("codeValues=====%s", utils.Format4Output(codeValues, false))
codeList := codeValues.Get("code")
globals.SugarLogger.Debugf("codeList=====%s", utils.Format4Output(codeList, false))
globals.SugarLogger.Debugf("codeValues.Get(code)===%s", utils.Format4Output(codeValues.Get("Code"), false))
if err := json.Unmarshal([]byte(string(codeList)), &code); err != nil {
globals.SugarLogger.Debugf("codeList=====err%s", utils.Format4Output(err, false))
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
c.ServeJSON()
return
}
} }
globals.SugarLogger.Debugf("code ==================%s", utils.Format4Output(code, false))
if len(code) == 0 { if len(code) == 0 {
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail} c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}