EventLog.go
1.54 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
package Api
import (
"encoding/json"
"github.com/aarongao/tools"
"github.com/gin-gonic/gin"
"letu/DB"
"strconv"
)
// @Title 增加访问日志
// @Description 增加访问日志
// @Accept json
// @Produce json
// @Param UserId 5dfb03070a9ac17ac7a82054 string true "用户ID"
// @Param UserName Aaron string true "用户名称"
// @Param TypeNum 9 int true "类型编号"
// @Param TypeName 点击个人中心 string true "类型名称"
// @Param DateTime 1578556751220 int true "时间戳"
// @Param Location {"Latitude": 119, "Longitude": 39} string true "位置"
// @Param Remarks 备注 string true "备注"
// @Success 200 {object} tools.ResponseSeccess ""
// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
// @Router /EventLog? [post]
func EventLog(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
c.Header("Access-Control-Allow-Credentials", "true")
if c.Request.Method == "post" {
var Location DB.SLocation
json.Unmarshal([]byte(c.PostForm("Location")), &Location)
DateTime, _ := strconv.ParseInt(c.PostForm("DateTime"), 0, 64)
TypeNum, _ := strconv.ParseInt("TypeNum", 0, 64)
DB.CEventLog.Insert(DB.SEventLog{
c.PostForm("UserId"),
c.PostForm("UserName"),
TypeNum,
c.PostForm("TypeName"),
DateTime,
Location,
c.PostForm("Remarks"),
})
c.JSON(200, tools.ResponseSeccess{
0,
"ok",
})
}
}