Commit 1924a8a0a16a031b953b2cf8da2ab36f0c13281a
1 parent
cfcccc99
Exists in
v1.2
s
Showing
5 changed files
with
61 additions
and
46 deletions
Show diff stats
API/Item.go
... | ... | @@ -39,6 +39,9 @@ func ItemInfo(c *gin.Context) { |
39 | 39 | objID, _ := primitive.ObjectIDFromHex(c.Query("id")) |
40 | 40 | DB.CItem.FindOne(tools.GetContext(), bson.M{"_id": objID}).Decode(&SItem) |
41 | 41 | |
42 | + if SItem.ReminderInterval == nil{ | |
43 | + SItem.ReminderInterval = []string{} | |
44 | + } | |
42 | 45 | c.JSON(200, tools.ResponseSeccess{ |
43 | 46 | 0, |
44 | 47 | SItem, |
... | ... | @@ -115,7 +118,10 @@ func UpdateItem(c *gin.Context) { |
115 | 118 | var CustomAttribute []DB.SCustomAttribute |
116 | 119 | json.Unmarshal([]byte(c.PostForm("CustomAttribute")), &CustomAttribute) |
117 | 120 | |
118 | - var ReminderInterval = strings.Split(c.PostForm("ReminderInterval"),",") | |
121 | + var ReminderInterval = []string{} | |
122 | + if c.PostForm("ReminderInterval") != "" { | |
123 | + ReminderInterval = strings.Split(c.PostForm("ReminderInterval"),",") | |
124 | + } | |
119 | 125 | |
120 | 126 | var id primitive.ObjectID |
121 | 127 | if pid := c.PostForm("id"); pid == "null" { | ... | ... |
API/Tag.go
... | ... | @@ -39,12 +39,10 @@ func AllTag(c *gin.Context) { |
39 | 39 | for cur.Next(tools.GetContext()) { |
40 | 40 | var e DB.STag |
41 | 41 | cur.Decode(&e) |
42 | - Stags = append(Stags,e) | |
42 | + Stags = append(Stags, e) | |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - | |
47 | - | |
48 | 46 | if Stags == nil { |
49 | 47 | Stags = []DB.STag{} |
50 | 48 | } |
... | ... | @@ -94,7 +92,7 @@ func AllTagGroup(c *gin.Context) { |
94 | 92 | for cur.Next(tools.GetContext()) { |
95 | 93 | var e DB.STag |
96 | 94 | cur.Decode(&e) |
97 | - Stags = append(Stags,e) | |
95 | + Stags = append(Stags, e) | |
98 | 96 | } |
99 | 97 | } |
100 | 98 | |
... | ... | @@ -103,15 +101,17 @@ func AllTagGroup(c *gin.Context) { |
103 | 101 | } |
104 | 102 | |
105 | 103 | Group := make(map[string][]string) |
104 | + GroupName := make(map[string]string) | |
106 | 105 | // 去重 |
107 | 106 | for _, v := range Stags { |
108 | 107 | Group[v.Type] = append(Group[v.Type], v.Name) |
108 | + GroupName[v.Type] = v.TypeAlias | |
109 | 109 | } |
110 | 110 | |
111 | 111 | // 转为数组 |
112 | 112 | aGroup := []Tag{} |
113 | 113 | for k, v := range Group { |
114 | - aGroup = append(aGroup, Tag{k, v}) | |
114 | + aGroup = append(aGroup, Tag{k, GroupName[k],v}) | |
115 | 115 | } |
116 | 116 | |
117 | 117 | DB.Redis.Set("Tags_"+ScenicId, aGroup, time.Second*3600*24) |
... | ... | @@ -122,8 +122,6 @@ func AllTagGroup(c *gin.Context) { |
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | - | |
126 | - | |
127 | 125 | // @Title 标签 |
128 | 126 | // @Description 标签 - 增加标签 |
129 | 127 | // @Accept json |
... | ... | @@ -158,7 +156,6 @@ func CreateTag(c *gin.Context) { |
158 | 156 | return |
159 | 157 | } |
160 | 158 | |
161 | - | |
162 | 159 | if c.PostForm("TagGroup") == "" { |
163 | 160 | c.JSON(200, tools.ResponseError{ |
164 | 161 | 1, |
... | ... | @@ -167,7 +164,6 @@ func CreateTag(c *gin.Context) { |
167 | 164 | return |
168 | 165 | } |
169 | 166 | |
170 | - | |
171 | 167 | if c.PostForm("TagGroup") == "type" { |
172 | 168 | c.JSON(200, tools.ResponseError{ |
173 | 169 | 1, |
... | ... | @@ -176,7 +172,7 @@ func CreateTag(c *gin.Context) { |
176 | 172 | return |
177 | 173 | } |
178 | 174 | |
179 | - DB.CTags.InsertOne(tools.GetContext(),DB.STag{ | |
175 | + DB.CTags.InsertOne(tools.GetContext(), DB.STag{ | |
180 | 176 | c.PostForm("ScenicId"), |
181 | 177 | c.PostForm("TagGroup"), |
182 | 178 | c.PostForm("TypeAlias"), |
... | ... | @@ -192,9 +188,6 @@ func CreateTag(c *gin.Context) { |
192 | 188 | }) |
193 | 189 | } |
194 | 190 | |
195 | - | |
196 | - | |
197 | - | |
198 | 191 | // @Title 标签 |
199 | 192 | // @Description 标签 - 删除标签 |
200 | 193 | // @Accept json |
... | ... | @@ -229,7 +222,6 @@ func RemoveTag(c *gin.Context) { |
229 | 222 | return |
230 | 223 | } |
231 | 224 | |
232 | - | |
233 | 225 | if c.PostForm("TagGroup") == "" { |
234 | 226 | c.JSON(200, tools.ResponseError{ |
235 | 227 | 1, |
... | ... | @@ -238,7 +230,6 @@ func RemoveTag(c *gin.Context) { |
238 | 230 | return |
239 | 231 | } |
240 | 232 | |
241 | - | |
242 | 233 | if c.PostForm("TagGroup") == "type" { |
243 | 234 | c.JSON(200, tools.ResponseError{ |
244 | 235 | 1, |
... | ... | @@ -247,7 +238,7 @@ func RemoveTag(c *gin.Context) { |
247 | 238 | return |
248 | 239 | } |
249 | 240 | |
250 | - DB.CTags.DeleteOne(tools.GetContext(), bson.M{"ScenicId": c.PostForm("ScenicId"),"Name":c.PostForm("TagName"),"Type":c.PostForm("TagGroup")}) | |
241 | + DB.CTags.DeleteOne(tools.GetContext(), bson.M{"ScenicId": c.PostForm("ScenicId"), "Name": c.PostForm("TagName"), "Type": c.PostForm("TagGroup")}) | |
251 | 242 | |
252 | 243 | DB.Redis.Delete("Tags_" + c.PostForm("ScenicId")) |
253 | 244 | println("清楚缓存Tags") |
... | ... | @@ -258,8 +249,8 @@ func RemoveTag(c *gin.Context) { |
258 | 249 | }) |
259 | 250 | } |
260 | 251 | |
261 | - | |
262 | 252 | type Tag struct { |
263 | - Type string | |
264 | - Tags []string | |
253 | + Type string | |
254 | + TypeAlias string | |
255 | + Tags []string | |
265 | 256 | } | ... | ... |
Bin/Monitor.go
... | ... | @@ -14,7 +14,7 @@ func main() { |
14 | 14 | |
15 | 15 | for { |
16 | 16 | time.Sleep(600 * time.Second) |
17 | - httpState, body, error := tools.GET("http://leyoutu.st-i.com.cn/AllScenic") | |
17 | + httpState, body, error := tools.GET("http://leyoutu.st-i.com.cn/api/v1.1/AllScenic") | |
18 | 18 | if httpState == 200 && error == nil { |
19 | 19 | |
20 | 20 | oBody := tools.ResponseSeccess{} | ... | ... |
DB/db.go
... | ... | @@ -53,30 +53,30 @@ type SScenic struct { |
53 | 53 | } |
54 | 54 | |
55 | 55 | type SItem struct { |
56 | - Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` | |
57 | - ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` // 景区id | |
58 | - Name string `bson:"Name" json:"Name" valid:"required"` | |
59 | - SubName string `bson:"SubName,omitempty" json:"SubName"` | |
60 | - Location SLocation `bson:"Location" json:"Location" valid:"required"` | |
61 | - Tags []STag `bson:"Tags" json:"Tags"` | |
62 | - Icon string `bson:"Icon" json:"Icon" valid:"required"` | |
63 | - LimitHeight string `bson:"LimitHeight,omitempty" json:"LimitHeight"` //限高 | |
64 | - PlayDuration string `bson:"PlayDuration,omitempty" json:"PlayDuration"` //游玩时长 | |
65 | - SceneTime string `bson:"SceneTime,omitempty" json:"SceneTime"` //场次时间 | |
66 | - Picture []string `bson:"Picture,omitempty" json:"Picture"` | |
67 | - Voice string `bson:"Voice,omitempty" json:"Voice"` //音频 | |
68 | - Tel string `bson:"Tel,omitempty" json:"Tel"` | |
69 | - AverageConsumption string `bson:"AverageConsumption,omitempty" json:"AverageConsumption"` //人均消费 | |
70 | - Menu string `bson:"Menu,omitempty" json:"Menu"` //目录 | |
71 | - Time string `bson:"Time,omitempty" json:"Time"` | |
72 | - OpenHours string `bson:"OpenHours,omitempty" json:"OpenHours"` //开放时间 | |
73 | - LocationDescription string `bson:"LocationDescription,omitempty" json:"LocationDescription"` //位置描述 | |
74 | - Reminder string `bson:"Reminder,omitempty" json:"Reminder"` //温馨提示 | |
75 | - State int `bson:"State,omitempty" json:"State"` // 运行状态0=正常1=停运 | |
76 | - CustomAttribute []SCustomAttribute `bson:"CustomAttribute" json:"CustomAttribute"` // 自定义属性 | |
77 | - WaitingTimeDisplay bool `bson:"WaitingTimeDisplay" json:"WaitingTimeDisplay"` //是否有等待时间显示 | |
78 | - ReminderInterval []string `bson:"ReminderInterval" json:"ReminderInterval"` //排队提醒间隔时间 | |
79 | - Display bool `bson:"Display" json:"Display"` //是否显示 | |
56 | + Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` | |
57 | + ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` // 景区id | |
58 | + Name string `bson:"Name" json:"Name" valid:"required"` | |
59 | + SubName string `bson:"SubName,omitempty" json:"SubName"` | |
60 | + Location SLocation `bson:"Location" json:"Location" valid:"required"` | |
61 | + Tags []STag `bson:"Tags" json:"Tags"` | |
62 | + Icon string `bson:"Icon" json:"Icon" valid:"required"` | |
63 | + LimitHeight string `bson:"LimitHeight,omitempty" json:"LimitHeight"` //限高 | |
64 | + PlayDuration string `bson:"PlayDuration,omitempty" json:"PlayDuration"` //游玩时长 | |
65 | + SceneTime string `bson:"SceneTime,omitempty" json:"SceneTime"` //场次时间 | |
66 | + Picture []string `bson:"Picture,omitempty" json:"Picture"` | |
67 | + Voice string `bson:"Voice,omitempty" json:"Voice"` //音频 | |
68 | + Tel string `bson:"Tel,omitempty" json:"Tel"` | |
69 | + AverageConsumption string `bson:"AverageConsumption,omitempty" json:"AverageConsumption"` //人均消费 | |
70 | + Menu string `bson:"Menu,omitempty" json:"Menu"` //目录 | |
71 | + //Time string `bson:"Time,omitempty" json:"Time"` | |
72 | + OpenHours string `bson:"OpenHours,omitempty" json:"OpenHours"` //开放时间 | |
73 | + LocationDescription string `bson:"LocationDescription,omitempty" json:"LocationDescription"` //位置描述 | |
74 | + Reminder string `bson:"Reminder,omitempty" json:"Reminder"` //温馨提示 | |
75 | + State int `bson:"State,omitempty" json:"State"` // 运行状态0=正常1=停运 | |
76 | + CustomAttribute []SCustomAttribute `bson:"CustomAttribute" json:"CustomAttribute"` // 自定义属性 | |
77 | + WaitingTimeDisplay bool `bson:"WaitingTimeDisplay" json:"WaitingTimeDisplay"` //是否有等待时间显示 | |
78 | + ReminderInterval []string `bson:"ReminderInterval" json:"ReminderInterval"` //排队提醒间隔时间 | |
79 | + Display bool `bson:"Display" json:"Display"` //是否显示 | |
80 | 80 | } |
81 | 81 | |
82 | 82 | type SCustomAttribute struct { |
... | ... | @@ -93,7 +93,7 @@ type SNotice struct { |
93 | 93 | Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` |
94 | 94 | ScenicId string `bson:"ScenicId" json:"ScenicId" valid:"required"` |
95 | 95 | Title string `bson:"Title" json:"Title" valid:"required"` |
96 | - Url string `bson:"Url" json:"Url" valid:"required"` | |
96 | + Url string `bson:"Url" json:"Url"` | |
97 | 97 | CreateTime int64 `bson:"CreateTime,omitempty" json:"CreateTime"` //创建时间 |
98 | 98 | UpdateTime int64 `bson:"UpdateTime,omitempty" json:"UpdateTime"` //最后一次修改时间 |
99 | 99 | Expiry int64 `bson:"Expiry" json:"Expiry"` //有效期 | ... | ... |
Version.md
... | ... | @@ -11,16 +11,34 @@ |
11 | 11 | 3. 获取标签接口/AllTag增加TypeAlias字段(标签分组的中文名称)。 |
12 | 12 | 4. 更新项目信息接口/UpdateItem增加ReminderInterval字段(排队提醒间隔时间)用逗号分割如60,90,120 |
13 | 13 | 5. 项目和商品增加是否在前台显示属性 |
14 | +6. 项目信息增加WaitingTimeDisplay(用于判断是否显示等待时间功能) | |
14 | 15 | |
15 | 16 | |
16 | 17 | |
17 | 18 | ##### 数据结构变更: |
18 | 19 | |
19 | 20 | 1. 标签表增加TypeAlias字段(标签分组的中文名称) |
21 | + | |
20 | 22 | 2. 删除1.0所属标签 |
23 | + | |
21 | 24 | 3. 更新商品表和项目表的全部Display字段为true |
25 | + | |
22 | 26 | 4. 更新项目表的所有游玩项目WaitingTimeDisplay字段为true |
23 | 27 | |
28 | +5. 删除项目表的Time字段,修改DB.go相应配置 | |
29 | + | |
30 | +6. 增加基础标签,观光,戏水,其它 | |
31 | + | |
32 | +7. 更新项目表CustomAttribute,ReminderInterval字段所有内容,不可以为nul或没有 | |
33 | + | |
34 | + ``` | |
35 | + db.getCollection("Item").update({},{$set:{'CustomAttribute':[{"Title":"","Content":""},{"Title":"","Content":""},{"Title":"","Content":""},{"Title":"","Content":""},{"Title":"","Content":""}]}},false,true); | |
36 | + | |
37 | + db.getCollection("Item").update({},{$set:{'ReminderInterval':[]}},false,true); | |
38 | + ``` | |
39 | + | |
40 | + | |
41 | + | |
24 | 42 | |
25 | 43 | |
26 | 44 | ... | ... |