diff --git a/API/Item.go b/API/Item.go index 0ef4029..d9ce563 100644 --- a/API/Item.go +++ b/API/Item.go @@ -3,7 +3,6 @@ package Api import ( "encoding/json" "github.com/aarongao/tools" - "github.com/davecgh/go-spew/spew" "github.com/gin-gonic/gin" "gopkg.in/mgo.v2/bson" "letu/DB" @@ -110,6 +109,24 @@ func UpdateItem(c *gin.Context) { }}, ) + + + // 更新等待时间 + allteim := DB.Redis.Get("AllItemTime") + jsond,_ := json.Marshal(allteim) + + var ItemTime map[string]string + json.Unmarshal([]byte(jsond), &ItemTime) + + if poststate == 1{ + ItemTime[c.PostForm("id")] = "--" + } + if poststate == 0{ + ItemTime[c.PostForm("id")] = "0" + } + DB.Redis.Set("AllItemTime", ItemTime, time.Second*60*60*24*30) + + c.JSON(200, tools.ResponseSeccess{ 0, "ok", @@ -147,7 +164,6 @@ func UpdateItemTime(c *gin.Context) { 0, "ok", }) - } // @Title 获得所有设备的等待时间 @@ -162,21 +178,18 @@ func AllItemTime(c *gin.Context) { c.Header("Access-Control-Allow-Credentials", "true") - Device := DB.SDevice{ - c.Request.Header.Get("DeviceId"), - c.Request.Header.Get("Mac"), - c.Request.Header.Get("UDID"), - c.Request.Header.Get("SystemVersion"), - c.Request.Header.Get("SystemModel"), - c.Request.Header.Get("AppVersion"), - c.Request.Header.Get("AppVersion"), - c.Request.Header.Get("DeviceToken"), - } - spew.Dump(Device) - + //Device := DB.SDevice{ + // c.Request.Header.Get("DeviceId"), + // c.Request.Header.Get("Mac"), + // c.Request.Header.Get("UDID"), + // c.Request.Header.Get("SystemVersion"), + // c.Request.Header.Get("SystemModel"), + // c.Request.Header.Get("AppVersion"), + // c.Request.Header.Get("AppVersion"), + // c.Request.Header.Get("DeviceToken"), + //} + //spew.Dump(Device) - var ItemTime map[string]string - json.Unmarshal([]byte(c.PostForm("items")), &ItemTime) allteim := DB.Redis.Get("AllItemTime") if allteim != nil { @@ -185,4 +198,4 @@ func AllItemTime(c *gin.Context) { c.String(200, "{}") } -} +} \ No newline at end of file diff --git a/API/Scenic.go b/API/Scenic.go index 3bd8d8f..0b1f92e 100644 --- a/API/Scenic.go +++ b/API/Scenic.go @@ -13,7 +13,7 @@ import ( // @Accept json // @Produce json // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url" +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点)" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /ScenicInfo? [get] func ScenicInfo(c *gin.Context) { @@ -43,7 +43,7 @@ func ScenicInfo(c *gin.Context) { // @Accept json // @Produce json // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url" +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点)" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /UpdateScenic? [post] func UpdateScenic(c *gin.Context) { @@ -53,6 +53,9 @@ func UpdateScenic(c *gin.Context) { var Location DB.SLocation json.Unmarshal([]byte(c.PostForm("Location")), &Location) + var RangeLocation []DB.SLocation + json.Unmarshal([]byte(c.PostForm("RangeLocation")), &RangeLocation) + var Picture []DB.SPicture json.Unmarshal([]byte(c.PostForm("Picture")), &Picture) @@ -84,6 +87,7 @@ func UpdateScenic(c *gin.Context) { "Name": c.PostForm("Name"), "Describe": c.PostForm("Describe"), "Location": Location, + "RangeLocation": RangeLocation, "OpenHours": c.PostForm("OpenHours"), "Mobile": c.PostForm("Mobile"), "Address": c.PostForm("Address"), diff --git a/API/User.go b/API/User.go index 34ad9e8..f47dd2f 100644 --- a/API/User.go +++ b/API/User.go @@ -335,3 +335,51 @@ func UpdateUser(c *gin.Context) { } } + + +// @Title 删除用户 +// @Description 用户管理 - 删除用户(注销) +// @Accept json +// @Produce json +// @Param id aaron 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 /RemoveUser? [post] +func RemoveUser(c *gin.Context) { + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) + c.Header("Access-Control-Allow-Credentials", "true") + + if c.PostForm("Token") == "" || bson.IsObjectIdHex(c.PostForm("id")) == false { + c.JSON(200, tools.ResponseError{ + 1, + "Token或者用户id不正确", + }) + return + } + + if Token.GetToken(c.PostForm("id")) != c.PostForm("Token") { + c.JSON(200, tools.ResponseError{ + 401, + "token过期", + }) + return + } + + + err := DB.CMember.Remove(bson.M{"_id": bson.ObjectIdHex(c.PostForm("id"))}) + + if err == nil { + + c.JSON(200, tools.ResponseSeccess{ + 0, + "ok", + }) + } else { + c.JSON(200, tools.ResponseError{ + 1, + err.Error(), + }) + } + +} diff --git a/DB/db.go b/DB/db.go index ffc57d4..b58f3d1 100644 --- a/DB/db.go +++ b/DB/db.go @@ -182,4 +182,5 @@ type SScenic struct { ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 ActivityPicture []SPicture `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 VideoList []SVideo `bson:"VideoList" json:"VideoList"` + RangeLocation []SLocation `bson:"RangeLocation" json:"RangeLocation"` //景区范围 } diff --git a/README.md b/README.md index d4c13e5..69a2358 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ 1. [查询线路信息](#lineinfo-get) 1. [用户管理 - 用户登录&注册](#loginuser-post) 1. [用户管理 - 注册客户端](#registerdevice-post) +1. [用户管理 - 删除用户(注销)](#removeuser-post) 1. [返回景区基础信息](#scenicinfo-get) 1. [发送短信验证码](#sms-send-post) 1. [标签 - 增加标签](#tag-create-post) @@ -489,6 +490,26 @@ + + +#### /RemoveUser (POST) + + +用户管理 - 删除用户(注销) + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| id | aaron | 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":"错误原因"} | + + + #### /ScenicInfo (GET) @@ -503,7 +524,7 @@ | Code | Type | Model | Message | |-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点) | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | @@ -691,7 +712,7 @@ | Code | Type | Model | Message | |-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点) | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | -- libgit2 0.21.0