diff --git a/API/AccessLog.go b/API/AccessLog.go deleted file mode 100644 index 7b88675..0000000 --- a/API/AccessLog.go +++ /dev/null @@ -1,54 +0,0 @@ -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 /AccessLog? [post] -func AccessLog(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.CAccessLog.Insert(DB.SAccessLog{ - c.PostForm("UserId"), - c.PostForm("UserName"), - TypeNum, - c.PostForm("TypeName"), - DateTime, - Location, - c.PostForm("Remarks"), - }) - - c.JSON(200, tools.ResponseSeccess{ - 0, - "ok", - }) - } - -} diff --git a/API/EventLog.go b/API/EventLog.go new file mode 100644 index 0000000..8d63722 --- /dev/null +++ b/API/EventLog.go @@ -0,0 +1,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", + }) + } + +} diff --git a/Config/AccessType/AccessType.go b/Config/AccessType/AccessType.go index 11915aa..fd6fb86 100644 --- a/Config/AccessType/AccessType.go +++ b/Config/AccessType/AccessType.go @@ -1,21 +1,21 @@ -package AccessType +package EventType -type AccessType int32 +type EventType int32 const ( - PageForIndex AccessType = 1 - PageForRecommendMenu AccessType = 2 - PageForPlayItemMenu AccessType = 3 - PageForPerformMenu AccessType = 4 - PageForServiceMenu AccessType = 5 - PageForRestaurantMenu AccessType = 6 - TouchAnnotation AccessType = 7 - TouchShopMenu AccessType = 8 - TouchMyMenu AccessType = 9 - TouchComplaintMenu AccessType = 10 + PageForIndex EventType = 1 + PageForRecommendMenu EventType = 2 + PageForPlayItemMenu EventType = 3 + PageForPerformMenu EventType = 4 + PageForServiceMenu EventType = 5 + PageForRestaurantMenu EventType = 6 + TouchAnnotation EventType = 7 + TouchShopMenu EventType = 8 + TouchMyMenu EventType = 9 + TouchComplaintMenu EventType = 10 ) -func (o AccessType) String() string { +func (o EventType) String() string { switch (o) { case PageForIndex: return "首页" diff --git a/DB/db.go b/DB/db.go index e42cd34..e06b8ec 100644 --- a/DB/db.go +++ b/DB/db.go @@ -17,8 +17,8 @@ var CCommodity *mgo.Collection //商城 var CTags *mgo.Collection //标签 var CScenic *mgo.Collection //景区 var CLine *mgo.Collection //推荐线路 -var CAccessLog *mgo.Collection //访问记录 -var CActionLog *mgo.Collection //行为记录 +var CEventLog *mgo.Collection //用户行为记录 +var CActionLog *mgo.Collection //操作记录 var CTrajectory *mgo.Collection //移动轨迹 var DB *mgo.Database @@ -48,7 +48,7 @@ type SLocation struct { Latitude float64 `bson:"Latitude" json:"Latitude"` //纬度 Longitude float64 `bson:"Longitude" json:"Longitude"` //经度 } -type SAccessLog struct { +type SEventLog struct { UserId string `bson:"UserId" json:"UserId"` // 用户ID UserName string `bson:"UserName" json:"UserName"` //用户名称 TypeNum int64 `bson:"TypeNum" json:"TypeNum"` //类型编号 diff --git a/README.md b/README.md index 8437091..19713f3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ ### API List -1. [增加访问日志](#accesslog-post) 1. [查询所有商品](#allcommodity-get) 1. [查询所有游玩项目](#allitems-get) 1. [查询所有线路](#allline-get) @@ -17,6 +16,7 @@ 1. [增加投诉](#createcomplaint-post) 1. [查询用户的定时提醒](#dealymessage-info-get) 1. [创建提醒](#dealymessage-create-post) +1. [增加访问日志](#eventlog-post) 1. [增加调查](#investigation-save-post) 1. [查询设备信息](#iteminfo-get) 1. [查询线路信息](#lineinfo-get) @@ -36,31 +36,6 @@ - - -#### /AccessLog (POST) - - -增加访问日志 - -| Param Name | Example | Data Type | Description | Required? | -|-----|-----|-----|-----|-----| -| UserId | 5dfb03070a9ac17ac7a82054 | string | 用户ID | Yes | -| UserName | Aaron | string | 用户名称 | Yes | -| TypeNum | 9 | int | 类型编号 | Yes | -| TypeName | 点击个人中心 | string | 类型名称 | Yes | -| DateTime | 1578556751220 | int | 时间戳 | Yes | -| Location | {"Latitude": 119, "Longitude": 39} | string | 位置 | Yes | -| Remarks | 备注 | string | 备注 | Yes | - - -| Code | Type | Model | Message | -|-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | | -| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | - - - #### /AllCommodity (GET) @@ -203,6 +178,31 @@ + + +#### /EventLog (POST) + + +增加访问日志 + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| UserId | 5dfb03070a9ac17ac7a82054 | string | 用户ID | Yes | +| UserName | Aaron | string | 用户名称 | Yes | +| TypeNum | 9 | int | 类型编号 | Yes | +| TypeName | 点击个人中心 | string | 类型名称 | Yes | +| DateTime | 1578556751220 | int | 时间戳 | Yes | +| Location | {"Latitude": 119, "Longitude": 39} | string | 位置 | Yes | +| Remarks | 备注 | string | 备注 | Yes | + + +| Code | Type | Model | Message | +|-----|-----|-----|-----| +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | + + + #### /Investigation/Save (POST) diff --git a/main.go b/main.go index 0d3f58f..c1ca003 100644 --- a/main.go +++ b/main.go @@ -56,7 +56,7 @@ func main() { DB.CTags = DB.DB.C("Tags") DB.CScenic = DB.DB.C("Scenic") DB.CLine = DB.DB.C("Line") - DB.CAccessLog = DB.DB.C("AccessLog") + DB.CEventLog = DB.DB.C("EventLog") DB.CActionLog = DB.DB.C("ActionLog") DB.CInvestigation = DB.DB.C("Investigation") DB.CTrajectory = DB.DB.C("Trajectory") @@ -87,8 +87,8 @@ func main() { r.POST("/UpdateScenic", Api.UpdateScenic) r.POST("/UpdateItemTime", Api.UpdateItemTime) r.GET("/AllScenic", Api.AllScenic) - r.POST("/AccessLog", Api.AccessLog) - r.GET("/AccessLog", Api.AccessLog) + r.POST("/EventLog", Api.EventLog) + r.GET("/EventLog", Api.EventLog) r.POST("/Sms/Send", Api.Send) r.POST("/Investigation/Save", Api.SaveInvestigation) r.POST("/Trajectory/Save", Api.SaveTrajectory) -- libgit2 0.21.0