From 483ade81417c32153bce17ceed964e30252d6448 Mon Sep 17 00:00:00 2001 From: aarongao Date: Mon, 13 Apr 2020 18:11:07 +0800 Subject: [PATCH] v1.1 --- API/Analysls.go | 34 ++++++++++++++++++++++++++++++++++ API/Complaint.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ API/Operator.go | 1 + API/Scenic.go | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- API/Shop.go | 2 +- API/SystemInfo.go | 8 ++++++-- API/TopMenus.go | 14 ++++++++------ API/User.go | 5 +++-- API/UserLog.go | 1 + Bin/Monitor.go | 9 ++++++++- Config/config.go | 4 ++-- Config/config.json | 4 ++-- DB/db.go | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- Lib/Auth/Auth.go | 6 ++++++ Lib/OperatorLog/operatorLog.go | 4 +++- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- Version.md | 22 ++++++++++++++++++++-- main.go | 4 ++++ 18 files changed, 490 insertions(+), 108 deletions(-) create mode 100644 API/Analysls.go diff --git a/API/Analysls.go b/API/Analysls.go new file mode 100644 index 0000000..6a8960c --- /dev/null +++ b/API/Analysls.go @@ -0,0 +1,34 @@ +package Api + +import ( + "github.com/aarongao/tools" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson" + "letu/DB" +) + +// @Title 数据统计 +// @Description 数据统计 +// @Accept json +// @Produce json +// @Param ScenicId wgergejfwe string true "景区id" +// @Param StartTime 1 int false "时间戳" +// @Param StopTime 1 int false "时间戳" +// @Success 200 {object} tools.ResponseSeccess "userTotal=用户总数registerTotal=注册用户总数nonRegisterTotal非注册用户总数" +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" +// @Router /Analysls/Count? [get] +func Analysls(c *gin.Context) { + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) + c.Header("Access-Control-Allow-Credentials", "true") + + _map := make(map[string]int64) + _map["registerTotal"], _ = DB.CMember.CountDocuments(tools.GetContext(), bson.M{}) + _map["userTotal"], _ = DB.CDevice.CountDocuments(tools.GetContext(), bson.M{}) + _map["nonRegisterTotal"] = _map["userTotal"] - _map["registerTotal"] + + + c.JSON(200, tools.ResponseSeccess{ + 0, + _map, + }) +} diff --git a/API/Complaint.go b/API/Complaint.go index b8417ce..24e585f 100644 --- a/API/Complaint.go +++ b/API/Complaint.go @@ -5,8 +5,10 @@ import ( "github.com/aarongao/tools" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo/options" "letu/DB" + "letu/Lib/Auth" "math" "regexp" "strconv" @@ -64,8 +66,9 @@ func CreateComplaint(c *gin.Context) { var images []string json.Unmarshal([]byte(c.PostForm("Image")), &images) - + objectID := primitive.NewObjectID() DB.CComplaint.InsertOne(tools.GetContext(), DB.SComplaint{ + &objectID, c.PostForm("Type"), c.PostForm("ScenicId"), c.PostForm("Mobile"), @@ -97,12 +100,12 @@ func AllComplaint(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - total, _ := DB.CComplaint.CountDocuments(tools.GetContext(), bson.M{}) - limit, _ := strconv.ParseInt(c.Query("Limit"),10,64) + total, _ := DB.CComplaint.CountDocuments(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) + limit, _ := strconv.ParseInt(c.Query("Limit"), 10, 64) if limit == 0 { limit = 50 } - currPage, _ := strconv.ParseInt(c.Query("Page"),10,64) + currPage, _ := strconv.ParseInt(c.Query("Page"), 10, 64) if currPage == 0 { currPage = 1 } @@ -110,13 +113,13 @@ func AllComplaint(c *gin.Context) { var aComplaint = []bson.M{} - cur, err := DB.CComplaint.Find(tools.GetContext(), bson.M{"ScenicId":c.Query("ScenicId")}, &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()) { var e bson.M cur.Decode(&e) - aComplaint = append(aComplaint,e) + aComplaint = append(aComplaint, e) } } @@ -130,3 +133,43 @@ func AllComplaint(c *gin.Context) { }) } + +// @Title 处理投诉 +// @Description 处理投诉 +// @Accept json +// @Produce json +// @Param id 5dfb03070a9ac17ac7a82054 string true "投诉id" +// @Param ScenicId wgergejfwe 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 /HandleComplaint? [post] +func HandleComplaint(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 + } + objectID, _ := primitive.ObjectIDFromHex(c.PostForm("id")) + _, err = DB.CComplaint.UpdateOne(tools.GetContext(), + bson.M{"_id": objectID}, + bson.M{"$set": bson.M{ + "State": "已处理", + }}, + ) + + c.JSON(200, tools.ResponseSeccess{ + 0, + "ok", + }) + +} diff --git a/API/Operator.go b/API/Operator.go index 9bd7877..6d77925 100644 --- a/API/Operator.go +++ b/API/Operator.go @@ -119,6 +119,7 @@ func UpdateOperator(c *gin.Context) { Password: c.PostForm("Password"), Auth: _auth, Remarks: c.PostForm("Remarks"), + CreateTime:time.Now().Unix(), } _, err := DB.CMember.InsertOne(tools.GetContext(), User) diff --git a/API/Scenic.go b/API/Scenic.go index 9972bd5..58979ac 100644 --- a/API/Scenic.go +++ b/API/Scenic.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "letu/DB" "letu/Lib/Auth" + "strconv" ) // @Title 返回景区基础信息 @@ -16,7 +17,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;RangeLocation景区范围(多个坐标点)" +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点)ZoomForIOS地图的缩放大小(IOS);ZoomForAndroidMin地图的缩放大小(Android最小);ZoomForAndroidMax地图的缩放大小(Android最大);Rotation旋转角度;OpenTiles否开启地图切片;ColorTiles切片底色(#FFFFFF)" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /ScenicInfo? [get] func ScenicInfo(c *gin.Context) { @@ -32,7 +33,7 @@ func ScenicInfo(c *gin.Context) { } var Scenic *DB.SScenic - objID,_ := primitive.ObjectIDFromHex(c.Query("id")) + objID, _ := primitive.ObjectIDFromHex(c.Query("id")) DB.CScenic.FindOne(tools.GetContext(), bson.M{"_id": objID}).Decode(&Scenic) c.JSON(200, tools.ResponseSeccess{ @@ -48,7 +49,7 @@ func ScenicInfo(c *gin.Context) { // @Produce json // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" // @Param Token wgergejfwe string true "用户token" -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点)" +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /UpdateScenic? [post] func UpdateScenic(c *gin.Context) { @@ -57,6 +58,7 @@ func UpdateScenic(c *gin.Context) { _user, _ := c.Get("UserInfo") user := _user.(*DB.SMember) + err := Auth.CheckScenicAuth(c.PostForm("id"), user) if err != nil { c.JSON(200, tools.ResponseError{ @@ -66,13 +68,6 @@ func UpdateScenic(c *gin.Context) { return } - - 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) @@ -90,22 +85,27 @@ func UpdateScenic(c *gin.Context) { var id primitive.ObjectID if pid := c.PostForm("id"); pid == "null" { + + if user.UserType != "root" { + c.JSON(200, tools.ResponseError{ + 401, + "没有权限", + }) + return + } id = primitive.NewObjectID() // 新景区,初始化 initScenic(id.Hex()) } else { - id,_ = primitive.ObjectIDFromHex(pid) + id, _ = primitive.ObjectIDFromHex(pid) } - upsert := true DB.CScenic.FindOneAndUpdate(tools.GetContext(), bson.M{"_id": id}, bson.M{"$set": bson.M{ "Name": c.PostForm("Name"), "Describe": c.PostForm("Describe"), - "Location": Location, - "RangeLocation": RangeLocation, "OpenHours": c.PostForm("OpenHours"), "Mobile": c.PostForm("Mobile"), "Address": c.PostForm("Address"), @@ -124,39 +124,205 @@ func UpdateScenic(c *gin.Context) { 0, "ok", }) +} + +// @Title 更新景区基础信息-高级 +// @Description 更新景区基础信息-高级 +// @Accept json +// @Produce json +// @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" +// @Param Token wgergejfwe string true "用户token" +// @Success 200 {object} tools.ResponseSeccess "RangeLocation景区范围(多个坐标点)ZoomForIOS地图的缩放大小(IOS);ZoomForAndroidMin地图的缩放大小(Android最小);ZoomForAndroidMax地图的缩放大小(Android最大);Rotation旋转角度;OpenTiles否开启地图切片;ColorTiles切片底色(#FFFFFF)" +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" +// @Router /UpdateScenicSenior? [post] +func UpdateScenicSenior(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("id"), user) + if err != nil { + c.JSON(200, tools.ResponseError{ + 401, + "没有权限", + }) + return + } + + var Location DB.SLocation + json.Unmarshal([]byte(c.PostForm("Location")), &Location) + + var RangeLocation []DB.SLocation + json.Unmarshal([]byte(c.PostForm("RangeLocation")), &RangeLocation) + + var ZoomForIOS DB.SRange + json.Unmarshal([]byte(c.PostForm("ZoomForIOS")), &ZoomForIOS) + + var ZoomForAndroidMin []DB.SLocation + json.Unmarshal([]byte(c.PostForm("ZoomForAndroidMin")), &ZoomForAndroidMin) + + var ZoomForAndroidMax []DB.SLocation + json.Unmarshal([]byte(c.PostForm("ZoomForAndroidMax")), &ZoomForAndroidMax) + + var id primitive.ObjectID + if pid := c.PostForm("id"); pid == "null" { + + if user.UserType != "root" { + c.JSON(200, tools.ResponseError{ + 401, + "没有权限", + }) + return + } + id = primitive.NewObjectID() + // 新景区,初始化 + initScenic(id.Hex()) + } else { + id, _ = primitive.ObjectIDFromHex(pid) + } + + Rotation, err := strconv.ParseFloat(c.PostForm("Rotation"), 64) + OpenTiles, err := strconv.ParseBool(c.PostForm("OpenTiles")) + Display, _ := strconv.ParseBool(c.PostForm("Display")) + upsert := true + DB.CScenic.FindOneAndUpdate(tools.GetContext(), + bson.M{"_id": id}, + bson.M{"$set": bson.M{ + "Location": Location, + "RangeLocation": RangeLocation, + "ZoomForIOS": ZoomForIOS, + "ZoomForAndroidMin": ZoomForAndroidMin, + "ZoomForAndroidMax": ZoomForAndroidMax, + "Rotation": Rotation, + "OpenTiles": OpenTiles, + "ColorTiles": c.PostForm("ColorTiles"), + "Display": Display, + "Remove": false, + }}, &options.FindOneAndUpdateOptions{ + Upsert: &upsert, + }, + ) + c.JSON(200, tools.ResponseSeccess{ + 0, + "ok", + }) } func initScenic(id string) { var dba []interface{} - dba = append(dba,DB.STag{ + dba = append(dba, DB.STag{ id, "type", "服务设施", }) - dba = append(dba,DB.STag{ + dba = append(dba, DB.STag{ id, "type", - "游乐设施", + "普通", }) - dba = append(dba,DB.STag{ + dba = append(dba, DB.STag{ id, "type", - "餐饮", + "演出", }) - dba = append(dba,DB.STag{ + dba = append(dba, DB.STag{ id, "type", "购物", }) - DB.CTags.InsertMany(tools.GetContext(),dba[1:]) + dba = append(dba, DB.STag{ + id, + "type", + "餐饮", + }) + dba = append(dba, DB.STag{ + id, + "type", + "游乐设施", + }) + + dba = append(dba, DB.STag{ + id, + "age", + "儿童", + }) + dba = append(dba, DB.STag{ + id, + "age", + "成人", + }) + dba = append(dba, DB.STag{ + id, + "age", + "青少年", + }) + + dba = append(dba, DB.STag{ + id, + "food", + "海鲜", + }) + dba = append(dba, DB.STag{ + id, + "food", + "团餐", + }) + dba = append(dba, DB.STag{ + id, + "food", + "烧烤", + }) + dba = append(dba, DB.STag{ + id, + "food", + "小吃", + }) + + dba = append(dba, DB.STag{ + id, + "recommend", + "必玩", + }) + + dba = append(dba, DB.STag{ + id, + "shop", + "纪念品", + }) + dba = append(dba, DB.STag{ + id, + "shop", + "收藏品", + }) + dba = append(dba, DB.STag{ + id, + "shop", + "玩具", + }) + + dba = append(dba, DB.STag{ + id, + "thrilling", + "刺激", + }) + dba = append(dba, DB.STag{ + id, + "thrilling", + "放松", + }) + + DB.CTags.InsertMany(tools.GetContext(), dba[1:]) } // @Title 所有景区基础信息 // @Description 所有景区基础信息 // @Accept json // @Produce json +// @Param Display true string true "true=显示隐藏数据" // @Success 200 {object} tools.ResponseSeccess "" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /AllScenic? [get] @@ -164,14 +330,19 @@ func AllScenic(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") + _select := bson.M{"Display": true} + if c.Query("Display") == "all"{ + _select = bson.M{} + } + var Scenic []DB.SScenic - cur, err := DB.CScenic.Find(tools.GetContext(), bson.M{}) + cur, err := DB.CScenic.Find(tools.GetContext(), _select) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { var e DB.SScenic cur.Decode(&e) - Scenic = append(Scenic,e) + Scenic = append(Scenic, e) } } diff --git a/API/Shop.go b/API/Shop.go index f585b0c..b1f11e6 100644 --- a/API/Shop.go +++ b/API/Shop.go @@ -54,7 +54,7 @@ func AllCommodity(c *gin.Context) { c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) c.Header("Access-Control-Allow-Credentials", "true") - var aCommoditys []DB.SCommodity + var aCommoditys = []DB.SCommodity{} cur, err := DB.CCommodity.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) defer cur.Close(tools.GetContext()) if err == nil { diff --git a/API/SystemInfo.go b/API/SystemInfo.go index b83c238..c4544bc 100644 --- a/API/SystemInfo.go +++ b/API/SystemInfo.go @@ -19,9 +19,13 @@ func SystemInfo(c *gin.Context) { c.Header("Access-Control-Allow-Credentials", "true") info := make(map[string]interface{}) - info["Version"] = Config.Info.Version + info["ApiVersion"] = Config.Info.ApiVersion + info["SupportVersion"] = Config.Info.SupportVersion + //SupportVersion := DB.Redis.Get("SupportVersion") + //info["SupportVersion"] = SupportVersion + UpdateLocationInterval := DB.Redis.Get("UpdateLocationInterval") info["UpdateLocationInterval"] = UpdateLocationInterval @@ -30,4 +34,4 @@ func SystemInfo(c *gin.Context) { info, }) -} +} \ No newline at end of file diff --git a/API/TopMenus.go b/API/TopMenus.go index 5c894a5..92511eb 100644 --- a/API/TopMenus.go +++ b/API/TopMenus.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "letu/DB" "letu/Lib/Auth" + "strconv" ) // @Title 查询所有菜单 @@ -25,13 +26,13 @@ func AllTopMenus(c *gin.Context) { c.Header("Access-Control-Allow-Credentials", "true") var STopMenus []DB.STopMenus - cur, err := DB.CTopMenus.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) + cur, err := DB.CTopMenus.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}, &options.FindOptions{Sort: bson.M{"Order": 1}}) defer cur.Close(tools.GetContext()) if err == nil { for cur.Next(tools.GetContext()) { var e DB.STopMenus cur.Decode(&e) - STopMenus = append(STopMenus,e) + STopMenus = append(STopMenus, e) } } @@ -59,7 +60,6 @@ func UpdateTopMenus(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) @@ -86,15 +86,17 @@ func UpdateTopMenus(c *gin.Context) { if pid := c.PostForm("id"); pid == "null" { id = primitive.NewObjectID() } else { - id,_ = primitive.ObjectIDFromHex(pid) + id, _ = primitive.ObjectIDFromHex(pid) } + Order, err := strconv.ParseFloat(c.PostForm("Order"), 64) upsert := true DB.CTopMenus.FindOneAndUpdate(tools.GetContext(), bson.M{"_id": id}, bson.M{"$set": bson.M{ "ScenicId": c.PostForm("ScenicId"), - "Name": c.PostForm("Name"), + "Name": c.PostForm("Name"), + "Order": Order, "Tags": Tags, }}, &options.FindOneAndUpdateOptions{ Upsert: &upsert, @@ -151,4 +153,4 @@ func RemoveTopMenus(c *gin.Context) { "ok", }) -} \ No newline at end of file +} diff --git a/API/User.go b/API/User.go index 0f9d8fc..0c2f2fc 100644 --- a/API/User.go +++ b/API/User.go @@ -79,8 +79,10 @@ func LoginUser(c *gin.Context) { c.Request.Header.Get("AppVersion"), c.Request.Header.Get("AppVersion"), c.Request.Header.Get("DeviceToken"), + time.Now().Unix(), }, - Auth: auth, + Auth: auth, + CreateTime: time.Now().Unix(), } _, err := DB.CMember.InsertOne(tools.GetContext(), User) if err != nil { @@ -350,7 +352,6 @@ func RemoveUser(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) diff --git a/API/UserLog.go b/API/UserLog.go index 304d102..9f800d6 100644 --- a/API/UserLog.go +++ b/API/UserLog.go @@ -69,6 +69,7 @@ func UserLog(c *gin.Context) { c.Request.Header.Get("AppVersion"), c.Request.Header.Get("AppVersion"), c.Request.Header.Get("DeviceToken"), + time.Now().Unix(), }, }) diff --git a/Bin/Monitor.go b/Bin/Monitor.go index f2cb398..882fff2 100644 --- a/Bin/Monitor.go +++ b/Bin/Monitor.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/aarongao/tools" "github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi" + "github.com/davecgh/go-spew/spew" "time" ) @@ -12,7 +13,7 @@ var lastState = 0 func main() { for { - time.Sleep(180 * time.Second) + time.Sleep(600 * time.Second) httpState, body, error := tools.GET("http://leyoutu.st-i.com.cn/AllScenic") if httpState == 200 && error == nil { @@ -22,11 +23,16 @@ func main() { rlen := len(oBody.Result.([]interface{})) if oBody.ErrCode != 0 || rlen == 0 { sms(1) + + println("ERROR---------------------1:",rlen) + spew.Dump(oBody) } else { sms(2) } } else { + println("ERROR---------------------2:",httpState) + spew.Dump(error) sms(1) } @@ -34,6 +40,7 @@ func main() { } + func sms(state int) { stateString := "" diff --git a/Config/config.go b/Config/config.go index 669eccc..b2f213a 100644 --- a/Config/config.go +++ b/Config/config.go @@ -10,8 +10,8 @@ type Config struct { Env string TokenSecret string ServerPort string - Version int64 - SupportVersion int64 + ApiVersion string + SupportVersion string } var Info = Config{} diff --git a/Config/config.json b/Config/config.json index f68cd1b..9ffd450 100644 --- a/Config/config.json +++ b/Config/config.json @@ -8,6 +8,6 @@ "Env": "DEV", "tokenSecret": "token.secret", "ServerPort": ":8080", - "Version": 1.1, - "SupportVersion": 1.0 + "ApiVersion": "1.1", + "SupportVersion": "1.0" } diff --git a/DB/db.go b/DB/db.go index d0d9d66..95e0435 100644 --- a/DB/db.go +++ b/DB/db.go @@ -27,6 +27,31 @@ var CTopMenus *mongo.Collection //菜单 var CSysAds *mongo.Collection //平台广告 var DB *mongo.Database +type SScenic struct { + Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` + Name string `bson:"Name" json:"Name" valid:"required"` + Describe string `bson:"Describe" json:"Describe"` + OpenHours string `bson:"OpenHours" json:"OpenHours"` //营业时间 + Mobile string `bson:"Mobile" json:"Mobile"` + Address string `bson:"Address" json:"Address"` + InvestigationUrl string `bson:"InvestigationUrl" json:"InvestigationUrl"` //问券调查的url地址 + Location SLocation `bson:"Location" json:"Location"` + Picture []SPicture `bson:"Picture" json:"Picture"` + ShopAdPicture []SPicture `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 + ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 + ActivityPicture []SPicture `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 + VideoList []SVideo `bson:"VideoList" json:"VideoList"` + RangeLocation []SLocation `bson:"RangeLocation" json:"RangeLocation"` //景区范围 + ZoomForIOS SRange `bson:"ZoomForIOS" json:"ZoomForIOS"` //地图的缩放大小(IOS) + ZoomForAndroidMin []SLocation `bson:"ZoomForAndroidMin" json:"ZoomForAndroidMin"` //地图的缩放大小(Android最小) + ZoomForAndroidMax []SLocation `bson:"ZoomForAndroidMax" json:"ZoomForAndroidMax"` //地图的缩放大小(Android最大) + Rotation float64 `bson:"Rotation" json:"Rotation"` //旋转角度 + OpenTiles bool `bson:"OpenTiles" json:"OpenTiles"` //否开启地图切片 + ColorTiles string `bson:"ColorTiles" json:"ColorTiles"` //切片底色(#FFFFFF) + Display bool `bson:"Display" json:"Display"` //是否显示 + Remove bool `bson:"Remove" json:"Remove"` //是否删除 +} + type SItem struct { Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` ScenicId string `bson:"ScenicId" json:"ScenicId"` // 景区id @@ -83,19 +108,21 @@ type SLocation struct { type STopMenus struct { Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` - Name string `bson:"Name" json:"Name" valid:"required"` //菜单标题 - Tags []string `bson:"Tags" json:"Tags" valid:"required"` //标签 + Name string `bson:"Name" json:"Name" valid:"required"` //菜单标题 + Tags []string `bson:"Tags" json:"Tags" valid:"required"` //标签 + Order int64 `bson:"Order" json:"Order" valid:"required"` //排序 } type SDevice struct { DeviceId string `bson:"DeviceId" json:"DeviceId"` Mac string `bson:"Mac" json:"Mac"` UDID string `bson:"UDID" json:"UDID"` - SystemType string `bson:"SystemType" json:"SystemType"` //ios,android - SystemVersion string `bson:"SystemVersion" json:"SystemVersion"` //系统版本 - SystemModel string `bson:"SystemModel" json:"SystemModel"` //机型 - AppVersion string `bson:"AppVersion" json:"AppVersion"` //app版本 - DeviceToken string `bson:"DeviceToken" json:"DeviceToken"` //用于推送的token + SystemType string `bson:"SystemType" json:"SystemType"` //ios,android + SystemVersion string `bson:"SystemVersion" json:"SystemVersion"` //系统版本 + SystemModel string `bson:"SystemModel" json:"SystemModel"` //机型 + AppVersion string `bson:"AppVersion" json:"AppVersion"` //app版本 + DeviceToken string `bson:"DeviceToken" json:"DeviceToken"` //用于推送的token + CreateTime int64 `bson:"CreateTime,omitempty" json:"CreateTime"` //创建时间 } type SUserLog struct { @@ -113,14 +140,15 @@ type SUserLog struct { } type SOperatorLog struct { - ScenicId string `bson:"ScenicId" json:"ScenicId"` - UserId string `bson:"UserId" json:"UserId"` // 用户ID - UserName string `bson:"UserName" json:"UserName"` //用户名称 - DateTime int64 `bson:"DateTime" json:"DateTime"` //时间戳 - Remarks string `bson:"Remarks" json:"Remarks"` //备注 - Model SModel `bson:"Model" json:"Model"` - Api string `bson:"Api" json:"Api"` - Parames interface{} `bson:"Parames" json:"Parames"` + Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` + ScenicId string `bson:"ScenicId" json:"ScenicId"` + UserId string `bson:"UserId" json:"UserId"` // 用户ID + UserName string `bson:"UserName" json:"UserName"` //用户名称 + DateTime int64 `bson:"DateTime" json:"DateTime"` //时间戳 + Remarks string `bson:"Remarks" json:"Remarks"` //备注 + Model SModel `bson:"Model" json:"Model"` + Api string `bson:"Api" json:"Api"` + Parames interface{} `bson:"Parames" json:"Parames"` } type SSystemLog struct { UserId string `bson:"UserId" json:"UserId"` // 用户ID @@ -156,15 +184,16 @@ type SLine struct { } type SComplaint struct { - Type string `bson:"Type" json:"Type"` - ScenicId string `bson:"ScenicId" json:"ScenicId"` // 景区id - Mobile string `bson:"Mobile" json:"Mobile"` - FullName string `bson:"FullName" json:"FullName"` - Sex string `bson:"Sex" json:"Sex"` - Content string `bson:"Content" json:"Content"` - Image []string `bson:"Image" json:"Image"` - State string `bson:"State" json:"State"` // 处理状态(未处理,已处理) - DateTime int64 `bson:"DateTime" json:"DateTime"` //时间戳 + Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` + Type string `bson:"Type" json:"Type"` + ScenicId string `bson:"ScenicId" json:"ScenicId"` // 景区id + Mobile string `bson:"Mobile" json:"Mobile"` + FullName string `bson:"FullName" json:"FullName"` + Sex string `bson:"Sex" json:"Sex"` + Content string `bson:"Content" json:"Content"` + Image []string `bson:"Image" json:"Image"` + State string `bson:"State" json:"State"` // 处理状态(未处理,已处理) + DateTime int64 `bson:"DateTime" json:"DateTime"` //时间戳 } type SInvestigation struct { @@ -173,20 +202,21 @@ type SInvestigation struct { Data interface{} `bson:"Data" json:"Data"` } type SMember struct { - Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` - UserType string `bson:"UserType" json:"UserType" valid:"required,in(root|operator|visitor)"` // "root" or "operator" or "visitor" - ScenicId string `bson:"ScenicId,omitempty" json:"ScenicId,omitempty"` - Username string `bson:"Username,omitempty" json:"Username,omitempty"` - Password string `bson:"Password,omitempty" json:"Password,omitempty"` - Birthday string `bson:"Birthday,omitempty" json:"Birthday"` - FullName string `bson:"FullName,omitempty" json:"FullName"` - Mobile string `bson:"Mobile,omitempty" json:"Mobile"` - Openid string `bson:"Openid,omitempty" json:"Openid"` - Token string `bson:"Token,omitempty" json:"Token,omitempty"` - Sex string `bson:"Sex,omitempty" json:"Sex"` - Device *SDevice `bson:"Device,omitempty" json:"Device"` //设备信息 - Auth []string `bson:"Auth,omitempty" json:"Auth"` //权限信息 - Remarks string `bson:"Remarks,omitempty" json:"Remarks"` //说明 + Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` + UserType string `bson:"UserType" json:"UserType" valid:"required,in(root|operator|visitor)"` // "root" or "operator" or "visitor" + ScenicId string `bson:"ScenicId,omitempty" json:"ScenicId,omitempty"` + Username string `bson:"Username,omitempty" json:"Username,omitempty"` + Password string `bson:"Password,omitempty" json:"Password,omitempty"` + Birthday string `bson:"Birthday,omitempty" json:"Birthday"` + FullName string `bson:"FullName,omitempty" json:"FullName"` + Mobile string `bson:"Mobile,omitempty" json:"Mobile"` + Openid string `bson:"Openid,omitempty" json:"Openid"` + Token string `bson:"Token,omitempty" json:"Token,omitempty"` + Sex string `bson:"Sex,omitempty" json:"Sex"` + Device *SDevice `bson:"Device,omitempty" json:"Device"` //设备信息 + Auth []string `bson:"Auth,omitempty" json:"Auth"` //权限信息 + Remarks string `bson:"Remarks,omitempty" json:"Remarks"` //说明 + CreateTime int64 `bson:"CreateTime,omitempty" json:"CreateTime"` //创建时间 } type STag struct { @@ -209,27 +239,15 @@ type SSize struct { Width int64 `bson:"Width" json:"Width"` Height int64 `bson:"Height" json:"Height"` } +type SRange struct { + Min float64 `bson:"Min" json:"Min"` + Max float64 `bson:"Max" json:"Max"` +} type SSysAds struct { Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` - Site string `bson:"Site" json:"Site" valid:"required"` // 位置 - Size SSize `bson:"Size" json:"Size" valid:"required"` // 尺寸 + Site string `bson:"Site" json:"Site" valid:"required"` // 位置 + Size SSize `bson:"Size" json:"Size" valid:"required"` // 尺寸 Type string `bson:"Type" json:"Type" valid:"required,in(轮播|单图|单视频)"` // 类型 - Picture []SPicture `bson:"Picture" json:"Picture"` // 图片 - Video []SVideo `bson:"Video" json:"Video"` // 视频 -} -type SScenic struct { - Id *primitive.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"` //营业时间 - Mobile string `bson:"Mobile" json:"Mobile"` - Address string `bson:"Address" json:"Address"` - InvestigationUrl string `bson:"InvestigationUrl" json:"InvestigationUrl"` //问券调查的url地址 - Location SLocation `bson:"Location" json:"Location"` - Picture []SPicture `bson:"Picture" json:"Picture"` - ShopAdPicture []SPicture `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 - ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 - ActivityPicture []SPicture `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 - VideoList []SVideo `bson:"VideoList" json:"VideoList"` - RangeLocation []SLocation `bson:"RangeLocation" json:"RangeLocation"` //景区范围 + Picture []SPicture `bson:"Picture" json:"Picture"` // 图片 + Video []SVideo `bson:"Video" json:"Video"` // 视频 } diff --git a/Lib/Auth/Auth.go b/Lib/Auth/Auth.go index d8d2996..f95f53e 100644 --- a/Lib/Auth/Auth.go +++ b/Lib/Auth/Auth.go @@ -102,6 +102,9 @@ func CheckAuthFunc(handFunc func(c *gin.Context), auth *DB.SModel) func(c *gin.C func CheckScenicAuth(ScenicId string, user *DB.SMember) error { + if user.UserType == "root" { + return nil + } if ScenicId == "" { return errors.New("景区id不能为空") } @@ -121,6 +124,9 @@ func CheckScenicAuth(ScenicId string, user *DB.SMember) error { func CheckUserAuth(UserId string, user *DB.SMember) error { + if user.UserType == "root" { + return nil + } if UserId == "" { return errors.New("用户id不能为空") } diff --git a/Lib/OperatorLog/operatorLog.go b/Lib/OperatorLog/operatorLog.go index 859c9f6..0c4a42f 100644 --- a/Lib/OperatorLog/operatorLog.go +++ b/Lib/OperatorLog/operatorLog.go @@ -2,13 +2,15 @@ package OperatorLog import ( "github.com/aarongao/tools" + "go.mongodb.org/mongo-driver/bson/primitive" "letu/DB" "time" ) func CreateOperatorLog(ScenicId string, user *DB.SMember, model *DB.SModel, api string, parames interface{}) { - + id := primitive.NewObjectID() DB.COperatorLog.InsertOne(tools.GetContext(), DB.SOperatorLog{ + &id, ScenicId, user.Id.Hex(), user.Username, diff --git a/README.md b/README.md index 5dbd49d..3a67bea 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,14 @@ 1. [标签 - 所有标签](#alltag-get) 1. [标签 - 按照标签分组查看所有标签](#alltaggroup-get) 1. [查询所有用户行为](#alluserlog-get) +1. [数据统计](#analysls-count-get) 1. [用户管理 - 检查Token是否过期](#checktoken-post) 1. [查询商品信息](#commodityinfo-get) 1. [投诉 - 增加投诉](#createcomplaint-post) 1. [查询用户的定时提醒](#dealymessage-info-get) 1. [创建提醒](#dealymessage-create-post) 1. [删除提醒](#dealymessage-remove-post) +1. [处理投诉](#handlecomplaint-post) 1. [图标管理 - 返回图标基础信息](#icon-info-get) 1. [图标管理 - 增加或修改图标信息](#icon-update-post) 1. [图标管理 - 所有图标](#icon-all-get) @@ -59,6 +61,7 @@ 1. [更新线路](#updateline-post) 1. [操作员管理 - 修改用户信息](#updateoperator-post) 1. [更新景区基础信息](#updatescenic-post) +1. [更新景区基础信息-高级](#updatescenicsenior-post) 1. [用户管理 - 修改用户信息](#updateuser-post) 1. [上传](#upload-post) 1. [用户管理 - 获取用户信息](#userinfo-get) @@ -204,6 +207,11 @@ 所有景区基础信息 +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| Display | true | string | true=显示隐藏数据 | Yes | + + | Code | Type | Model | Message | |-----|-----|-----|-----| | 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | | @@ -269,6 +277,27 @@ + + +#### /Analysls/Count (GET) + + +数据统计 + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| ScenicId | wgergejfwe | string | 景区id | Yes | +| StartTime | 1 | int | 时间戳 | | +| StopTime | 1 | int | 时间戳 | | + + +| Code | Type | Model | Message | +|-----|-----|-----|-----| +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | userTotal=用户总数registerTotal=注册用户总数nonRegisterTotal非注册用户总数 | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | + + + #### /CheckToken (POST) @@ -396,6 +425,27 @@ + + +#### /HandleComplaint (POST) + + +处理投诉 + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| id | 5dfb03070a9ac17ac7a82054 | string | 投诉id | Yes | +| ScenicId | wgergejfwe | 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":"错误原因"} | + + + #### /Icon/Info (GET) @@ -739,7 +789,7 @@ | Code | Type | Model | Message | |-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点) | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点)ZoomForIOS地图的缩放大小(IOS);ZoomForAndroidMin地图的缩放大小(Android最小);ZoomForAndroidMax地图的缩放大小(Android最大);Rotation旋转角度;OpenTiles否开启地图切片;ColorTiles切片底色(#FFFFFF) | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | @@ -1079,7 +1129,27 @@ | Code | Type | Model | Message | |-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点) | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url; | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | + + + + + +#### /UpdateScenicSenior (POST) + + +更新景区基础信息-高级 + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| id | 5dfb03070a9ac17ac7a82054 | string | 景区id | Yes | +| Token | wgergejfwe | string | 用户token | Yes | + + +| Code | Type | Model | Message | +|-----|-----|-----|-----| +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | RangeLocation景区范围(多个坐标点)ZoomForIOS地图的缩放大小(IOS);ZoomForAndroidMin地图的缩放大小(Android最小);ZoomForAndroidMax地图的缩放大小(Android最大);Rotation旋转角度;OpenTiles否开启地图切片;ColorTiles切片底色(#FFFFFF) | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | diff --git a/Version.md b/Version.md index 86a70ba..71e0a5d 100644 --- a/Version.md +++ b/Version.md @@ -66,13 +66,24 @@ } ``` - +12. /ScenicInfo景区信息接口增加新属性 + + ``` + ZoomForIOS //地图的缩放大小(IOS) + ZoomForAndroidMin //地图的缩放大小(Android最小) + ZoomForAndroidMax //地图的缩放大小(Android最大) + Rotation //旋转角度 + OpenTiles //否开启地图切片 + ColorTiles //切片底色(FFFFFF) + ``` + +13. /AllScenic增加Display=all参数。意思是显示所有数据,默认情况不显示隐藏信息 ##### 数据结构变更: -1、标签表 +1、标签表、设施信息中的所属标签 2、平台广告表初始数据 @@ -93,6 +104,13 @@ 1. 提交APP代码到git(v1.1分支) 2. 使用 “测试环境地址” 打包内测版本至TestFlight 3. 升级 ”生产环境“ 接口至v1.1 + 1. 打包上传程序文件main_v1.1 + 2. 修改config.json配置文件 + 3. 运行程序 + 4. nginx增加/api/v1.1路径支持 + 5. 上传后台页面 + 6. 更新root用户模块权限数据 + 7. 修改数据结构变更及数据缺失(广告,标签等。。) 4. 使用 “生产环境地址” 打包公测版本至TestFlight 5. 发布至商店 diff --git a/main.go b/main.go index 595b4d1..381998c 100644 --- a/main.go +++ b/main.go @@ -120,6 +120,7 @@ func main() { InitController("GET", "/ItemInfo", Api.ItemInfo, &DB.SModel{}) InitController("GET", "/CommodityInfo", Api.CommodityInfo, &DB.SModel{}) InitController("POST", "/CreateComplaint", Api.CreateComplaint, &DB.SModel{}) + InitController("POST", "/HandleComplaint", Api.HandleComplaint, &DB.SModel{"投诉建议", "处理投诉"}) InitController("GET", "/AllComplaint", Api.AllComplaint, &DB.SModel{"投诉建议", "查看所有"}) //InitController("/CreateUser", Api.CreateUser) InitController("POST", "/LoginUser", Api.LoginUser, &DB.SModel{}) @@ -137,6 +138,7 @@ func main() { InitController("POST", "/UpdateCommodity", Api.UpdateCommodity, &DB.SModel{"商品管理", "修改"}) InitController("POST", "/UpdateLine", Api.UpdateLine, &DB.SModel{"线路管理", "修改"}) InitController("POST", "/UpdateScenic", Api.UpdateScenic, &DB.SModel{"景区管理", "修改"}) + InitController("POST", "/UpdateScenicSenior", Api.UpdateScenicSenior, &DB.SModel{"景区管理", "修改-高级"}) InitController("POST", "/UpdateItemTime", Api.UpdateItemTime, &DB.SModel{"项目管理", "修改等候时间"}) InitController("GET", "/AllScenic", Api.AllScenic, &DB.SModel{}) InitController("POST", "/UserLog", Api.UserLog, &DB.SModel{}) @@ -178,6 +180,8 @@ func main() { InitController("GET", "/SysAds/List", Api.SysAdsList, &DB.SModel{}) InitController("POST", "/SysAds/Modify", Api.ModifySysAds, &DB.SModel{"平台广告", "修改"}) + InitController("GET", "/Analysls/Count", Api.Analysls, &DB.SModel{"平台数据统计","查询"}) + Gin.GET("/AllModules", Auth.Modules) //InitController("/ws", Api.WsPage) -- libgit2 0.21.0