package controller import ( "easygoadmin/utils" "easygoadmin/utils/common" "encoding/json" "fmt" "github.com/gin-gonic/gin" "net/http" ) // 用户API管理对象 var Test = new(testCtl) type testCtl struct{} func (c *testCtl) Test(ctx *gin.Context) { //cache := utils.GetRedisHelper() //cache.Set(ctx, "cacheTest", "1112", 10*time.Minute) //utils.SendSms("18583618609", "【B卡特权】优惠券购买成功!请下载B卡特权APP进行使用。下载或需要帮助请点击: https://d.shareyi.top/2 ,退订回T", "Cloud") // goodsId 类型:2移动 3电信 4联通 //strLQ, okLQ := utils.OrderDirectAdd("19828267470", "recharge202210231337", "work.shareyi.top:9097", 1, 100) //strLQ, okLQ := utils.OrderDirectAdd("19888888888", "recharge202210231338", "work.shareyi.top:9097", 1, 100) //{"code":1019,"message":"您的IP不在IP白名单内,联系平台添加","result":null,"sign":null} //if !okLQ { // logs.Error("调快充接口失败") //} //logs.Debug("strLQ, okLQ----------------------", strLQ, okLQ) //a, b := utils.Refund(36, "recharge2022102617412013698", "4200001627202210267407543317", "", 95) //logs.Debug(a, b) // 返回结果 ctx.JSON(http.StatusOK, common.JsonResult{ Code: 0, Data: nil, Msg: "查询成功2", Count: 0, }) } func (c *testCtl) Test2(ctx *gin.Context) { //panic("this is panic") // 返回结果 ctx.JSON(http.StatusOK, common.JsonResult{ Code: 0, Data: nil, Msg: "查询成功2", Count: 0, }) } func (c *testCtl) TestJwt(ctx *gin.Context) { str, err := utils.GenerateToken(1, "18583638609", "asd") if err != nil { ctx.JSON(http.StatusOK, common.JsonResult{ Code: -1, Msg: err.Error(), }) } // 返回结果 ctx.JSON(http.StatusOK, common.JsonResult{ Code: 0, Data: nil, Msg: "查询成功: " + str, Count: 0, }) } type TestReq struct { Jwt string `form:"jwt"` // 用户名 } func (c *testCtl) TestCheckJwt(ctx *gin.Context) { jwt := ctx.Query("jwt") fmt.Println("req", jwt) str, err := utils.ParseToken(jwt) if err != nil { ctx.JSON(http.StatusOK, common.JsonResult{ Code: -1, Msg: err.Error(), }) } jsonStr, _ := json.Marshal(str) // 返回结果 ctx.JSON(http.StatusOK, common.JsonResult{ Code: 0, Data: nil, Msg: "查询成功: " + string(jsonStr), Count: 0, }) }