Commit 9ecec7d437bd04be32ac53b8e56b7dafea9176a7
1 parent
21bc8074
Exists in
v1.2
and in
2 other branches
..
Showing
6 changed files
with
99 additions
and
99 deletions
Show diff stats
API/AccessLog.go
| ... | ... | @@ -1,54 +0,0 @@ |
| 1 | -package Api | |
| 2 | - | |
| 3 | -import ( | |
| 4 | - "encoding/json" | |
| 5 | - "github.com/aarongao/tools" | |
| 6 | - "github.com/gin-gonic/gin" | |
| 7 | - "letu/DB" | |
| 8 | - "strconv" | |
| 9 | -) | |
| 10 | - | |
| 11 | -// @Title 增加访问日志 | |
| 12 | -// @Description 增加访问日志 | |
| 13 | -// @Accept json | |
| 14 | -// @Produce json | |
| 15 | -// @Param UserId 5dfb03070a9ac17ac7a82054 string true "用户ID" | |
| 16 | -// @Param UserName Aaron string true "用户名称" | |
| 17 | -// @Param TypeNum 9 int true "类型编号" | |
| 18 | -// @Param TypeName 点击个人中心 string true "类型名称" | |
| 19 | -// @Param DateTime 1578556751220 int true "时间戳" | |
| 20 | -// @Param Location {"Latitude": 119, "Longitude": 39} string true "位置" | |
| 21 | -// @Param Remarks 备注 string true "备注" | |
| 22 | -// @Success 200 {object} tools.ResponseSeccess "" | |
| 23 | -// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | |
| 24 | -// @Router /AccessLog? [post] | |
| 25 | -func AccessLog(c *gin.Context) { | |
| 26 | - c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | |
| 27 | - c.Header("Access-Control-Allow-Credentials", "true") | |
| 28 | - | |
| 29 | - if c.Request.Method == "post" { | |
| 30 | - | |
| 31 | - var Location DB.SLocation | |
| 32 | - json.Unmarshal([]byte(c.PostForm("Location")), &Location) | |
| 33 | - | |
| 34 | - DateTime, _ := strconv.ParseInt(c.PostForm("DateTime"), 0, 64) | |
| 35 | - | |
| 36 | - TypeNum, _ := strconv.ParseInt("TypeNum", 0, 64) | |
| 37 | - | |
| 38 | - DB.CAccessLog.Insert(DB.SAccessLog{ | |
| 39 | - c.PostForm("UserId"), | |
| 40 | - c.PostForm("UserName"), | |
| 41 | - TypeNum, | |
| 42 | - c.PostForm("TypeName"), | |
| 43 | - DateTime, | |
| 44 | - Location, | |
| 45 | - c.PostForm("Remarks"), | |
| 46 | - }) | |
| 47 | - | |
| 48 | - c.JSON(200, tools.ResponseSeccess{ | |
| 49 | - 0, | |
| 50 | - "ok", | |
| 51 | - }) | |
| 52 | - } | |
| 53 | - | |
| 54 | -} |
| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | +package Api | |
| 2 | + | |
| 3 | +import ( | |
| 4 | + "encoding/json" | |
| 5 | + "github.com/aarongao/tools" | |
| 6 | + "github.com/gin-gonic/gin" | |
| 7 | + "letu/DB" | |
| 8 | + "strconv" | |
| 9 | +) | |
| 10 | + | |
| 11 | +// @Title 增加访问日志 | |
| 12 | +// @Description 增加访问日志 | |
| 13 | +// @Accept json | |
| 14 | +// @Produce json | |
| 15 | +// @Param UserId 5dfb03070a9ac17ac7a82054 string true "用户ID" | |
| 16 | +// @Param UserName Aaron string true "用户名称" | |
| 17 | +// @Param TypeNum 9 int true "类型编号" | |
| 18 | +// @Param TypeName 点击个人中心 string true "类型名称" | |
| 19 | +// @Param DateTime 1578556751220 int true "时间戳" | |
| 20 | +// @Param Location {"Latitude": 119, "Longitude": 39} string true "位置" | |
| 21 | +// @Param Remarks 备注 string true "备注" | |
| 22 | +// @Success 200 {object} tools.ResponseSeccess "" | |
| 23 | +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | |
| 24 | +// @Router /EventLog? [post] | |
| 25 | +func EventLog(c *gin.Context) { | |
| 26 | + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | |
| 27 | + c.Header("Access-Control-Allow-Credentials", "true") | |
| 28 | + | |
| 29 | + if c.Request.Method == "post" { | |
| 30 | + | |
| 31 | + var Location DB.SLocation | |
| 32 | + json.Unmarshal([]byte(c.PostForm("Location")), &Location) | |
| 33 | + | |
| 34 | + DateTime, _ := strconv.ParseInt(c.PostForm("DateTime"), 0, 64) | |
| 35 | + | |
| 36 | + TypeNum, _ := strconv.ParseInt("TypeNum", 0, 64) | |
| 37 | + | |
| 38 | + DB.CEventLog.Insert(DB.SEventLog{ | |
| 39 | + c.PostForm("UserId"), | |
| 40 | + c.PostForm("UserName"), | |
| 41 | + TypeNum, | |
| 42 | + c.PostForm("TypeName"), | |
| 43 | + DateTime, | |
| 44 | + Location, | |
| 45 | + c.PostForm("Remarks"), | |
| 46 | + }) | |
| 47 | + | |
| 48 | + c.JSON(200, tools.ResponseSeccess{ | |
| 49 | + 0, | |
| 50 | + "ok", | |
| 51 | + }) | |
| 52 | + } | |
| 53 | + | |
| 54 | +} | ... | ... |
Config/AccessType/AccessType.go
| 1 | -package AccessType | |
| 1 | +package EventType | |
| 2 | 2 | |
| 3 | -type AccessType int32 | |
| 3 | +type EventType int32 | |
| 4 | 4 | |
| 5 | 5 | const ( |
| 6 | - PageForIndex AccessType = 1 | |
| 7 | - PageForRecommendMenu AccessType = 2 | |
| 8 | - PageForPlayItemMenu AccessType = 3 | |
| 9 | - PageForPerformMenu AccessType = 4 | |
| 10 | - PageForServiceMenu AccessType = 5 | |
| 11 | - PageForRestaurantMenu AccessType = 6 | |
| 12 | - TouchAnnotation AccessType = 7 | |
| 13 | - TouchShopMenu AccessType = 8 | |
| 14 | - TouchMyMenu AccessType = 9 | |
| 15 | - TouchComplaintMenu AccessType = 10 | |
| 6 | + PageForIndex EventType = 1 | |
| 7 | + PageForRecommendMenu EventType = 2 | |
| 8 | + PageForPlayItemMenu EventType = 3 | |
| 9 | + PageForPerformMenu EventType = 4 | |
| 10 | + PageForServiceMenu EventType = 5 | |
| 11 | + PageForRestaurantMenu EventType = 6 | |
| 12 | + TouchAnnotation EventType = 7 | |
| 13 | + TouchShopMenu EventType = 8 | |
| 14 | + TouchMyMenu EventType = 9 | |
| 15 | + TouchComplaintMenu EventType = 10 | |
| 16 | 16 | ) |
| 17 | 17 | |
| 18 | -func (o AccessType) String() string { | |
| 18 | +func (o EventType) String() string { | |
| 19 | 19 | switch (o) { |
| 20 | 20 | case PageForIndex: |
| 21 | 21 | return "首页" | ... | ... |
DB/db.go
| ... | ... | @@ -17,8 +17,8 @@ var CCommodity *mgo.Collection //商城 |
| 17 | 17 | var CTags *mgo.Collection //标签 |
| 18 | 18 | var CScenic *mgo.Collection //景区 |
| 19 | 19 | var CLine *mgo.Collection //推荐线路 |
| 20 | -var CAccessLog *mgo.Collection //访问记录 | |
| 21 | -var CActionLog *mgo.Collection //行为记录 | |
| 20 | +var CEventLog *mgo.Collection //用户行为记录 | |
| 21 | +var CActionLog *mgo.Collection //操作记录 | |
| 22 | 22 | var CTrajectory *mgo.Collection //移动轨迹 |
| 23 | 23 | var DB *mgo.Database |
| 24 | 24 | |
| ... | ... | @@ -48,7 +48,7 @@ type SLocation struct { |
| 48 | 48 | Latitude float64 `bson:"Latitude" json:"Latitude"` //纬度 |
| 49 | 49 | Longitude float64 `bson:"Longitude" json:"Longitude"` //经度 |
| 50 | 50 | } |
| 51 | -type SAccessLog struct { | |
| 51 | +type SEventLog struct { | |
| 52 | 52 | UserId string `bson:"UserId" json:"UserId"` // 用户ID |
| 53 | 53 | UserName string `bson:"UserName" json:"UserName"` //用户名称 |
| 54 | 54 | TypeNum int64 `bson:"TypeNum" json:"TypeNum"` //类型编号 | ... | ... |
README.md
| ... | ... | @@ -8,7 +8,6 @@ |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | ### API List |
| 11 | -1. [增加访问日志](#accesslog-post) | |
| 12 | 11 | 1. [查询所有商品](#allcommodity-get) |
| 13 | 12 | 1. [查询所有游玩项目](#allitems-get) |
| 14 | 13 | 1. [查询所有线路](#allline-get) |
| ... | ... | @@ -17,6 +16,7 @@ |
| 17 | 16 | 1. [增加投诉](#createcomplaint-post) |
| 18 | 17 | 1. [查询用户的定时提醒](#dealymessage-info-get) |
| 19 | 18 | 1. [创建提醒](#dealymessage-create-post) |
| 19 | +1. [增加访问日志](#eventlog-post) | |
| 20 | 20 | 1. [增加调查](#investigation-save-post) |
| 21 | 21 | 1. [查询设备信息](#iteminfo-get) |
| 22 | 22 | 1. [查询线路信息](#lineinfo-get) |
| ... | ... | @@ -36,31 +36,6 @@ |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | -<a name="accesslog-post"></a> | |
| 40 | - | |
| 41 | -#### /AccessLog (POST) | |
| 42 | - | |
| 43 | - | |
| 44 | -增加访问日志 | |
| 45 | - | |
| 46 | -| Param Name | Example | Data Type | Description | Required? | | |
| 47 | -|-----|-----|-----|-----|-----| | |
| 48 | -| UserId | 5dfb03070a9ac17ac7a82054 | string | 用户ID | Yes | | |
| 49 | -| UserName | Aaron | string | 用户名称 | Yes | | |
| 50 | -| TypeNum | 9 | int | 类型编号 | Yes | | |
| 51 | -| TypeName | 点击个人中心 | string | 类型名称 | Yes | | |
| 52 | -| DateTime | 1578556751220 | int | 时间戳 | Yes | | |
| 53 | -| Location | {"Latitude": 119, "Longitude": 39} | string | 位置 | Yes | | |
| 54 | -| Remarks | 备注 | string | 备注 | Yes | | |
| 55 | - | |
| 56 | - | |
| 57 | -| Code | Type | Model | Message | | |
| 58 | -|-----|-----|-----|-----| | |
| 59 | -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | | | |
| 60 | -| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | |
| 61 | - | |
| 62 | - | |
| 63 | - | |
| 64 | 39 | <a name="allcommodity-get"></a> |
| 65 | 40 | |
| 66 | 41 | #### /AllCommodity (GET) |
| ... | ... | @@ -203,6 +178,31 @@ |
| 203 | 178 | |
| 204 | 179 | |
| 205 | 180 | |
| 181 | +<a name="eventlog-post"></a> | |
| 182 | + | |
| 183 | +#### /EventLog (POST) | |
| 184 | + | |
| 185 | + | |
| 186 | +增加访问日志 | |
| 187 | + | |
| 188 | +| Param Name | Example | Data Type | Description | Required? | | |
| 189 | +|-----|-----|-----|-----|-----| | |
| 190 | +| UserId | 5dfb03070a9ac17ac7a82054 | string | 用户ID | Yes | | |
| 191 | +| UserName | Aaron | string | 用户名称 | Yes | | |
| 192 | +| TypeNum | 9 | int | 类型编号 | Yes | | |
| 193 | +| TypeName | 点击个人中心 | string | 类型名称 | Yes | | |
| 194 | +| DateTime | 1578556751220 | int | 时间戳 | Yes | | |
| 195 | +| Location | {"Latitude": 119, "Longitude": 39} | string | 位置 | Yes | | |
| 196 | +| Remarks | 备注 | string | 备注 | Yes | | |
| 197 | + | |
| 198 | + | |
| 199 | +| Code | Type | Model | Message | | |
| 200 | +|-----|-----|-----|-----| | |
| 201 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | | | |
| 202 | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | 206 | <a name="investigation-save-post"></a> |
| 207 | 207 | |
| 208 | 208 | #### /Investigation/Save (POST) | ... | ... |
main.go
| ... | ... | @@ -56,7 +56,7 @@ func main() { |
| 56 | 56 | DB.CTags = DB.DB.C("Tags") |
| 57 | 57 | DB.CScenic = DB.DB.C("Scenic") |
| 58 | 58 | DB.CLine = DB.DB.C("Line") |
| 59 | - DB.CAccessLog = DB.DB.C("AccessLog") | |
| 59 | + DB.CEventLog = DB.DB.C("EventLog") | |
| 60 | 60 | DB.CActionLog = DB.DB.C("ActionLog") |
| 61 | 61 | DB.CInvestigation = DB.DB.C("Investigation") |
| 62 | 62 | DB.CTrajectory = DB.DB.C("Trajectory") |
| ... | ... | @@ -87,8 +87,8 @@ func main() { |
| 87 | 87 | r.POST("/UpdateScenic", Api.UpdateScenic) |
| 88 | 88 | r.POST("/UpdateItemTime", Api.UpdateItemTime) |
| 89 | 89 | r.GET("/AllScenic", Api.AllScenic) |
| 90 | - r.POST("/AccessLog", Api.AccessLog) | |
| 91 | - r.GET("/AccessLog", Api.AccessLog) | |
| 90 | + r.POST("/EventLog", Api.EventLog) | |
| 91 | + r.GET("/EventLog", Api.EventLog) | |
| 92 | 92 | r.POST("/Sms/Send", Api.Send) |
| 93 | 93 | r.POST("/Investigation/Save", Api.SaveInvestigation) |
| 94 | 94 | r.POST("/Trajectory/Save", Api.SaveTrajectory) | ... | ... |