diff --git a/API/Item.go b/API/Item.go index b1c6095..c397afd 100644 --- a/API/Item.go +++ b/API/Item.go @@ -39,6 +39,9 @@ func ItemInfo(c *gin.Context) { objID, _ := primitive.ObjectIDFromHex(c.Query("id")) DB.CItem.FindOne(tools.GetContext(), bson.M{"_id": objID}).Decode(&SItem) + if SItem.ReminderInterval == nil{ + SItem.ReminderInterval = []string{} + } c.JSON(200, tools.ResponseSeccess{ 0, SItem, @@ -115,7 +118,10 @@ func UpdateItem(c *gin.Context) { var CustomAttribute []DB.SCustomAttribute json.Unmarshal([]byte(c.PostForm("CustomAttribute")), &CustomAttribute) - var ReminderInterval = strings.Split(c.PostForm("ReminderInterval"),",") + var ReminderInterval = []string{} + if c.PostForm("ReminderInterval") != "" { + ReminderInterval = strings.Split(c.PostForm("ReminderInterval"),",") + } var id primitive.ObjectID if pid := c.PostForm("id"); pid == "null" { diff --git a/API/Tag.go b/API/Tag.go index 4f770b8..ed914e7 100644 --- a/API/Tag.go +++ b/API/Tag.go @@ -39,12 +39,10 @@ func AllTag(c *gin.Context) { for cur.Next(tools.GetContext()) { var e DB.STag cur.Decode(&e) - Stags = append(Stags,e) + Stags = append(Stags, e) } } - - if Stags == nil { Stags = []DB.STag{} } @@ -94,7 +92,7 @@ func AllTagGroup(c *gin.Context) { for cur.Next(tools.GetContext()) { var e DB.STag cur.Decode(&e) - Stags = append(Stags,e) + Stags = append(Stags, e) } } @@ -103,15 +101,17 @@ func AllTagGroup(c *gin.Context) { } Group := make(map[string][]string) + GroupName := make(map[string]string) // 去重 for _, v := range Stags { Group[v.Type] = append(Group[v.Type], v.Name) + GroupName[v.Type] = v.TypeAlias } // 转为数组 aGroup := []Tag{} for k, v := range Group { - aGroup = append(aGroup, Tag{k, v}) + aGroup = append(aGroup, Tag{k, GroupName[k],v}) } DB.Redis.Set("Tags_"+ScenicId, aGroup, time.Second*3600*24) @@ -122,8 +122,6 @@ func AllTagGroup(c *gin.Context) { } - - // @Title 标签 // @Description 标签 - 增加标签 // @Accept json @@ -158,7 +156,6 @@ func CreateTag(c *gin.Context) { return } - if c.PostForm("TagGroup") == "" { c.JSON(200, tools.ResponseError{ 1, @@ -167,7 +164,6 @@ func CreateTag(c *gin.Context) { return } - if c.PostForm("TagGroup") == "type" { c.JSON(200, tools.ResponseError{ 1, @@ -176,7 +172,7 @@ func CreateTag(c *gin.Context) { return } - DB.CTags.InsertOne(tools.GetContext(),DB.STag{ + DB.CTags.InsertOne(tools.GetContext(), DB.STag{ c.PostForm("ScenicId"), c.PostForm("TagGroup"), c.PostForm("TypeAlias"), @@ -192,9 +188,6 @@ func CreateTag(c *gin.Context) { }) } - - - // @Title 标签 // @Description 标签 - 删除标签 // @Accept json @@ -229,7 +222,6 @@ func RemoveTag(c *gin.Context) { return } - if c.PostForm("TagGroup") == "" { c.JSON(200, tools.ResponseError{ 1, @@ -238,7 +230,6 @@ func RemoveTag(c *gin.Context) { return } - if c.PostForm("TagGroup") == "type" { c.JSON(200, tools.ResponseError{ 1, @@ -247,7 +238,7 @@ func RemoveTag(c *gin.Context) { return } - DB.CTags.DeleteOne(tools.GetContext(), bson.M{"ScenicId": c.PostForm("ScenicId"),"Name":c.PostForm("TagName"),"Type":c.PostForm("TagGroup")}) + DB.CTags.DeleteOne(tools.GetContext(), bson.M{"ScenicId": c.PostForm("ScenicId"), "Name": c.PostForm("TagName"), "Type": c.PostForm("TagGroup")}) DB.Redis.Delete("Tags_" + c.PostForm("ScenicId")) println("清楚缓存Tags") @@ -258,8 +249,8 @@ func RemoveTag(c *gin.Context) { }) } - type Tag struct { - Type string - Tags []string + Type string + TypeAlias string + Tags []string } diff --git a/Bin/Monitor.go b/Bin/Monitor.go index 882fff2..4a1b998 100644 --- a/Bin/Monitor.go +++ b/Bin/Monitor.go @@ -14,7 +14,7 @@ func main() { for { time.Sleep(600 * time.Second) - httpState, body, error := tools.GET("http://leyoutu.st-i.com.cn/AllScenic") + httpState, body, error := tools.GET("http://leyoutu.st-i.com.cn/api/v1.1/AllScenic") if httpState == 200 && error == nil { oBody := tools.ResponseSeccess{} diff --git a/DB/db.go b/DB/db.go index dd78811..118845c 100644 --- a/DB/db.go +++ b/DB/db.go @@ -53,30 +53,30 @@ type SScenic struct { } type SItem struct { - Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` - ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` // 景区id - Name string `bson:"Name" json:"Name" valid:"required"` - SubName string `bson:"SubName,omitempty" json:"SubName"` - Location SLocation `bson:"Location" json:"Location" valid:"required"` - Tags []STag `bson:"Tags" json:"Tags"` - Icon string `bson:"Icon" json:"Icon" valid:"required"` - LimitHeight string `bson:"LimitHeight,omitempty" json:"LimitHeight"` //限高 - PlayDuration string `bson:"PlayDuration,omitempty" json:"PlayDuration"` //游玩时长 - SceneTime string `bson:"SceneTime,omitempty" json:"SceneTime"` //场次时间 - Picture []string `bson:"Picture,omitempty" json:"Picture"` - Voice string `bson:"Voice,omitempty" json:"Voice"` //音频 - Tel string `bson:"Tel,omitempty" json:"Tel"` - AverageConsumption string `bson:"AverageConsumption,omitempty" json:"AverageConsumption"` //人均消费 - Menu string `bson:"Menu,omitempty" json:"Menu"` //目录 - Time string `bson:"Time,omitempty" json:"Time"` - OpenHours string `bson:"OpenHours,omitempty" json:"OpenHours"` //开放时间 - LocationDescription string `bson:"LocationDescription,omitempty" json:"LocationDescription"` //位置描述 - Reminder string `bson:"Reminder,omitempty" json:"Reminder"` //温馨提示 - State int `bson:"State,omitempty" json:"State"` // 运行状态0=正常1=停运 - CustomAttribute []SCustomAttribute `bson:"CustomAttribute" json:"CustomAttribute"` // 自定义属性 - WaitingTimeDisplay bool `bson:"WaitingTimeDisplay" json:"WaitingTimeDisplay"` //是否有等待时间显示 - ReminderInterval []string `bson:"ReminderInterval" json:"ReminderInterval"` //排队提醒间隔时间 - Display bool `bson:"Display" json:"Display"` //是否显示 + Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` + ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` // 景区id + Name string `bson:"Name" json:"Name" valid:"required"` + SubName string `bson:"SubName,omitempty" json:"SubName"` + Location SLocation `bson:"Location" json:"Location" valid:"required"` + Tags []STag `bson:"Tags" json:"Tags"` + Icon string `bson:"Icon" json:"Icon" valid:"required"` + LimitHeight string `bson:"LimitHeight,omitempty" json:"LimitHeight"` //限高 + PlayDuration string `bson:"PlayDuration,omitempty" json:"PlayDuration"` //游玩时长 + SceneTime string `bson:"SceneTime,omitempty" json:"SceneTime"` //场次时间 + Picture []string `bson:"Picture,omitempty" json:"Picture"` + Voice string `bson:"Voice,omitempty" json:"Voice"` //音频 + Tel string `bson:"Tel,omitempty" json:"Tel"` + AverageConsumption string `bson:"AverageConsumption,omitempty" json:"AverageConsumption"` //人均消费 + Menu string `bson:"Menu,omitempty" json:"Menu"` //目录 + //Time string `bson:"Time,omitempty" json:"Time"` + OpenHours string `bson:"OpenHours,omitempty" json:"OpenHours"` //开放时间 + LocationDescription string `bson:"LocationDescription,omitempty" json:"LocationDescription"` //位置描述 + Reminder string `bson:"Reminder,omitempty" json:"Reminder"` //温馨提示 + State int `bson:"State,omitempty" json:"State"` // 运行状态0=正常1=停运 + CustomAttribute []SCustomAttribute `bson:"CustomAttribute" json:"CustomAttribute"` // 自定义属性 + WaitingTimeDisplay bool `bson:"WaitingTimeDisplay" json:"WaitingTimeDisplay"` //是否有等待时间显示 + ReminderInterval []string `bson:"ReminderInterval" json:"ReminderInterval"` //排队提醒间隔时间 + Display bool `bson:"Display" json:"Display"` //是否显示 } type SCustomAttribute struct { @@ -93,7 +93,7 @@ type SNotice struct { Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` Title string `bson:"Title" json:"Title" valid:"required"` - Url string `bson:"Url" json:"Url" valid:"required"` + Url string `bson:"Url" json:"Url"` CreateTime int64 `bson:"CreateTime,omitempty" json:"CreateTime"` //创建时间 UpdateTime int64 `bson:"UpdateTime,omitempty" json:"UpdateTime"` //最后一次修改时间 Expiry int64 `bson:"Expiry" json:"Expiry"` //有效期 diff --git a/Version.md b/Version.md index d9955ff..a628a30 100644 --- a/Version.md +++ b/Version.md @@ -11,16 +11,34 @@ 3. 获取标签接口/AllTag增加TypeAlias字段(标签分组的中文名称)。 4. 更新项目信息接口/UpdateItem增加ReminderInterval字段(排队提醒间隔时间)用逗号分割如60,90,120 5. 项目和商品增加是否在前台显示属性 +6. 项目信息增加WaitingTimeDisplay(用于判断是否显示等待时间功能) ##### 数据结构变更: 1. 标签表增加TypeAlias字段(标签分组的中文名称) + 2. 删除1.0所属标签 + 3. 更新商品表和项目表的全部Display字段为true + 4. 更新项目表的所有游玩项目WaitingTimeDisplay字段为true +5. 删除项目表的Time字段,修改DB.go相应配置 + +6. 增加基础标签,观光,戏水,其它 + +7. 更新项目表CustomAttribute,ReminderInterval字段所有内容,不可以为nul或没有 + + ``` + db.getCollection("Item").update({},{$set:{'CustomAttribute':[{"Title":"","Content":""},{"Title":"","Content":""},{"Title":"","Content":""},{"Title":"","Content":""},{"Title":"","Content":""}]}},false,true); + + db.getCollection("Item").update({},{$set:{'ReminderInterval':[]}},false,true); + ``` + + + -- libgit2 0.21.0