|
|
@@ -1,9 +1,11 @@
|
|
|
package model
|
|
|
|
|
|
import (
|
|
|
+ "bytes"
|
|
|
"encoding/base64"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "io/ioutil"
|
|
|
"net/http"
|
|
|
"rocommon/service"
|
|
|
"rocommon/util"
|
|
|
@@ -165,6 +167,44 @@ func GetServerState(c *gin.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+func MyCardCodeRequest(c *gin.Context) {
|
|
|
+ _ = c.DefaultQuery("sid", "0") ///default 0
|
|
|
+ // 定义要请求的URL
|
|
|
+ url := service.GetServiceConfig().SDKConfig.CodeRequestUrl
|
|
|
+ postData := &CodeRequest{}
|
|
|
+ // 将结构体编码为JSON
|
|
|
+ jsonData, err := json.Marshal(postData)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("JSON编码失败: %s\n", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发送POST请求
|
|
|
+ response, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("请求失败: %s\n", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer response.Body.Close()
|
|
|
+
|
|
|
+ // 读取响应体
|
|
|
+ body, err := ioutil.ReadAll(response.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("读取响应失败: %s\n", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 打印响应状态码和响应体
|
|
|
+ fmt.Printf("状态码: %d\n", response.StatusCode)
|
|
|
+ fmt.Printf("响应体: %s\n", body)
|
|
|
+ c.JSON(http.StatusOK, gin.H{
|
|
|
+ "err": "no server node!!!",
|
|
|
+ })
|
|
|
+ c.JSON(http.StatusOK, gin.H{
|
|
|
+ "err": "no server node!!!",
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
type SelfServerNodeDetail struct {
|
|
|
ServerId int32 `json:serverid`
|
|
|
HeadFrameId int32 `json:headframeid`
|