From 58ec1105806da5abe8c2e7821e20c6457df8e401 Mon Sep 17 00:00:00 2001 From: aarongao Date: Wed, 1 Apr 2020 15:42:41 +0800 Subject: [PATCH] new --- API/Complaint.go | 3 ++- API/Icon.go | 7 +------ API/Item.go | 14 ++------------ API/Line.go | 7 +------ API/Shop.go | 7 +------ API/SystemInfo.go | 2 +- API/TopMenus.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++------------- Config/config.go | 21 +++++++++++---------- Config/config.json | 3 ++- DB/db.go | 8 ++++---- README.md | 22 ++++++++++++++++++++++ Version.md | 28 +++++++++++++++++++++++++--- main.go | 7 +++++-- 13 files changed, 124 insertions(+), 65 deletions(-) diff --git a/API/Complaint.go b/API/Complaint.go index cfb2ba6..b8417ce 100644 --- a/API/Complaint.go +++ b/API/Complaint.go @@ -88,6 +88,7 @@ func CreateComplaint(c *gin.Context) { // @Description 投诉 - 查询所有投诉 // @Accept json // @Produce json +// @Param ScenicId 5e1ed07524e03431008b4572 string true "景区id" // @Param Page 1 int true "当前第几页" // @Success 200 {object} tools.ResponseSeccess "" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" @@ -109,7 +110,7 @@ func AllComplaint(c *gin.Context) { var aComplaint = []bson.M{} - cur, err := DB.CComplaint.Find(tools.GetContext(), bson.M{}, &options.FindOptions{Limit: &limit, Skip: &skip, Sort: bson.M{"_id": -1}}) + cur, err := DB.CComplaint.Find(tools.GetContext(), bson.M{"ScenicId":c.Query("ScenicId")}, &options.FindOptions{Limit: &limit, Skip: &skip, Sort: bson.M{"_id": -1}}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { diff --git a/API/Icon.go b/API/Icon.go index 6d6292d..61882ba 100644 --- a/API/Icon.go +++ b/API/Icon.go @@ -104,13 +104,8 @@ func AllIcons(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - var ScenicId string - if ScenicId = c.Query("ScenicId"); ScenicId == "" { - ScenicId = "5e0d504e24e03431008b4567" // 乐岛 - } - var SIcons = []DB.SIcons{} - cur, err := DB.CIcons.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId}) + cur, err := DB.CIcons.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { diff --git a/API/Item.go b/API/Item.go index 5d74415..a2da5fa 100644 --- a/API/Item.go +++ b/API/Item.go @@ -56,13 +56,8 @@ func AllItems(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - var ScenicId string - if ScenicId = c.Query("ScenicId");ScenicId == ""{ - ScenicId = "5e0d504e24e03431008b4567" // 乐岛 - } - var aItems = []DB.SItem{} - cur, err := DB.CItem.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId}) + cur, err := DB.CItem.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { @@ -225,12 +220,7 @@ func AllItemTime(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - var ScenicId string - if ScenicId = c.Query("ScenicId");ScenicId == ""{ - ScenicId = "5e0d504e24e03431008b4567" // 乐岛 - } - - allteim := DB.Redis.Get("AllItemTime_" + ScenicId) + allteim := DB.Redis.Get("AllItemTime_" + c.Query("ScenicId")) if allteim != nil { c.JSON(200, allteim) } else { diff --git a/API/Line.go b/API/Line.go index 17f24c2..ad96e98 100644 --- a/API/Line.go +++ b/API/Line.go @@ -53,13 +53,8 @@ func AllLine(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - var ScenicId string - if ScenicId = c.Query("ScenicId");ScenicId == ""{ - ScenicId = "5e0d504e24e03431008b4567" // 乐岛 - } - var aLine []DB.SLine - cur, err := DB.CLine.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId}) + cur, err := DB.CLine.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { diff --git a/API/Shop.go b/API/Shop.go index b707af4..f585b0c 100644 --- a/API/Shop.go +++ b/API/Shop.go @@ -54,13 +54,8 @@ func AllCommodity(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - var ScenicId string - if ScenicId = c.Query("ScenicId");ScenicId == ""{ - ScenicId = "5e0d504e24e03431008b4567" // 乐岛 - } - var aCommoditys []DB.SCommodity - cur, err := DB.CCommodity.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId}) + cur, err := DB.CCommodity.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { diff --git a/API/SystemInfo.go b/API/SystemInfo.go index 7ff2e2e..b83c238 100644 --- a/API/SystemInfo.go +++ b/API/SystemInfo.go @@ -20,7 +20,7 @@ func SystemInfo(c *gin.Context) { info := make(map[string]interface{}) info["Version"] = Config.Info.Version - + info["SupportVersion"] = Config.Info.SupportVersion UpdateLocationInterval := DB.Redis.Get("UpdateLocationInterval") info["UpdateLocationInterval"] = UpdateLocationInterval diff --git a/API/TopMenus.go b/API/TopMenus.go index cd1ffff..5c894a5 100644 --- a/API/TopMenus.go +++ b/API/TopMenus.go @@ -24,19 +24,8 @@ func AllTopMenus(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - _user, _ := c.Get("UserInfo") - user := _user.(*DB.SMember) - err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user) - if err != nil { - c.JSON(200, tools.ResponseError{ - 401, - "没有权限", - }) - return - } - var STopMenus []DB.STopMenus - cur, err := DB.CTopMenus.Find(tools.GetContext(), bson.M{"ScenicId": c.PostForm("ScenicId")}) + cur, err := DB.CTopMenus.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { @@ -105,7 +94,7 @@ func UpdateTopMenus(c *gin.Context) { bson.M{"_id": id}, bson.M{"$set": bson.M{ "ScenicId": c.PostForm("ScenicId"), - "Title": c.PostForm("Title"), + "Name": c.PostForm("Name"), "Tags": Tags, }}, &options.FindOneAndUpdateOptions{ Upsert: &upsert, @@ -118,3 +107,48 @@ func UpdateTopMenus(c *gin.Context) { }) } + +// @Title 删除菜单 +// @Description 删除菜单 +// @Accept json +// @Produce json +// @Param id 5dfb03070a9ac17ac7a82054 string true "公告id" +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id" +// @Param Token wgergejfwe string true "用户token" +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" +// @Router /TopMenus/Remove? [post] +func RemoveTopMenus(c *gin.Context) { + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) + c.Header("Access-Control-Allow-Credentials", "true") + + _user, _ := c.Get("UserInfo") + user := _user.(*DB.SMember) + + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user) + if err != nil { + c.JSON(200, tools.ResponseError{ + 401, + "没有权限", + }) + return + } + + _, err = primitive.ObjectIDFromHex(c.PostForm("id")) + if err != nil { + c.JSON(200, tools.ResponseError{ + 1, + "id不正确", + }) + return + } + + objID, _ := primitive.ObjectIDFromHex(c.PostForm("id")) + DB.CTopMenus.DeleteOne(tools.GetContext(), bson.M{"_id": objID}) + + c.JSON(200, tools.ResponseSeccess{ + 0, + "ok", + }) + +} \ No newline at end of file diff --git a/Config/config.go b/Config/config.go index b4f4205..669eccc 100644 --- a/Config/config.go +++ b/Config/config.go @@ -1,16 +1,17 @@ package Config type Config struct { - TagType []string - DbPath string - DbName string - DbUser string - DbPassword string - RedisPath string - Env string - TokenSecret string - ServerPort string - Version string + TagType []string + DbPath string + DbName string + DbUser string + DbPassword string + RedisPath string + Env string + TokenSecret string + ServerPort string + Version int64 + SupportVersion int64 } var Info = Config{} diff --git a/Config/config.json b/Config/config.json index 4ae3cce..f68cd1b 100644 --- a/Config/config.json +++ b/Config/config.json @@ -8,5 +8,6 @@ "Env": "DEV", "tokenSecret": "token.secret", "ServerPort": ":8080", - "Version": "v1.1" + "Version": 1.1, + "SupportVersion": 1.0 } diff --git a/DB/db.go b/DB/db.go index 3208d7e..1669971 100644 --- a/DB/db.go +++ b/DB/db.go @@ -20,9 +20,9 @@ var CUserLog *mongo.Collection //用户行为记录 var CSystemLog *mongo.Collection //操作记录 var CTrajectory *mongo.Collection //移动轨迹 var CIcons *mongo.Collection //图标信息 -var CTopMenus *mongo.Collection //菜单 var CDevice *mongo.Collection //设备清单 var CNotice *mongo.Collection //公告 +var CTopMenus *mongo.Collection //菜单 var DB *mongo.Database type SItem struct { @@ -80,9 +80,9 @@ type SLocation struct { } type STopMenus struct { Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` - ScenicId string `bson:"ScenicId" json:"ScenicId"` - Title string `bson:"Title" json:"Title"` //菜单标题 - Tags []string `bson:"Tags" json:"Tags"` //标签 + ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` + Name string `bson:"Name" json:"Name" valid:"required"` //菜单标题 + Tags []string `bson:"Tags" json:"Tags" valid:"required"` //标签 } type SDevice struct { diff --git a/README.md b/README.md index 28f150e..e4060d1 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ 1. [标签 - 删除标签](#tag-remove-post) 1. [菜单管理 - 查询所有菜单](#topmenus-all-get) 1. [菜单管理 - 更新菜单](#topmenus-update-post) +1. [删除菜单](#topmenus-remove-post) 1. [保存用户移动轨迹(5分钟提交一次)](#trajectory-save-post) 1. [更新商品](#updatecommodity-post) 1. [设备管理 - 更新设施](#updateitem-post) @@ -89,6 +90,7 @@ | Param Name | Example | Data Type | Description | Required? | |-----|-----|-----|-----|-----| +| ScenicId | 5e1ed07524e03431008b4572 | string | 景区id | Yes | | Page | 1 | int | 当前第几页 | Yes | @@ -832,6 +834,26 @@ | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | + + +#### /TopMenus/Remove (POST) + + +删除菜单 + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| id | 5dfb03070a9ac17ac7a82054 | string | 公告id | Yes | +| ScenicId | 5dfb03070a9ac17ac7a82054 | string | 景区id | Yes | +| Token | wgergejfwe | string | 用户token | Yes | + + +| Code | Type | Model | Message | +|-----|-----|-----|-----| +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":"ok"} | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | + + diff --git a/Version.md b/Version.md index 49e91f2..acc0586 100644 --- a/Version.md +++ b/Version.md @@ -8,19 +8,22 @@ 1. /UserInfo接口增加权限验证(需要携带Token),游客只能查询自己信息,操作员可查询所有。 -2. /SystemInfo 新增系统信息接口 +2. /AllComplaint接口增加ScenicId景区id参数 + +3. /SystemInfo 新增系统信息接口 ``` { "errcode": 0, "result": { "UpdateLocationInterval": 30,//上报位置时间间隔(秒) - "Version": "v1.1"//最新版本号 + "Version": 1.1//最新版本号 + "SupportVersion": 1.1//支持的最旧版本号 } } ``` -3. 新增加公告管理模块接口 +4. 新增加公告管理模块接口 ``` /Notice/Info @@ -30,8 +33,22 @@ /Notice/Modify(需要携带Token) ``` +5. 新增加顶部菜单相关接口 + + ``` + /TopMenus/All 获取所有菜单,以及关联标签 + /TopMenus/Update(需要携带Token) + /TopMenus/Remove(需要携带Token) + ``` + +6. 删除【游玩项目】标签。增加【游乐设施】【演出】【餐饮】【购物】【普通】 + +7. 删除【location】标签组 + +8. + ##### 发布流程: 1. 提交APP代码到git(v1.1分支) @@ -40,3 +57,8 @@ 4. 使用 “生产环境地址” 打包公测版本至TestFlight 5. 发布至商店 + + +##### 销毁说明 + +1. \ No newline at end of file diff --git a/main.go b/main.go index a968249..eaf2ed7 100644 --- a/main.go +++ b/main.go @@ -92,9 +92,9 @@ func main() { DB.CInvestigation = DB.DB.Collection("Investigation") DB.CTrajectory = DB.DB.Collection("Trajectory") DB.CIcons = DB.DB.Collection("Icons") - DB.CTopMenus = DB.DB.Collection("TopMenus") DB.CDevice = DB.DB.Collection("Device") DB.CNotice = DB.DB.Collection("Notice") + DB.CTopMenus = DB.DB.Collection("TopMenu") DelayMessage.CDelayMessage = DB.DB.Collection("DelayMessage") DelayMessage.CDelayErrorLog = DB.DB.Collection("DelayErrorLog") @@ -156,7 +156,8 @@ func main() { InitController("GET", "/Icon/Info", Api.IconInfo, &DB.SModel{}) InitController("POST", "/CheckToken", Api.CheckToken, &DB.SModel{}) //InitController("/Tiles", Api.Tiles) - InitController("POST", "/TopMenus/Update", Api.UpdateTopMenus, &DB.SModel{}) + InitController("POST", "/TopMenus/Update", Api.UpdateTopMenus, &DB.SModel{"菜单管理","修改"}) + InitController("POST", "/TopMenus/Remove", Api.RemoveTopMenus, &DB.SModel{"菜单管理","删除"}) InitController("GET", "/TopMenus/All", Api.AllTopMenus, &DB.SModel{}) InitController("GET", "/RegisterDevice", Api.RegisterDevice, &DB.SModel{}) InitController("POST", "/RemoveUser", Api.RemoveUser, &DB.SModel{"用户管理", "删除"}) @@ -165,6 +166,8 @@ func main() { InitController("POST", "/UpdateOperator", Api.UpdateOperator, &DB.SModel{"操作员管理", "增加和修改"}) InitController("GET", "/AllOperator", Api.AllOperator, &DB.SModel{"操作员管理", "查看所有"}) InitController("GET", "/SystemInfo", Api.SystemInfo, &DB.SModel{}) + + Gin.GET("/AllModules", Auth.Modules) //InitController("/ws", Api.WsPage) -- libgit2 0.21.0