Trajectory.go
1014 Bytes
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
package Api
import (
"encoding/json"
"github.com/aarongao/tools"
"github.com/gin-gonic/gin"
"letu/DB"
"time"
)
// @Title 保存用户移动轨迹
// @Description 保存用户移动轨迹
// @Accept json
// @Produce json
// @Param UserId 5dfb03070a9ac17ac7a82054 string true "用户id"
// @Param Location {"Latitude": 119, "Longitude": 39} string true "经纬度"
// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}"
// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
// @Router /Trajectory/Save? [post]
func SaveTrajectory(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
c.Header("Access-Control-Allow-Credentials", "true")
var Location DB.SLocation
json.Unmarshal([]byte(c.PostForm("Location")), &Location)
DB.CTrajectory.Insert(DB.STrajectory{
c.PostForm("UserId"),
Location,
time.Now().Unix(),
})
c.JSON(200, tools.ResponseSeccess{
0,
"ok",
})
}