diff --git a/API/AccessLog.go b/API/AccessLog.go
new file mode 100644
index 0000000..3b2cccc
--- /dev/null
+++ b/API/AccessLog.go
@@ -0,0 +1,52 @@
+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)
+
+ DB.CAccessLog.Insert(DB.SAccessLog{
+ c.PostForm("UserId"),
+ c.PostForm("UserName"),
+ c.PostForm("TypeNum"),
+ c.PostForm("TypeName"),
+ DateTime,
+ Location,
+ c.PostForm("Remarks"),
+ })
+
+ c.JSON(200, tools.ResponseSeccess{
+ 0,
+ "ok",
+ })
+ }
+
+}
diff --git a/API/Tag.go b/API/Tag.go
index 2453612..7a0bc0f 100644
--- a/API/Tag.go
+++ b/API/Tag.go
@@ -30,72 +30,6 @@ func AllTag(c *gin.Context) {
})
} else {
-
- c.JSON(200, tools.ResponseSeccess{
- 0,
- Stags,
- })
- }
-
-}
-
-// @Title 创建标签
-// @Description 创建标签
-// @Accept json
-// @Produce json
-// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}"
-// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
-// @Router /CreateTag? [post]
-func CreateTag(c *gin.Context) {
- c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
- c.Header("Access-Control-Allow-Credentials", "true")
-
-
- var Stags []*DB.STag
- DB.CTags.Find(bson.M{}).All(&Stags)
-
- if Stags == nil {
-
- c.JSON(200, tools.ResponseError{
- 1,
- "空",
- })
- } else {
-
-
- c.JSON(200, tools.ResponseSeccess{
- 0,
- Stags,
- })
- }
-
-}
-
-
-// @Title 更新标签
-// @Description 更新标签
-// @Accept json
-// @Produce json
-// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}"
-// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
-// @Router /UpdateTag? [post]
-func UpdateTag(c *gin.Context) {
- c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
- c.Header("Access-Control-Allow-Credentials", "true")
-
-
- var Stags []*DB.STag
- DB.CTags.Find(bson.M{}).All(&Stags)
-
- if Stags == nil {
-
- c.JSON(200, tools.ResponseError{
- 1,
- "空",
- })
- } else {
-
-
c.JSON(200, tools.ResponseSeccess{
0,
Stags,
diff --git a/Config/AccessType/AccessType.go b/Config/AccessType/AccessType.go
new file mode 100644
index 0000000..11915aa
--- /dev/null
+++ b/Config/AccessType/AccessType.go
@@ -0,0 +1,43 @@
+package AccessType
+
+type AccessType 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
+)
+
+func (o AccessType) String() string {
+ switch (o) {
+ case PageForIndex:
+ return "首页"
+ case PageForRecommendMenu:
+ return "推荐"
+ case PageForPlayItemMenu:
+ return "游玩项目"
+ case PageForPerformMenu:
+ return "演出活动"
+ case PageForServiceMenu:
+ return "服务设施"
+ case PageForRestaurantMenu:
+ return "餐饮购物"
+ case TouchAnnotation:
+ return "点击建筑图标"
+ case TouchShopMenu:
+ return "点击商店"
+ case TouchMyMenu:
+ return "点击个人中心"
+ case TouchComplaintMenu:
+ return "点击投诉&意见"
+ default:
+ return "UNKNOWN"
+ }
+}
diff --git a/Config/config.go b/Config/config.go
index a857481..3eda95e 100644
--- a/Config/config.go
+++ b/Config/config.go
@@ -4,3 +4,4 @@ type Config struct {
TagType []string
DbPath string
}
+
diff --git a/DB/db.go b/DB/db.go
index 0d6c594..1792fcb 100644
--- a/DB/db.go
+++ b/DB/db.go
@@ -14,6 +14,7 @@ var CCommodity *mgo.Collection //商城
var CTags *mgo.Collection //标签
var CScenic *mgo.Collection //景区
var CLine *mgo.Collection //推荐线路
+var CAccessLog *mgo.Collection //访问记录
var DB *mgo.Database
type SItem struct {
@@ -23,19 +24,28 @@ type SItem struct {
Location SLocation `bson:"Location" json:"Location"`
Tags []STag `bson:"Tags" json:"Tags"`
Icon string `bson:"Icon" json:"Icon"`
- LimitHeight string `bson:"LimitHeight" json:"LimitHeight"`
- PlayDuration string `bson:"PlayDuration" json:"PlayDuration"`
- SceneTime string `bson:"SceneTime" json:"SceneTime"`
+ LimitHeight string `bson:"LimitHeight" json:"LimitHeight"` //限高
+ PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` //游玩时长
+ SceneTime string `bson:"SceneTime" json:"SceneTime"` //场次时间
Picture []string `bson:"Picture" json:"Picture"`
- Voice string `bson:"Voice" json:"Voice"`
+ Voice string `bson:"Voice" json:"Voice"` //音频
Tel string `bson:"Tel" json:"Tel"`
- AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"`
- Menu string `bson:"Menu" json:"Menu"`
+ AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"` //人均消费
+ Menu string `bson:"Menu" json:"Menu"` //菜单
Time string `bson:"Time" json:"Time"`
}
type SLocation struct {
- Latitude float64 `bson:"Latitude" json:"Latitude"`
- Longitude float64 `bson:"Longitude" json:"Longitude"`
+ Latitude float64 `bson:"Latitude" json:"Latitude"` //纬度
+ Longitude float64 `bson:"Longitude" json:"Longitude"` //经度
+}
+type SAccessLog struct {
+ UserId string `bson:"UserId" json:"UserId"` // 用户ID
+ UserName string `bson:"UserName" json:"UserName"` //用户名称
+ TypeNum string `bson:"TypeNum" json:"TypeNum"` //类型编号
+ TypeName string `bson:"TypeName" json:"TypeName"` //类型名称
+ DateTime int64 `bson:"DateTime" json:"DateTime"` //时间戳
+ Location SLocation `bson:"Location" json:"Location"` //位置
+ Remarks string `bson:"Remarks" json:"Remarks"` //备注
}
type SCommodity struct {
Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
@@ -43,19 +53,19 @@ type SCommodity struct {
Price string `bson:"Price" json:"Price"`
ShopName string `bson:"ShopName" json:"ShopName"`
Location SLocation `bson:"Location" json:"Location"`
- KvPhoto string `bson:"KvPhoto" json:"KvPhoto"`
- TopPhoto []string `bson:"TopPhoto" json:"TopPhoto"`
- Images []string `bson:"Images" json:"Images"`
+ KvPhoto string `bson:"KvPhoto" json:"KvPhoto"` //用于列表页的图片
+ TopPhoto []string `bson:"TopPhoto" json:"TopPhoto"` //详情页最上面的轮播图
+ Images []string `bson:"Images" json:"Images"` //详情页下面的产品详细图
}
type SLine struct {
Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
Name string `bson:"Name" json:"Name"`
- SubName string `bson:"SubName" json:"SubName"`
- Location []SLocation `bson:"Location" json:"Location"`
+ SubName string `bson:"SubName" json:"SubName"` //游玩时长
+ Location []SLocation `bson:"Location" json:"Location"` //线路点坐标
PlayDuration string `bson:"PlayDuration" json:"PlayDuration"`
- Suitable string `bson:"Suitable" json:"Suitable"`
+ Suitable string `bson:"Suitable" json:"Suitable"` //适合人群
Content string `bson:"Content" json:"Content"`
- Annotations []string `bson:"Annotations" json:"Annotations"`
+ Annotations []string `bson:"Annotations" json:"Annotations"` //需要点亮的设施id
}
type SComplaint struct {
@@ -85,13 +95,13 @@ type SScenic struct {
Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
Name string `bson:"Name" json:"Name"`
Describe string `bson:"Describe" json:"Describe"`
- OpenHours string `bson:"OpenHours" json:"OpenHours"`
+ OpenHours string `bson:"OpenHours" json:"OpenHours"` //营业时间
Mobile string `bson:"Mobile" json:"Mobile"`
Address string `bson:"Address" json:"Address"`
Location SLocation `bson:"Location" json:"Location"`
Picture []string `bson:"Picture" json:"Picture"`
- ShopAdPicture []string `bson:"ShopAdPicture" json:"ShopAdPicture"`
- ItemScenicPicture []string `bson:"ItemScenicPicture" json:"ItemScenicPicture"`
- ActivityPicture []string `bson:"ActivityPicture" json:"ActivityPicture"`
+ ShopAdPicture []string `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片
+ ItemScenicPicture []string `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片
+ ActivityPicture []string `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片
VideoList []string `bson:"VideoList" json:"VideoList"`
}
diff --git a/README.md b/README.md
index a1bca61..8cb3592 100644
--- a/README.md
+++ b/README.md
@@ -8,13 +8,13 @@
### API List
+1. [增加访问日志](#增加访问日志)
1. [查询所有商品](#查询所有商品)
1. [查询所有游玩项目](#查询所有游玩项目)
1. [查询所有线路](#查询所有线路)
1. [所有景区基础信息](#所有景区基础信息)
1. [查询商品信息](#查询商品信息)
1. [增加投诉](#增加投诉)
-1. [创建标签](#创建标签)
1. [用户注册](#用户注册)
1. [查询设备信息](#查询设备信息)
1. [查询线路信息](#查询线路信息)
@@ -26,12 +26,36 @@
1. [更新等待时间](#更新等待时间)
1. [更新线路](#更新线路)
1. [更新景区基础信息](#更新景区基础信息)
-1. [更新标签](#更新标签)
1. [上传](#上传)
1. [获取用户信息](#获取用户信息)
+
+
+#### /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)
@@ -129,20 +153,6 @@
-
-
-#### /CreateTag (POST)
-
-
-创建标签
-
-| Code | Type | Model | Message |
-|-----|-----|-----|-----|
-| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]} |
-| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
-
-
-
#### /CreateUser (POST)
@@ -338,20 +348,6 @@
-
-
-#### /UpdateTag (POST)
-
-
-更新标签
-
-| Code | Type | Model | Message |
-|-----|-----|-----|-----|
-| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]} |
-| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
-
-
-
#### /Upload (POST)
diff --git a/main.go b/main.go
index 5df6a1d..25f4519 100644
--- a/main.go
+++ b/main.go
@@ -42,6 +42,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")
r := gin.Default()
//r.Static("/.well-known", "./.well-known/")
@@ -58,8 +59,6 @@ func main() {
r.GET("/ScenicInfo", Api.ScenicInfo)
r.GET("/LineInfo", Api.LineInfo)
r.GET("/AllTag", Api.AllTag)
- r.POST("/CreateTag", Api.CreateTag)
- r.POST("/UpdateTag", Api.UpdateTag)
r.POST("/Upload", Api.Upload)
r.POST("/UpdateItem", Api.UpdateItem)
r.POST("/UpdateCommodity", Api.UpdateCommodity)
@@ -67,6 +66,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.GET("/ws", Api.WsPage)
r.Static("/Upload", "./Upload")
--
libgit2 0.21.0