Commit cfcccc9984be6d121a517c2f802bba7b0e416a66

Authored by aarongao
1 parent f833bc66
Exists in v1.2

ok

@@ -3,6 +3,7 @@ package Api @@ -3,6 +3,7 @@ package Api
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
5 "github.com/aarongao/tools" 5 "github.com/aarongao/tools"
  6 + "github.com/asaskevich/govalidator"
6 "github.com/gin-gonic/gin" 7 "github.com/gin-gonic/gin"
7 "go.mongodb.org/mongo-driver/bson" 8 "go.mongodb.org/mongo-driver/bson"
8 "go.mongodb.org/mongo-driver/bson/primitive" 9 "go.mongodb.org/mongo-driver/bson/primitive"
@@ -10,6 +11,7 @@ import ( @@ -10,6 +11,7 @@ import (
10 "letu/DB" 11 "letu/DB"
11 "letu/Lib/Auth" 12 "letu/Lib/Auth"
12 "strconv" 13 "strconv"
  14 + "strings"
13 "time" 15 "time"
14 ) 16 )
15 17
@@ -18,7 +20,7 @@ import ( @@ -18,7 +20,7 @@ import (
18 // @Accept json 20 // @Accept json
19 // @Produce json 21 // @Produce json
20 // @Param id 5dfb03070a9ac17ac7a82054 string true "设备id" 22 // @Param id 5dfb03070a9ac17ac7a82054 string true "设备id"
21 -// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运" 23 +// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运;Display是否在前台显示;ReminderInterval排队提醒间隔时间(用逗号分割如60,90,120)"
22 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" 24 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
23 // @Router /ItemInfo? [get] 25 // @Router /ItemInfo? [get]
24 func ItemInfo(c *gin.Context) { 26 func ItemInfo(c *gin.Context) {
@@ -49,15 +51,20 @@ func ItemInfo(c *gin.Context) { @@ -49,15 +51,20 @@ func ItemInfo(c *gin.Context) {
49 // @Accept json 51 // @Accept json
50 // @Produce json 52 // @Produce json
51 // @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id" 53 // @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
52 -// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运" 54 +// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运;Display是否在前台显示;ReminderInterval排队提醒间隔时间(用逗号分割如60,90,120)"
53 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" 55 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
54 // @Router /AllItems? [get] 56 // @Router /AllItems? [get]
55 func AllItems(c *gin.Context) { 57 func AllItems(c *gin.Context) {
56 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) 58 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
57 c.Header("Access-Control-Allow-Credentials", "true") 59 c.Header("Access-Control-Allow-Credentials", "true")
58 60
  61 + _select := bson.M{"ScenicId": c.Query("ScenicId"), "Display": true}
  62 + if c.Query("Display") == "all"{
  63 + _select = bson.M{"ScenicId": c.Query("ScenicId")}
  64 + }
  65 +
59 var aItems = []DB.SItem{} 66 var aItems = []DB.SItem{}
60 - cur, err := DB.CItem.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) 67 + cur, err := DB.CItem.Find(tools.GetContext(), _select)
61 defer cur.Close(tools.GetContext()) 68 defer cur.Close(tools.GetContext())
62 if err == nil { 69 if err == nil {
63 for cur.Next(tools.GetContext()) { 70 for cur.Next(tools.GetContext()) {
@@ -105,6 +112,11 @@ func UpdateItem(c *gin.Context) { @@ -105,6 +112,11 @@ func UpdateItem(c *gin.Context) {
105 var Picture []string 112 var Picture []string
106 json.Unmarshal([]byte(c.PostForm("Picture")), &Picture) 113 json.Unmarshal([]byte(c.PostForm("Picture")), &Picture)
107 114
  115 + var CustomAttribute []DB.SCustomAttribute
  116 + json.Unmarshal([]byte(c.PostForm("CustomAttribute")), &CustomAttribute)
  117 +
  118 + var ReminderInterval = strings.Split(c.PostForm("ReminderInterval"),",")
  119 +
108 var id primitive.ObjectID 120 var id primitive.ObjectID
109 if pid := c.PostForm("id"); pid == "null" { 121 if pid := c.PostForm("id"); pid == "null" {
110 id = primitive.NewObjectID() 122 id = primitive.NewObjectID()
@@ -113,30 +125,49 @@ func UpdateItem(c *gin.Context) { @@ -113,30 +125,49 @@ func UpdateItem(c *gin.Context) {
113 } 125 }
114 126
115 poststate, _ := strconv.Atoi(c.PostForm("State")) 127 poststate, _ := strconv.Atoi(c.PostForm("State"))
  128 + Display, _ := strconv.ParseBool(c.PostForm("Display"))
  129 + WaitingTimeDisplay, _ := strconv.ParseBool(c.PostForm("WaitingTimeDisplay"))
  130 +
  131 +
  132 + Item := &DB.SItem{
  133 + Id: &id,
  134 + Name: c.PostForm("Name"),
  135 + SubName: c.PostForm("SubName"),
  136 + ScenicId: c.PostForm("ScenicId"),
  137 + Location: Location,
  138 + Icon: c.PostForm("Icon"),
  139 + LimitHeight: c.PostForm("LimitHeight"),
  140 + PlayDuration: c.PostForm("PlayDuration"),
  141 + SceneTime: c.PostForm("SceneTime"),
  142 + Picture: Picture,
  143 + Voice: c.PostForm("Voice"),
  144 + Tel: c.PostForm("Tel"),
  145 + AverageConsumption: c.PostForm("AverageConsumption"),
  146 + Menu: c.PostForm("Menu"),
  147 + Tags: Tags,
  148 + OpenHours: c.PostForm("OpenHours"),
  149 + LocationDescription: c.PostForm("LocationDescription"),
  150 + Reminder: c.PostForm("Reminder"),
  151 + State: poststate,
  152 + CustomAttribute: CustomAttribute,
  153 + Display: Display,
  154 + WaitingTimeDisplay: WaitingTimeDisplay,
  155 + ReminderInterval: ReminderInterval,
  156 + }
  157 +
  158 + _, err = govalidator.ValidateStruct(Item);
  159 + if err != nil {
  160 + c.JSON(200, tools.ResponseError{
  161 + 1,
  162 + err.Error(),
  163 + })
  164 + return
  165 + }
116 166
117 upsert := true 167 upsert := true
118 DB.CItem.FindOneAndUpdate(tools.GetContext(), 168 DB.CItem.FindOneAndUpdate(tools.GetContext(),
119 bson.M{"_id": id}, 169 bson.M{"_id": id},
120 - bson.M{"$set": bson.M{  
121 - "Name": c.PostForm("Name"),  
122 - "SubName": c.PostForm("SubName"),  
123 - "ScenicId": c.PostForm("ScenicId"),  
124 - "Location": Location,  
125 - "Icon": c.PostForm("Icon"),  
126 - "LimitHeight": c.PostForm("LimitHeight"),  
127 - "PlayDuration": c.PostForm("PlayDuration"),  
128 - "SceneTime": c.PostForm("SceneTime"),  
129 - "Picture": Picture,  
130 - "Voice": c.PostForm("Voice"),  
131 - "Tel": c.PostForm("Tel"),  
132 - "AverageConsumption": c.PostForm("AverageConsumption"),  
133 - "Menu": c.PostForm("Menu"),  
134 - "Tags": Tags,  
135 - "OpenHours": c.PostForm("OpenHours"),  
136 - "LocationDescription": c.PostForm("LocationDescription"),  
137 - "Reminder": c.PostForm("Reminder"),  
138 - "State": poststate,  
139 - }}, &options.FindOneAndUpdateOptions{ 170 + bson.M{"$set": Item}, &options.FindOneAndUpdateOptions{
140 Upsert: &upsert, 171 Upsert: &upsert,
141 }, 172 },
142 ) 173 )
@@ -155,7 +186,7 @@ func UpdateItem(c *gin.Context) { @@ -155,7 +186,7 @@ func UpdateItem(c *gin.Context) {
155 // ItemTime[c.PostForm("id")] = "0" 186 // ItemTime[c.PostForm("id")] = "0"
156 //} 187 //}
157 188
158 - DB.Redis.Set("AllItemTime_" + c.PostForm("ScenicId"), ItemTime, time.Second*60*60*24*30) 189 + DB.Redis.Set("AllItemTime_"+c.PostForm("ScenicId"), ItemTime, time.Second*60*60*24*30)
159 190
160 c.JSON(200, tools.ResponseSeccess{ 191 c.JSON(200, tools.ResponseSeccess{
161 0, 192 0,
@@ -217,101 +217,120 @@ func initScenic(id string) { @@ -217,101 +217,120 @@ func initScenic(id string) {
217 dba = append(dba, DB.STag{ 217 dba = append(dba, DB.STag{
218 id, 218 id,
219 "type", 219 "type",
  220 + "基础类型",
220 "服务设施", 221 "服务设施",
221 }) 222 })
222 dba = append(dba, DB.STag{ 223 dba = append(dba, DB.STag{
223 id, 224 id,
224 "type", 225 "type",
  226 + "基础类型",
225 "普通", 227 "普通",
226 }) 228 })
227 dba = append(dba, DB.STag{ 229 dba = append(dba, DB.STag{
228 id, 230 id,
229 "type", 231 "type",
  232 + "基础类型",
230 "演出", 233 "演出",
231 }) 234 })
232 dba = append(dba, DB.STag{ 235 dba = append(dba, DB.STag{
233 id, 236 id,
234 "type", 237 "type",
  238 + "基础类型",
235 "购物", 239 "购物",
236 }) 240 })
237 dba = append(dba, DB.STag{ 241 dba = append(dba, DB.STag{
238 id, 242 id,
239 "type", 243 "type",
  244 + "基础类型",
240 "餐饮", 245 "餐饮",
241 }) 246 })
242 dba = append(dba, DB.STag{ 247 dba = append(dba, DB.STag{
243 id, 248 id,
244 "type", 249 "type",
  250 + "基础类型",
245 "游乐设施", 251 "游乐设施",
246 }) 252 })
247 253
248 dba = append(dba, DB.STag{ 254 dba = append(dba, DB.STag{
249 id, 255 id,
250 "age", 256 "age",
  257 + "年龄段",
251 "儿童", 258 "儿童",
252 }) 259 })
253 dba = append(dba, DB.STag{ 260 dba = append(dba, DB.STag{
254 id, 261 id,
255 "age", 262 "age",
  263 + "年龄段",
256 "成人", 264 "成人",
257 }) 265 })
258 dba = append(dba, DB.STag{ 266 dba = append(dba, DB.STag{
259 id, 267 id,
260 "age", 268 "age",
  269 + "年龄段",
261 "青少年", 270 "青少年",
262 }) 271 })
263 272
264 dba = append(dba, DB.STag{ 273 dba = append(dba, DB.STag{
265 id, 274 id,
266 "food", 275 "food",
  276 + "餐饮类型",
267 "海鲜", 277 "海鲜",
268 }) 278 })
269 dba = append(dba, DB.STag{ 279 dba = append(dba, DB.STag{
270 id, 280 id,
271 "food", 281 "food",
  282 + "餐饮类型",
272 "团餐", 283 "团餐",
273 }) 284 })
274 dba = append(dba, DB.STag{ 285 dba = append(dba, DB.STag{
275 id, 286 id,
276 "food", 287 "food",
  288 + "餐饮类型",
277 "烧烤", 289 "烧烤",
278 }) 290 })
279 dba = append(dba, DB.STag{ 291 dba = append(dba, DB.STag{
280 id, 292 id,
281 "food", 293 "food",
  294 + "餐饮类型",
282 "小吃", 295 "小吃",
283 }) 296 })
284 297
285 dba = append(dba, DB.STag{ 298 dba = append(dba, DB.STag{
286 id, 299 id,
287 "recommend", 300 "recommend",
  301 + "推荐指数",
288 "必玩", 302 "必玩",
289 }) 303 })
290 304
291 dba = append(dba, DB.STag{ 305 dba = append(dba, DB.STag{
292 id, 306 id,
293 "shop", 307 "shop",
  308 + "商品分类",
294 "纪念品", 309 "纪念品",
295 }) 310 })
296 dba = append(dba, DB.STag{ 311 dba = append(dba, DB.STag{
297 id, 312 id,
298 "shop", 313 "shop",
  314 + "商品分类",
299 "收藏品", 315 "收藏品",
300 }) 316 })
301 dba = append(dba, DB.STag{ 317 dba = append(dba, DB.STag{
302 id, 318 id,
303 "shop", 319 "shop",
  320 + "商品分类",
304 "玩具", 321 "玩具",
305 }) 322 })
306 323
307 dba = append(dba, DB.STag{ 324 dba = append(dba, DB.STag{
308 id, 325 id,
309 "thrilling", 326 "thrilling",
  327 + "体验感受",
310 "刺激", 328 "刺激",
311 }) 329 })
312 dba = append(dba, DB.STag{ 330 dba = append(dba, DB.STag{
313 id, 331 id,
314 "thrilling", 332 "thrilling",
  333 + "体验感受",
315 "放松", 334 "放松",
316 }) 335 })
317 336
@@ -9,6 +9,7 @@ import ( @@ -9,6 +9,7 @@ import (
9 "go.mongodb.org/mongo-driver/mongo/options" 9 "go.mongodb.org/mongo-driver/mongo/options"
10 "letu/DB" 10 "letu/DB"
11 "letu/Lib/Auth" 11 "letu/Lib/Auth"
  12 + "strconv"
12 ) 13 )
13 14
14 // @Title 查询商品信息 15 // @Title 查询商品信息
@@ -16,7 +17,7 @@ import ( @@ -16,7 +17,7 @@ import (
16 // @Accept json 17 // @Accept json
17 // @Produce json 18 // @Produce json
18 // @Param id 5dfb03070a9ac17ac7a82054 string true "id" 19 // @Param id 5dfb03070a9ac17ac7a82054 string true "id"
19 -// @Success 200 {object} tools.ResponseSeccess "Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图" 20 +// @Success 200 {object} tools.ResponseSeccess "Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图; Display是否在前台显示"
20 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" 21 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
21 // @Router /CommodityInfo? [get] 22 // @Router /CommodityInfo? [get]
22 func CommodityInfo(c *gin.Context) { 23 func CommodityInfo(c *gin.Context) {
@@ -47,15 +48,20 @@ func CommodityInfo(c *gin.Context) { @@ -47,15 +48,20 @@ func CommodityInfo(c *gin.Context) {
47 // @Accept json 48 // @Accept json
48 // @Produce json 49 // @Produce json
49 // @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id" 50 // @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
50 -// @Success 200 {object} tools.ResponseSeccess "Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图" 51 +// @Success 200 {object} tools.ResponseSeccess "Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图; Display是否在前台显示"
51 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" 52 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
52 // @Router /AllCommodity? [get] 53 // @Router /AllCommodity? [get]
53 func AllCommodity(c *gin.Context) { 54 func AllCommodity(c *gin.Context) {
54 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) 55 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
55 c.Header("Access-Control-Allow-Credentials", "true") 56 c.Header("Access-Control-Allow-Credentials", "true")
56 57
  58 + _select := bson.M{"ScenicId": c.Query("ScenicId"), "Display": true}
  59 + if c.Query("Display") == "all"{
  60 + _select = bson.M{"ScenicId": c.Query("ScenicId")}
  61 + }
  62 +
57 var aCommoditys = []DB.SCommodity{} 63 var aCommoditys = []DB.SCommodity{}
58 - cur, err := DB.CCommodity.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId")}) 64 + cur, err := DB.CCommodity.Find(tools.GetContext(), _select)
59 defer cur.Close(tools.GetContext()) 65 defer cur.Close(tools.GetContext())
60 if err == nil { 66 if err == nil {
61 for cur.Next(tools.GetContext()) { 67 for cur.Next(tools.GetContext()) {
@@ -110,6 +116,7 @@ func UpdateCommodity(c *gin.Context) { @@ -110,6 +116,7 @@ func UpdateCommodity(c *gin.Context) {
110 } 116 }
111 117
112 upsert := true 118 upsert := true
  119 + Display, _ := strconv.ParseBool(c.PostForm("Display"))
113 DB.CCommodity.FindOneAndUpdate(tools.GetContext(), 120 DB.CCommodity.FindOneAndUpdate(tools.GetContext(),
114 bson.M{"_id": id}, 121 bson.M{"_id": id},
115 bson.M{"$set": bson.M{ 122 bson.M{"$set": bson.M{
@@ -120,6 +127,7 @@ func UpdateCommodity(c *gin.Context) { @@ -120,6 +127,7 @@ func UpdateCommodity(c *gin.Context) {
120 "TopPhoto": TopPhoto, 127 "TopPhoto": TopPhoto,
121 "ItemId": c.PostForm("ItemId"), 128 "ItemId": c.PostForm("ItemId"),
122 "Images": Picture, 129 "Images": Picture,
  130 + "Display": Display,
123 }}, &options.FindOneAndUpdateOptions{ 131 }}, &options.FindOneAndUpdateOptions{
124 Upsert: &upsert, 132 Upsert: &upsert,
125 }, 133 },
@@ -179,6 +179,7 @@ func CreateTag(c *gin.Context) { @@ -179,6 +179,7 @@ func CreateTag(c *gin.Context) {
179 DB.CTags.InsertOne(tools.GetContext(),DB.STag{ 179 DB.CTags.InsertOne(tools.GetContext(),DB.STag{
180 c.PostForm("ScenicId"), 180 c.PostForm("ScenicId"),
181 c.PostForm("TagGroup"), 181 c.PostForm("TagGroup"),
  182 + c.PostForm("TypeAlias"),
182 c.PostForm("TagName"), 183 c.PostForm("TagName"),
183 }) 184 })
184 185
1 package Api 1 package Api
2 2
3 import ( 3 import (
  4 + "encoding/base64"
4 "fmt" 5 "fmt"
5 "github.com/aarongao/tools" 6 "github.com/aarongao/tools"
6 "github.com/gin-gonic/gin" 7 "github.com/gin-gonic/gin"
  8 + "io/ioutil"
7 "path" 9 "path"
8 "strconv" 10 "strconv"
  11 + "strings"
9 "time" 12 "time"
10 ) 13 )
11 14
@@ -47,3 +50,39 @@ func Upload(c *gin.Context) { @@ -47,3 +50,39 @@ func Upload(c *gin.Context) {
47 "/" + filePath, 50 "/" + filePath,
48 }) 51 })
49 } 52 }
  53 +
  54 +// @Title 上传文件BASE64
  55 +// @Description 上传文件BASE64
  56 +// @Accept json
  57 +// @Produce json
  58 +// @Param file 1 file true "文件"
  59 +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"图片地址"}"
  60 +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
  61 +// @Router /UploadBASE64? [post]
  62 +func UploadBASE64(c *gin.Context) {
  63 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  64 + c.Header("Access-Control-Allow-Credentials", "true")
  65 +
  66 + base64Img := c.PostForm("base64Img")
  67 +
  68 + index := strings.Index(base64Img, ",")
  69 + base64Img = base64Img[index+1:]
  70 + dist, _ := base64.StdEncoding.DecodeString(base64Img)
  71 +
  72 + fileExt := ".jpg"
  73 + filePath := "Upload/" + strconv.Itoa(int(time.Now().UnixNano())) + fileExt
  74 +
  75 + err := ioutil.WriteFile(filePath, []byte(dist), 0666) //buffer输出到jpg文件中(不做处理,直接写到文件)
  76 + if err != nil {
  77 + fmt.Println(err)
  78 + c.JSON(200, tools.ResponseError{
  79 + 1,
  80 + "upload file err",
  81 + })
  82 + return
  83 + }
  84 + c.JSON(200, tools.ResponseSeccess{
  85 + 0,
  86 + "/" + filePath,
  87 + })
  88 +}
@@ -54,25 +54,34 @@ type SScenic struct { @@ -54,25 +54,34 @@ type SScenic struct {
54 54
55 type SItem struct { 55 type SItem struct {
56 Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` 56 Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
57 - ScenicId string `bson:"ScenicId" json:"ScenicId"` // 景区id  
58 - Name string `bson:"Name" json:"Name"`  
59 - SubName string `bson:"SubName" json:"SubName"`  
60 - Location SLocation `bson:"Location" json:"Location"` 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"` 61 Tags []STag `bson:"Tags" json:"Tags"`
62 - Icon string `bson:"Icon" json:"Icon"`  
63 - LimitHeight string `bson:"LimitHeight" json:"LimitHeight"` //限高  
64 - PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` //游玩时长  
65 - SceneTime string `bson:"SceneTime" json:"SceneTime"` //场次时间  
66 - Picture []string `bson:"Picture" json:"Picture"`  
67 - Voice string `bson:"Voice" json:"Voice"` //音频  
68 - Tel string `bson:"Tel" json:"Tel"`  
69 - AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"` //人均消费  
70 - Menu string `bson:"Menu" json:"Menu"` //目录  
71 - Time string `bson:"Time" json:"Time"`  
72 - OpenHours string `bson:"OpenHours" json:"OpenHours"` //开放时间  
73 - LocationDescription string `bson:"LocationDescription" json:"LocationDescription"` //位置描述  
74 - Reminder string `bson:"Reminder" json:"Reminder"` //温馨提示  
75 - State int `bson:"State" json:"State"` // 运行状态0=正常1=停运 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 +}
  81 +
  82 +type SCustomAttribute struct {
  83 + Title string `bson:"Title" json:"Title"`
  84 + Content string `bson:"Content" json:"Content"`
76 } 85 }
77 86
78 type SModel struct { 87 type SModel struct {
@@ -170,6 +179,7 @@ type SCommodity struct { @@ -170,6 +179,7 @@ type SCommodity struct {
170 KvPhoto string `bson:"KvPhoto" json:"KvPhoto"` //用于列表页的图片 179 KvPhoto string `bson:"KvPhoto" json:"KvPhoto"` //用于列表页的图片
171 TopPhoto []SPicture `bson:"TopPhoto" json:"TopPhoto"` //详情页最上面的轮播图 180 TopPhoto []SPicture `bson:"TopPhoto" json:"TopPhoto"` //详情页最上面的轮播图
172 Images []string `bson:"Images" json:"Images"` //详情页下面的产品详细图 181 Images []string `bson:"Images" json:"Images"` //详情页下面的产品详细图
  182 + Display bool `bson:"Display" json:"Display"` //是否显示
173 } 183 }
174 type SLine struct { 184 type SLine struct {
175 Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"` 185 Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
@@ -220,9 +230,10 @@ type SMember struct { @@ -220,9 +230,10 @@ type SMember struct {
220 } 230 }
221 231
222 type STag struct { 232 type STag struct {
223 - ScenicId string `bson:"ScenicId" json:"ScenicId"`  
224 - Type string `bson:"Type" json:"Type"`  
225 - Name string `bson:"Name" json:"Name"` 233 + ScenicId string `bson:"ScenicId" json:"ScenicId"`
  234 + Type string `bson:"Type" json:"Type"`
  235 + TypeAlias string `TypeAlias:"alias" json:"TypeAlias"` // 类型的别名
  236 + Name string `bson:"Name" json:"Name"`
226 } 237 }
227 238
228 type SPicture struct { 239 type SPicture struct {
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 ## 乐游图后端接口文档 2 ## 乐游图后端接口文档
3 | Specification | Value | 3 | Specification | Value |
4 |-----|-----| 4 |-----|-----|
5 -| API Version | 1.1.0 | 5 +| API Version | 1.0.0 |
6 | BasePath | 正式 leyoutu.st-i.com.cn; 测试 leyoutu.sti-uat.com | 6 | BasePath | 正式 leyoutu.st-i.com.cn; 测试 leyoutu.sti-uat.com |
7 7
8 8
@@ -64,6 +64,7 @@ @@ -64,6 +64,7 @@
64 1. [更新景区基础信息-高级](#updatescenicsenior-post) 64 1. [更新景区基础信息-高级](#updatescenicsenior-post)
65 1. [用户管理 - 修改用户信息](#updateuser-post) 65 1. [用户管理 - 修改用户信息](#updateuser-post)
66 1. [上传](#upload-post) 66 1. [上传](#upload-post)
  67 +1. [上传文件BASE64](#uploadbase64-post)
67 1. [用户管理 - 获取用户信息](#userinfo-get) 68 1. [用户管理 - 获取用户信息](#userinfo-get)
68 1. [增加用户行为日志](#userlog-post) 69 1. [增加用户行为日志](#userlog-post)
69 70
@@ -83,7 +84,7 @@ @@ -83,7 +84,7 @@
83 84
84 | Code | Type | Model | Message | 85 | Code | Type | Model | Message |
85 |-----|-----|-----|-----| 86 |-----|-----|-----|-----|
86 -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图 | 87 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图; Display是否在前台显示 |
87 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | 88 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
88 89
89 90
@@ -141,7 +142,7 @@ @@ -141,7 +142,7 @@
141 142
142 | Code | Type | Model | Message | 143 | Code | Type | Model | Message |
143 |-----|-----|-----|-----| 144 |-----|-----|-----|-----|
144 -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运 | 145 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运;Display是否在前台显示;ReminderInterval排队提醒间隔时间(用逗号分割如60,90,120) |
145 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | 146 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
146 147
147 148
@@ -331,7 +332,7 @@ @@ -331,7 +332,7 @@
331 332
332 | Code | Type | Model | Message | 333 | Code | Type | Model | Message |
333 |-----|-----|-----|-----| 334 |-----|-----|-----|-----|
334 -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图 | 335 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图; Display是否在前台显示 |
335 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | 336 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
336 337
337 338
@@ -556,7 +557,7 @@ @@ -556,7 +557,7 @@
556 557
557 | Code | Type | Model | Message | 558 | Code | Type | Model | Message |
558 |-----|-----|-----|-----| 559 |-----|-----|-----|-----|
559 -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运 | 560 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运;Display是否在前台显示;ReminderInterval排队提醒间隔时间(用逗号分割如60,90,120) |
560 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | 561 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
561 562
562 563
@@ -1199,6 +1200,25 @@ @@ -1199,6 +1200,25 @@
1199 1200
1200 1201
1201 1202
  1203 +<a name="uploadbase64-post"></a>
  1204 +
  1205 +#### /UploadBASE64 (POST)
  1206 +
  1207 +
  1208 +上传文件BASE64
  1209 +
  1210 +| Param Name | Example | Data Type | Description | Required? |
  1211 +|-----|-----|-----|-----|-----|
  1212 +| file | 1 | file | 文件 | Yes |
  1213 +
  1214 +
  1215 +| Code | Type | Model | Message |
  1216 +|-----|-----|-----|-----|
  1217 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":"图片地址"} |
  1218 +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
  1219 +
  1220 +
  1221 +
1202 <a name="userinfo-get"></a> 1222 <a name="userinfo-get"></a>
1203 1223
1204 #### /UserInfo (GET) 1224 #### /UserInfo (GET)
1 -## 版本号:v1.1 1 +## 版本号:v1.2
2 2
3 -##### 生产环境地址:http://leyoutu.st-i.com.cn/api/v1.1/ 3 +##### 生产环境地址:http://leyoutu.st-i.com.cn/api/v1.2/
4 4
5 -##### 测试环境地址:http://leyoutu.sti-uat.com/api/v1.1/ 5 +##### 测试环境地址:http://leyoutu.sti-uat.com/api/v1.2/
6 6
7 ##### 变更说明: 7 ##### 变更说明:
8 8
9 -1. /UserInfo接口增加权限验证(需要携带Token),游客只能查询自己信息,操作员可查询所有。  
10 -  
11 -2. /AllComplaint接口增加ScenicId景区id参数  
12 -  
13 -3. /SystemInfo 新增系统信息接口  
14 -  
15 - ```  
16 - {  
17 - "errcode": 0,  
18 - "result": {  
19 - "UpdateLocationInterval": 30,//上报位置时间间隔(秒)  
20 - "Version": 1.1//最新版本号  
21 - "SupportVersion": 1.1//支持的最旧版本号  
22 - }  
23 - }  
24 - ```  
25 -  
26 -4. 新增加公告管理模块接口  
27 -  
28 - ```  
29 - /Notice/Info  
30 - /Notice/List  
31 - /Notice/Create(需要携带Token)  
32 - /Notice/Remove(需要携带Token)  
33 - /Notice/Modify(需要携带Token)  
34 - ```  
35 -  
36 -5. 新增加顶部菜单相关接口  
37 -  
38 - ```  
39 - /TopMenus/All 获取所有菜单,以及关联标签  
40 - /TopMenus/Update(需要携带Token)  
41 - /TopMenus/Remove(需要携带Token)  
42 - ```  
43 -  
44 -6. 删除【游玩项目】标签。增加【游乐设施】【演出】【餐饮】【购物】【普通】  
45 -  
46 -7. 删除【location】标签组  
47 -  
48 -8. 修改地图切片url地址,及切片上传方式  
49 -  
50 - /tiles2/**<u>5e0d504e24e03431008b4567</u>**/18/218274/99286.jpg  
51 -  
52 - 其中5e0d504e24e03431008b4567(景区id)为新加目录  
53 -  
54 - 通过FTP方式上传到/root/leyoutu/tiles2/(景区id)/目录下  
55 -  
56 -9. 后台增加管理员日志功能  
57 -  
58 -10. 增加/SysAds/List获取平台广告信息接口  
59 -  
60 -11. /AllLine推荐线路接口返回结果变更,增加固定结构。  
61 -  
62 - ```  
63 - {  
64 - errcode: 0,  
65 - result: [ ]  
66 - }  
67 - ```  
68 -  
69 -12. /ScenicInfo景区信息接口增加新属性  
70 -  
71 - ```  
72 - ZoomForIOS //地图的缩放大小(IOS)  
73 - ZoomForAndroidMin //地图的缩放大小(Android最小)  
74 - ZoomForAndroidMax //地图的缩放大小(Android最大)  
75 - Rotation //旋转角度  
76 - OpenTiles //否开启地图切片  
77 - ColorTiles //切片底色(FFFFFF)  
78 - ```  
79 -  
80 -13. /AllScenic增加Display=all参数。意思是显示所有数据,默认情况不显示隐藏信息 9 +1. 后台取消景区增加标签功能。
  10 +2. 后台优化项目编辑页面布局及功能。
  11 +3. 获取标签接口/AllTag增加TypeAlias字段(标签分组的中文名称)。
  12 +4. 更新项目信息接口/UpdateItem增加ReminderInterval字段(排队提醒间隔时间)用逗号分割如60,90,120
  13 +5. 项目和商品增加是否在前台显示属性
81 14
82 15
83 16
84 ##### 数据结构变更: 17 ##### 数据结构变更:
85 18
86 -1、标签表、设施信息中的所属标签 19 +1. 标签表增加TypeAlias字段(标签分组的中文名称)
  20 +2. 删除1.0所属标签
  21 +3. 更新商品表和项目表的全部Display字段为true
  22 +4. 更新项目表的所有游玩项目WaitingTimeDisplay字段为true
87 23
88 -2、平台广告表初始数据  
89 24
90 -2、root用户增加新模块权限  
91 25
92 26
93 27
@@ -101,16 +35,16 @@ @@ -101,16 +35,16 @@
101 35
102 ##### 发布流程: 36 ##### 发布流程:
103 37
104 -1. 提交APP代码到git(v1.1分支) 38 +1. 提交APP代码到git(v1.2分支)
105 2. 使用 “测试环境地址” 打包内测版本至TestFlight 39 2. 使用 “测试环境地址” 打包内测版本至TestFlight
106 -3. 升级 ”生产环境“ 接口至v1.1  
107 - 1. 打包上传程序文件main_v1.1 40 +3. 升级 ”生产环境“ 接口至v1.2
  41 + 1. 打包上传程序文件main_v1.2
108 2. 修改config.json配置文件 42 2. 修改config.json配置文件
109 3. 运行程序 43 3. 运行程序
110 - 4. nginx增加/api/v1.1路径支持 44 + 4. nginx增加/api/v1.2路径支持
111 5. 上传后台页面 45 5. 上传后台页面
112 6. 更新root用户模块权限数据 46 6. 更新root用户模块权限数据
113 - 7. 修改数据结构变更及数据缺失(广告,标签等。。 47 + 7. 修改数据结构变更及数据缺失(见上面“数据结构变更”
114 4. 使用 “生产环境地址” 打包公测版本至TestFlight 48 4. 使用 “生产环境地址” 打包公测版本至TestFlight
115 5. 发布至商店 49 5. 发布至商店
116 50
@@ -40,7 +40,6 @@ func main() { @@ -40,7 +40,6 @@ func main() {
40 flag.StringVar(&runPort, "port", "", "端口号,默认为8080") 40 flag.StringVar(&runPort, "port", "", "端口号,默认为8080")
41 flag.Parse() 41 flag.Parse()
42 42
43 -  
44 // 连接数据库 43 // 连接数据库
45 // Set client options 44 // Set client options
46 clientOptions := options.Client() 45 clientOptions := options.Client()
@@ -134,6 +133,8 @@ func main() { @@ -134,6 +133,8 @@ func main() {
134 InitController("POST", "/Tag/Remove", Api.RemoveTag, &DB.SModel{"标签管理", "删除"}) 133 InitController("POST", "/Tag/Remove", Api.RemoveTag, &DB.SModel{"标签管理", "删除"})
135 134
136 InitController("POST", "/Upload", Api.Upload, &DB.SModel{}) 135 InitController("POST", "/Upload", Api.Upload, &DB.SModel{})
  136 + Gin.POST("/UploadBASE64", Api.UploadBASE64)
  137 +
137 InitController("POST", "/UpdateItem", Api.UpdateItem, &DB.SModel{"项目管理", "修改"}) 138 InitController("POST", "/UpdateItem", Api.UpdateItem, &DB.SModel{"项目管理", "修改"})
138 InitController("POST", "/UpdateCommodity", Api.UpdateCommodity, &DB.SModel{"商品管理", "修改"}) 139 InitController("POST", "/UpdateCommodity", Api.UpdateCommodity, &DB.SModel{"商品管理", "修改"})
139 InitController("POST", "/UpdateLine", Api.UpdateLine, &DB.SModel{"线路管理", "修改"}) 140 InitController("POST", "/UpdateLine", Api.UpdateLine, &DB.SModel{"线路管理", "修改"})
@@ -160,8 +161,8 @@ func main() { @@ -160,8 +161,8 @@ func main() {
160 InitController("GET", "/Icon/Info", Api.IconInfo, &DB.SModel{}) 161 InitController("GET", "/Icon/Info", Api.IconInfo, &DB.SModel{})
161 InitController("POST", "/CheckToken", Api.CheckToken, &DB.SModel{}) 162 InitController("POST", "/CheckToken", Api.CheckToken, &DB.SModel{})
162 //InitController("/Tiles", Api.Tiles) 163 //InitController("/Tiles", Api.Tiles)
163 - InitController("POST", "/TopMenus/Update", Api.UpdateTopMenus, &DB.SModel{"菜单管理","修改"})  
164 - InitController("POST", "/TopMenus/Remove", Api.RemoveTopMenus, &DB.SModel{"菜单管理","删除"}) 164 + InitController("POST", "/TopMenus/Update", Api.UpdateTopMenus, &DB.SModel{"菜单管理", "修改"})
  165 + InitController("POST", "/TopMenus/Remove", Api.RemoveTopMenus, &DB.SModel{"菜单管理", "删除"})
165 InitController("GET", "/TopMenus/All", Api.AllTopMenus, &DB.SModel{}) 166 InitController("GET", "/TopMenus/All", Api.AllTopMenus, &DB.SModel{})
166 InitController("GET", "/RegisterDevice", Api.RegisterDevice, &DB.SModel{}) 167 InitController("GET", "/RegisterDevice", Api.RegisterDevice, &DB.SModel{})
167 InitController("POST", "/RemoveUser", Api.RemoveUser, &DB.SModel{"用户管理", "删除"}) 168 InitController("POST", "/RemoveUser", Api.RemoveUser, &DB.SModel{"用户管理", "删除"})
@@ -171,7 +172,6 @@ func main() { @@ -171,7 +172,6 @@ func main() {
171 172
172 InitController("GET", "/AllOperatorLog", Api.AllOperatorLog, &DB.SModel{"操作员日志", "查看所有"}) 173 InitController("GET", "/AllOperatorLog", Api.AllOperatorLog, &DB.SModel{"操作员日志", "查看所有"})
173 174
174 -  
175 InitController("GET", "/AllOperator", Api.AllOperator, &DB.SModel{"操作员管理", "查看所有"}) 175 InitController("GET", "/AllOperator", Api.AllOperator, &DB.SModel{"操作员管理", "查看所有"})
176 InitController("GET", "/SystemInfo", Api.SystemInfo, &DB.SModel{}) 176 InitController("GET", "/SystemInfo", Api.SystemInfo, &DB.SModel{})
177 177
@@ -180,7 +180,7 @@ func main() { @@ -180,7 +180,7 @@ func main() {
180 InitController("GET", "/SysAds/List", Api.SysAdsList, &DB.SModel{}) 180 InitController("GET", "/SysAds/List", Api.SysAdsList, &DB.SModel{})
181 InitController("POST", "/SysAds/Modify", Api.ModifySysAds, &DB.SModel{"平台广告", "修改"}) 181 InitController("POST", "/SysAds/Modify", Api.ModifySysAds, &DB.SModel{"平台广告", "修改"})
182 182
183 - InitController("GET", "/Analysls/Count", Api.Analysls, &DB.SModel{"平台数据统计","查询"}) 183 + InitController("GET", "/Analysls/Count", Api.Analysls, &DB.SModel{"平台数据统计", "查询"})
184 184
185 Gin.GET("/AllModules", Auth.Modules) 185 Gin.GET("/AllModules", Auth.Modules)
186 //InitController("/ws", Api.WsPage) 186 //InitController("/ws", Api.WsPage)
@@ -228,7 +228,7 @@ func main() { @@ -228,7 +228,7 @@ func main() {
228 228
229 // 默认情况使用配置文件中的端口号,除非在启动命令中指定-port :808x 229 // 默认情况使用配置文件中的端口号,除非在启动命令中指定-port :808x
230 _port := Config.Info.ServerPort 230 _port := Config.Info.ServerPort
231 - if runPort != ""{ 231 + if runPort != "" {
232 _port = runPort 232 _port = runPort
233 } 233 }
234 Gin.Run(_port) 234 Gin.Run(_port)