cloud-archive.go
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**********************************************
* Copyright(c) 2017 IceSimba
* All rights reserved.
*
* FileName: icesimba.cloud.go
* Author: dsl
* Version: 1.0
* Date: 2017/08/03
* Description: 云存档接口Api
* Others:
* Function List:
1.…………
2.…………
* History:
1.Date:
Author:
Modification:
**********************************************/
package apis
import (
//"common"
"fmt"
"net/http"
. "client/icesimba.cloud/models"
"github.com/gin-gonic/gin"
)
var (
code string
data string
)
/*
* 测试网络连接接口
*/
func IndexApi(c *gin.Context) {
c.String(http.StatusOK, "It works")
}
/*
* 创建或者更新云存档
*/
func CreateCloudArchiveApi(c *gin.Context) {
fmt.Println(c.Request.URL.String())
userId := c.Request.FormValue("user_id")
gameId := c.Request.FormValue("game_id")
dataPacket := c.Request.FormValue("data_packet")
if userId == "" || gameId == "" || dataPacket == "" {
code = "102000"
c.JSON(http.StatusOK, gin.H{
"code": code,
"msg": "missing parameter",
})
return
}
cloud := CloudArchive{
UserId: userId,
GameId: gameId,
DataPacket: dataPacket,
}
ca, err := cloud.PostCloudArchive()
if err != nil {
code = "102002"
c.JSON(http.StatusOK, gin.H{
"code": code,
"msg": err.Error(),
})
return
}
code = "0"
c.JSON(http.StatusOK, gin.H{
"code": code,
"obj": ca,
})
return
}
/*
* 查询云存档
*/
func QueryCloudArchiveApi(c *gin.Context) {
// fmt.Println(c.Request.URL.String())
// fmt.Println(common.GetUrlSign(
// c.Request.URL.String(),
// c.Request.FormValue("deviceId"),
// c.Request.FormValue("timestamp"),
// ))
userId := c.Request.FormValue("user_id")
gameId := c.Request.FormValue("game_id")
if userId == "" || gameId == "" {
code = "102000"
c.JSON(http.StatusOK, gin.H{
"code": code,
"msg": "missing parameter",
})
return
}
cloud := CloudArchive{
UserId: userId,
GameId: gameId,
}
data, err := cloud.GetCloudArchive()
if err != nil {
code = "102001"
c.JSON(http.StatusOK, gin.H{
"code": code,
"msg": err.Error(),
})
return
}
code = "0"
c.JSON(http.StatusOK, gin.H{
"code": code,
"obj": data,
})
return
}