Commit 8bd8be3402b92754f2247547468d023ede9fa57c
1 parent
fc50874b
Exists in
v1.2
and in
2 other branches
readme
Showing
7 changed files
with
154 additions
and
117 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,52 @@ |
| 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 | + DB.CAccessLog.Insert(DB.SAccessLog{ | |
| 37 | + c.PostForm("UserId"), | |
| 38 | + c.PostForm("UserName"), | |
| 39 | + c.PostForm("TypeNum"), | |
| 40 | + c.PostForm("TypeName"), | |
| 41 | + DateTime, | |
| 42 | + Location, | |
| 43 | + c.PostForm("Remarks"), | |
| 44 | + }) | |
| 45 | + | |
| 46 | + c.JSON(200, tools.ResponseSeccess{ | |
| 47 | + 0, | |
| 48 | + "ok", | |
| 49 | + }) | |
| 50 | + } | |
| 51 | + | |
| 52 | +} | ... | ... |
API/Tag.go
| ... | ... | @@ -30,72 +30,6 @@ func AllTag(c *gin.Context) { |
| 30 | 30 | }) |
| 31 | 31 | } else { |
| 32 | 32 | |
| 33 | - | |
| 34 | - c.JSON(200, tools.ResponseSeccess{ | |
| 35 | - 0, | |
| 36 | - Stags, | |
| 37 | - }) | |
| 38 | - } | |
| 39 | - | |
| 40 | -} | |
| 41 | - | |
| 42 | -// @Title 创建标签 | |
| 43 | -// @Description 创建标签 | |
| 44 | -// @Accept json | |
| 45 | -// @Produce json | |
| 46 | -// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}" | |
| 47 | -// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | |
| 48 | -// @Router /CreateTag? [post] | |
| 49 | -func CreateTag(c *gin.Context) { | |
| 50 | - c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | |
| 51 | - c.Header("Access-Control-Allow-Credentials", "true") | |
| 52 | - | |
| 53 | - | |
| 54 | - var Stags []*DB.STag | |
| 55 | - DB.CTags.Find(bson.M{}).All(&Stags) | |
| 56 | - | |
| 57 | - if Stags == nil { | |
| 58 | - | |
| 59 | - c.JSON(200, tools.ResponseError{ | |
| 60 | - 1, | |
| 61 | - "空", | |
| 62 | - }) | |
| 63 | - } else { | |
| 64 | - | |
| 65 | - | |
| 66 | - c.JSON(200, tools.ResponseSeccess{ | |
| 67 | - 0, | |
| 68 | - Stags, | |
| 69 | - }) | |
| 70 | - } | |
| 71 | - | |
| 72 | -} | |
| 73 | - | |
| 74 | - | |
| 75 | -// @Title 更新标签 | |
| 76 | -// @Description 更新标签 | |
| 77 | -// @Accept json | |
| 78 | -// @Produce json | |
| 79 | -// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}" | |
| 80 | -// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | |
| 81 | -// @Router /UpdateTag? [post] | |
| 82 | -func UpdateTag(c *gin.Context) { | |
| 83 | - c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | |
| 84 | - c.Header("Access-Control-Allow-Credentials", "true") | |
| 85 | - | |
| 86 | - | |
| 87 | - var Stags []*DB.STag | |
| 88 | - DB.CTags.Find(bson.M{}).All(&Stags) | |
| 89 | - | |
| 90 | - if Stags == nil { | |
| 91 | - | |
| 92 | - c.JSON(200, tools.ResponseError{ | |
| 93 | - 1, | |
| 94 | - "空", | |
| 95 | - }) | |
| 96 | - } else { | |
| 97 | - | |
| 98 | - | |
| 99 | 33 | c.JSON(200, tools.ResponseSeccess{ |
| 100 | 34 | 0, |
| 101 | 35 | Stags, | ... | ... |
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +package AccessType | |
| 2 | + | |
| 3 | +type AccessType int32 | |
| 4 | + | |
| 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 | |
| 16 | +) | |
| 17 | + | |
| 18 | +func (o AccessType) String() string { | |
| 19 | + switch (o) { | |
| 20 | + case PageForIndex: | |
| 21 | + return "首页" | |
| 22 | + case PageForRecommendMenu: | |
| 23 | + return "推荐" | |
| 24 | + case PageForPlayItemMenu: | |
| 25 | + return "游玩项目" | |
| 26 | + case PageForPerformMenu: | |
| 27 | + return "演出活动" | |
| 28 | + case PageForServiceMenu: | |
| 29 | + return "服务设施" | |
| 30 | + case PageForRestaurantMenu: | |
| 31 | + return "餐饮购物" | |
| 32 | + case TouchAnnotation: | |
| 33 | + return "点击建筑图标" | |
| 34 | + case TouchShopMenu: | |
| 35 | + return "点击商店" | |
| 36 | + case TouchMyMenu: | |
| 37 | + return "点击个人中心" | |
| 38 | + case TouchComplaintMenu: | |
| 39 | + return "点击投诉&意见" | |
| 40 | + default: | |
| 41 | + return "UNKNOWN" | |
| 42 | + } | |
| 43 | +} | ... | ... |
Config/config.go
DB/db.go
| ... | ... | @@ -14,6 +14,7 @@ var CCommodity *mgo.Collection //商城 |
| 14 | 14 | var CTags *mgo.Collection //标签 |
| 15 | 15 | var CScenic *mgo.Collection //景区 |
| 16 | 16 | var CLine *mgo.Collection //推荐线路 |
| 17 | +var CAccessLog *mgo.Collection //访问记录 | |
| 17 | 18 | var DB *mgo.Database |
| 18 | 19 | |
| 19 | 20 | type SItem struct { |
| ... | ... | @@ -23,19 +24,28 @@ type SItem struct { |
| 23 | 24 | Location SLocation `bson:"Location" json:"Location"` |
| 24 | 25 | Tags []STag `bson:"Tags" json:"Tags"` |
| 25 | 26 | Icon string `bson:"Icon" json:"Icon"` |
| 26 | - LimitHeight string `bson:"LimitHeight" json:"LimitHeight"` | |
| 27 | - PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` | |
| 28 | - SceneTime string `bson:"SceneTime" json:"SceneTime"` | |
| 27 | + LimitHeight string `bson:"LimitHeight" json:"LimitHeight"` //限高 | |
| 28 | + PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` //游玩时长 | |
| 29 | + SceneTime string `bson:"SceneTime" json:"SceneTime"` //场次时间 | |
| 29 | 30 | Picture []string `bson:"Picture" json:"Picture"` |
| 30 | - Voice string `bson:"Voice" json:"Voice"` | |
| 31 | + Voice string `bson:"Voice" json:"Voice"` //音频 | |
| 31 | 32 | Tel string `bson:"Tel" json:"Tel"` |
| 32 | - AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"` | |
| 33 | - Menu string `bson:"Menu" json:"Menu"` | |
| 33 | + AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"` //人均消费 | |
| 34 | + Menu string `bson:"Menu" json:"Menu"` //菜单 | |
| 34 | 35 | Time string `bson:"Time" json:"Time"` |
| 35 | 36 | } |
| 36 | 37 | type SLocation struct { |
| 37 | - Latitude float64 `bson:"Latitude" json:"Latitude"` | |
| 38 | - Longitude float64 `bson:"Longitude" json:"Longitude"` | |
| 38 | + Latitude float64 `bson:"Latitude" json:"Latitude"` //纬度 | |
| 39 | + Longitude float64 `bson:"Longitude" json:"Longitude"` //经度 | |
| 40 | +} | |
| 41 | +type SAccessLog struct { | |
| 42 | + UserId string `bson:"UserId" json:"UserId"` // 用户ID | |
| 43 | + UserName string `bson:"UserName" json:"UserName"` //用户名称 | |
| 44 | + TypeNum string `bson:"TypeNum" json:"TypeNum"` //类型编号 | |
| 45 | + TypeName string `bson:"TypeName" json:"TypeName"` //类型名称 | |
| 46 | + DateTime int64 `bson:"DateTime" json:"DateTime"` //时间戳 | |
| 47 | + Location SLocation `bson:"Location" json:"Location"` //位置 | |
| 48 | + Remarks string `bson:"Remarks" json:"Remarks"` //备注 | |
| 39 | 49 | } |
| 40 | 50 | type SCommodity struct { |
| 41 | 51 | Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` |
| ... | ... | @@ -43,19 +53,19 @@ type SCommodity struct { |
| 43 | 53 | Price string `bson:"Price" json:"Price"` |
| 44 | 54 | ShopName string `bson:"ShopName" json:"ShopName"` |
| 45 | 55 | Location SLocation `bson:"Location" json:"Location"` |
| 46 | - KvPhoto string `bson:"KvPhoto" json:"KvPhoto"` | |
| 47 | - TopPhoto []string `bson:"TopPhoto" json:"TopPhoto"` | |
| 48 | - Images []string `bson:"Images" json:"Images"` | |
| 56 | + KvPhoto string `bson:"KvPhoto" json:"KvPhoto"` //用于列表页的图片 | |
| 57 | + TopPhoto []string `bson:"TopPhoto" json:"TopPhoto"` //详情页最上面的轮播图 | |
| 58 | + Images []string `bson:"Images" json:"Images"` //详情页下面的产品详细图 | |
| 49 | 59 | } |
| 50 | 60 | type SLine struct { |
| 51 | 61 | Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` |
| 52 | 62 | Name string `bson:"Name" json:"Name"` |
| 53 | - SubName string `bson:"SubName" json:"SubName"` | |
| 54 | - Location []SLocation `bson:"Location" json:"Location"` | |
| 63 | + SubName string `bson:"SubName" json:"SubName"` //游玩时长 | |
| 64 | + Location []SLocation `bson:"Location" json:"Location"` //线路点坐标 | |
| 55 | 65 | PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` |
| 56 | - Suitable string `bson:"Suitable" json:"Suitable"` | |
| 66 | + Suitable string `bson:"Suitable" json:"Suitable"` //适合人群 | |
| 57 | 67 | Content string `bson:"Content" json:"Content"` |
| 58 | - Annotations []string `bson:"Annotations" json:"Annotations"` | |
| 68 | + Annotations []string `bson:"Annotations" json:"Annotations"` //需要点亮的设施id | |
| 59 | 69 | } |
| 60 | 70 | |
| 61 | 71 | type SComplaint struct { |
| ... | ... | @@ -85,13 +95,13 @@ type SScenic struct { |
| 85 | 95 | Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` |
| 86 | 96 | Name string `bson:"Name" json:"Name"` |
| 87 | 97 | Describe string `bson:"Describe" json:"Describe"` |
| 88 | - OpenHours string `bson:"OpenHours" json:"OpenHours"` | |
| 98 | + OpenHours string `bson:"OpenHours" json:"OpenHours"` //营业时间 | |
| 89 | 99 | Mobile string `bson:"Mobile" json:"Mobile"` |
| 90 | 100 | Address string `bson:"Address" json:"Address"` |
| 91 | 101 | Location SLocation `bson:"Location" json:"Location"` |
| 92 | 102 | Picture []string `bson:"Picture" json:"Picture"` |
| 93 | - ShopAdPicture []string `bson:"ShopAdPicture" json:"ShopAdPicture"` | |
| 94 | - ItemScenicPicture []string `bson:"ItemScenicPicture" json:"ItemScenicPicture"` | |
| 95 | - ActivityPicture []string `bson:"ActivityPicture" json:"ActivityPicture"` | |
| 103 | + ShopAdPicture []string `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 | |
| 104 | + ItemScenicPicture []string `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 | |
| 105 | + ActivityPicture []string `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 | |
| 96 | 106 | VideoList []string `bson:"VideoList" json:"VideoList"` |
| 97 | 107 | } | ... | ... |
README.md
| ... | ... | @@ -8,13 +8,13 @@ |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | ### API List |
| 11 | +1. [增加访问日志](#增加访问日志) | |
| 11 | 12 | 1. [查询所有商品](#查询所有商品) |
| 12 | 13 | 1. [查询所有游玩项目](#查询所有游玩项目) |
| 13 | 14 | 1. [查询所有线路](#查询所有线路) |
| 14 | 15 | 1. [所有景区基础信息](#所有景区基础信息) |
| 15 | 16 | 1. [查询商品信息](#查询商品信息) |
| 16 | 17 | 1. [增加投诉](#增加投诉) |
| 17 | -1. [创建标签](#创建标签) | |
| 18 | 18 | 1. [用户注册](#用户注册) |
| 19 | 19 | 1. [查询设备信息](#查询设备信息) |
| 20 | 20 | 1. [查询线路信息](#查询线路信息) |
| ... | ... | @@ -26,12 +26,36 @@ |
| 26 | 26 | 1. [更新等待时间](#更新等待时间) |
| 27 | 27 | 1. [更新线路](#更新线路) |
| 28 | 28 | 1. [更新景区基础信息](#更新景区基础信息) |
| 29 | -1. [更新标签](#更新标签) | |
| 30 | 29 | 1. [上传](#上传) |
| 31 | 30 | 1. [获取用户信息](#获取用户信息) |
| 32 | 31 | |
| 33 | 32 | |
| 34 | 33 | |
| 34 | +<a name="增加访问日志"></a> | |
| 35 | + | |
| 36 | +#### /AccessLog (POST) | |
| 37 | + | |
| 38 | + | |
| 39 | +增加访问日志 | |
| 40 | + | |
| 41 | +| Param Name | Example | Data Type | Description | Required? | | |
| 42 | +|-----|-----|-----|-----|-----| | |
| 43 | +| UserId | 5dfb03070a9ac17ac7a82054 | string | 用户ID | Yes | | |
| 44 | +| UserName | Aaron | string | 用户名称 | Yes | | |
| 45 | +| TypeNum | 9 | int | 类型编号 | Yes | | |
| 46 | +| TypeName | 点击个人中心 | string | 类型名称 | Yes | | |
| 47 | +| DateTime | 1578556751220 | int | 时间戳 | Yes | | |
| 48 | +| Location | {"Latitude": 119, "Longitude": 39} | string | 位置 | Yes | | |
| 49 | +| Remarks | 备注 | string | 备注 | Yes | | |
| 50 | + | |
| 51 | + | |
| 52 | +| Code | Type | Model | Message | | |
| 53 | +|-----|-----|-----|-----| | |
| 54 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | | | |
| 55 | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 35 | 59 | <a name="查询所有商品"></a> |
| 36 | 60 | |
| 37 | 61 | #### /AllCommodity (GET) |
| ... | ... | @@ -129,20 +153,6 @@ |
| 129 | 153 | |
| 130 | 154 | |
| 131 | 155 | |
| 132 | -<a name="创建标签"></a> | |
| 133 | - | |
| 134 | -#### /CreateTag (POST) | |
| 135 | - | |
| 136 | - | |
| 137 | -创建标签 | |
| 138 | - | |
| 139 | -| Code | Type | Model | Message | | |
| 140 | -|-----|-----|-----|-----| | |
| 141 | -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]} | | |
| 142 | -| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | |
| 143 | - | |
| 144 | - | |
| 145 | - | |
| 146 | 156 | <a name="用户注册"></a> |
| 147 | 157 | |
| 148 | 158 | #### /CreateUser (POST) |
| ... | ... | @@ -338,20 +348,6 @@ |
| 338 | 348 | |
| 339 | 349 | |
| 340 | 350 | |
| 341 | -<a name="更新标签"></a> | |
| 342 | - | |
| 343 | -#### /UpdateTag (POST) | |
| 344 | - | |
| 345 | - | |
| 346 | -更新标签 | |
| 347 | - | |
| 348 | -| Code | Type | Model | Message | | |
| 349 | -|-----|-----|-----|-----| | |
| 350 | -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]} | | |
| 351 | -| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | |
| 352 | - | |
| 353 | - | |
| 354 | - | |
| 355 | 351 | <a name="上传"></a> |
| 356 | 352 | |
| 357 | 353 | #### /Upload (POST) | ... | ... |
main.go
| ... | ... | @@ -42,6 +42,7 @@ func main() { |
| 42 | 42 | DB.CTags = DB.DB.C("Tags") |
| 43 | 43 | DB.CScenic = DB.DB.C("Scenic") |
| 44 | 44 | DB.CLine = DB.DB.C("Line") |
| 45 | + DB.CAccessLog = DB.DB.C("AccessLog") | |
| 45 | 46 | |
| 46 | 47 | r := gin.Default() |
| 47 | 48 | //r.Static("/.well-known", "./.well-known/") |
| ... | ... | @@ -58,8 +59,6 @@ func main() { |
| 58 | 59 | r.GET("/ScenicInfo", Api.ScenicInfo) |
| 59 | 60 | r.GET("/LineInfo", Api.LineInfo) |
| 60 | 61 | r.GET("/AllTag", Api.AllTag) |
| 61 | - r.POST("/CreateTag", Api.CreateTag) | |
| 62 | - r.POST("/UpdateTag", Api.UpdateTag) | |
| 63 | 62 | r.POST("/Upload", Api.Upload) |
| 64 | 63 | r.POST("/UpdateItem", Api.UpdateItem) |
| 65 | 64 | r.POST("/UpdateCommodity", Api.UpdateCommodity) |
| ... | ... | @@ -67,6 +66,8 @@ func main() { |
| 67 | 66 | r.POST("/UpdateScenic", Api.UpdateScenic) |
| 68 | 67 | r.POST("/UpdateItemTime", Api.UpdateItemTime) |
| 69 | 68 | r.GET("/AllScenic", Api.AllScenic) |
| 69 | + r.POST("/AccessLog", Api.AccessLog) | |
| 70 | + r.GET("/AccessLog", Api.AccessLog) | |
| 70 | 71 | //r.GET("/ws", Api.WsPage) |
| 71 | 72 | |
| 72 | 73 | r.Static("/Upload", "./Upload") | ... | ... |