Commit da5bf47446eb9597fa6cb7d88abcffd549053521

Authored by aarongao
1 parent e4cd450a
Exists in v1.2 and in 2 other branches master, v1.1

..

API/Complaint.go
... ... @@ -4,12 +4,15 @@ import (
4 4 "encoding/json"
5 5 "github.com/aarongao/tools"
6 6 "github.com/gin-gonic/gin"
  7 + "gopkg.in/mgo.v2/bson"
7 8 "letu/DB"
  9 + "math"
8 10 "regexp"
  11 + "strconv"
9 12 )
10 13  
11 14 // @Title 增加投诉
12   -// @Description 增加投诉
  15 +// @Description 投诉 - 增加投诉
13 16 // @Accept json
14 17 // @Produce json
15 18 // @Param Mobile 18616619599 string true "联系电话"
... ... @@ -60,11 +63,6 @@ func CreateComplaint(c *gin.Context) {
60 63  
61 64 }
62 65  
63   -
64   -
65   -
66   -
67   -
68 66 var images []string
69 67  
70 68 json.Unmarshal([]byte(c.PostForm("Image")), &images)
... ... @@ -86,3 +84,44 @@ func CreateComplaint(c *gin.Context) {
86 84  
87 85  
88 86 }
  87 +
  88 +
  89 +
  90 +
  91 +
  92 +// @Title 查询所有投诉
  93 +// @Description 投诉 - 查询所有投诉
  94 +// @Accept json
  95 +// @Produce json
  96 +// @Param Page 1 int true "当前第几页"
  97 +// @Success 200 {object} tools.ResponseSeccess ""
  98 +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
  99 +// @Router /AllComplaint? [get]
  100 +func AllComplaint(c *gin.Context) {
  101 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  102 + c.Header("Access-Control-Allow-Credentials", "true")
  103 +
  104 + total,_ := DB.CComplaint.Find(bson.M{}).Count()
  105 + limit,_ := strconv.Atoi(c.Query("Limit"))
  106 + if limit == 0 {
  107 + limit = 50
  108 + }
  109 + currPage, _ := strconv.Atoi(c.Query("Page"))
  110 + if currPage == 0 {
  111 + currPage = 1
  112 + }
  113 + skip := (currPage - 1) * limit
  114 +
  115 + var aComplaint = []DB.SComplaint{}
  116 + DB.CComplaint.Find(bson.M{}).Limit(limit).Skip(int(skip)).Sort("-_id").All(&aComplaint)
  117 +
  118 + c.JSON(200, tools.Page{
  119 + 0,
  120 + total,
  121 + currPage,
  122 + int(math.Ceil(float64(total) / float64(limit))),
  123 + limit,
  124 + aComplaint,
  125 + })
  126 +
  127 +}
89 128 \ No newline at end of file
... ...
API/Investigation.go
... ... @@ -4,11 +4,14 @@ import (
4 4 "encoding/json"
5 5 "github.com/aarongao/tools"
6 6 "github.com/gin-gonic/gin"
  7 + "gopkg.in/mgo.v2/bson"
7 8 "letu/DB"
  9 + "math"
  10 + "strconv"
8 11 )
9 12  
10 13 // @Title 增加调查
11   -// @Description 增加调查
  14 +// @Description 问券调查 - 增加调查
12 15 // @Accept json
13 16 // @Produce json
14 17 // @Param UserId 1111111 string true "UserId"
... ... @@ -36,3 +39,41 @@ func SaveInvestigation(c *gin.Context) {
36 39 })
37 40  
38 41 }
  42 +
  43 +// @Title 查询所有问券调查
  44 +// @Description 问券调查 - 查询所有问券调查
  45 +// @Accept json
  46 +// @Produce json
  47 +// @Param Page 1 int true "当前第几页"
  48 +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"total":1,"currpage":1,"totalpages":1,"prepage":20,"result":}"
  49 +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
  50 +// @Router /Investigation/List? [get]
  51 +func AllInvestigation(c *gin.Context) {
  52 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  53 + c.Header("Access-Control-Allow-Credentials", "true")
  54 +
  55 +
  56 + total,_ := DB.CComplaint.Find(bson.M{}).Count()
  57 + limit,_ := strconv.Atoi(c.Query("Limit"))
  58 + if limit == 0 {
  59 + limit = 50
  60 + }
  61 + currPage, _ := strconv.Atoi(c.Query("Page"))
  62 + if currPage == 0 {
  63 + currPage = 1
  64 + }
  65 + skip := (currPage - 1) * limit
  66 +
  67 + var aInvestigation []DB.SInvestigation
  68 + DB.CInvestigation.Find(bson.M{}).Limit(limit).Skip(int(skip)).Sort("-_id").All(&aInvestigation)
  69 +
  70 + c.JSON(200, tools.Page{
  71 + 0,
  72 + total,
  73 + currPage,
  74 + int(math.Ceil(float64(total) / float64(limit))),
  75 + limit,
  76 + aInvestigation,
  77 + })
  78 +
  79 +}
... ...
API/Item.go
... ... @@ -6,6 +6,7 @@ import (
6 6 "github.com/gin-gonic/gin"
7 7 "gopkg.in/mgo.v2/bson"
8 8 "letu/DB"
  9 + "strconv"
9 10 "time"
10 11 )
11 12  
... ... @@ -14,7 +15,7 @@ import (
14 15 // @Accept json
15 16 // @Produce json
16 17 // @Param id 5dfb03070a9ac17ac7a82054 string true "设备id"
17   -// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Name":"名称","Describe":"介绍","OpenHours":"开放时间","Mobile":"电话","Address":"地址","SLocation":{"Latitude":0,"Longitude":0},"Picture":["照片1","照片2"]}}"
  18 +// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运"
18 19 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
19 20 // @Router /ItemInfo? [get]
20 21 func ItemInfo(c *gin.Context) {
... ... @@ -43,14 +44,14 @@ func ItemInfo(c *gin.Context) {
43 44 // @Description 设备管理 - 查询所有游玩项目
44 45 // @Accept json
45 46 // @Produce json
46   -// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单"
  47 +// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运"
47 48 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
48 49 // @Router /AllItems? [get]
49 50 func AllItems(c *gin.Context) {
50 51 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
51 52 c.Header("Access-Control-Allow-Credentials", "true")
52 53  
53   - var aItems []DB.SItem
  54 + var aItems = []DB.SItem{}
54 55 DB.CItem.Find(bson.M{}).All(&aItems)
55 56  
56 57 c.JSON(200, aItems)
... ... @@ -61,7 +62,7 @@ func AllItems(c *gin.Context) {
61 62 // @Description 设备管理 - 更新设施
62 63 // @Accept json
63 64 // @Produce json
64   -// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单"
  65 +// @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运"
65 66 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
66 67 // @Router /UpdateItem? [post]
67 68 func UpdateItem(c *gin.Context) {
... ... @@ -84,22 +85,27 @@ func UpdateItem(c *gin.Context) {
84 85 id = bson.ObjectIdHex(pid)
85 86 }
86 87  
  88 + poststate, _ := strconv.Atoi(c.PostForm("State"))
87 89 DB.CItem.UpsertId(
88 90 id,
89 91 bson.M{"$set": bson.M{
90   - "Name": c.PostForm("Name"),
91   - "SubName": c.PostForm("SubName"),
92   - "Location": Location,
93   - "Icon": c.PostForm("Icon"),
94   - "LimitHeight": c.PostForm("LimitHeight"),
95   - "PlayDuration": c.PostForm("PlayDuration"),
96   - "SceneTime": c.PostForm("SceneTime"),
97   - "Picture": Picture,
98   - "Voice": c.PostForm("Voice"),
99   - "Tel": c.PostForm("Tel"),
100   - "AverageConsumption": c.PostForm("AverageConsumption"),
101   - "Menu": c.PostForm("Menu"),
102   - "Tags": Tags,
  92 + "Name": c.PostForm("Name"),
  93 + "SubName": c.PostForm("SubName"),
  94 + "Location": Location,
  95 + "Icon": c.PostForm("Icon"),
  96 + "LimitHeight": c.PostForm("LimitHeight"),
  97 + "PlayDuration": c.PostForm("PlayDuration"),
  98 + "SceneTime": c.PostForm("SceneTime"),
  99 + "Picture": Picture,
  100 + "Voice": c.PostForm("Voice"),
  101 + "Tel": c.PostForm("Tel"),
  102 + "AverageConsumption": c.PostForm("AverageConsumption"),
  103 + "Menu": c.PostForm("Menu"),
  104 + "Tags": Tags,
  105 + "OpenHours": c.PostForm("OpenHours"),
  106 + "LocationDescription": c.PostForm("LocationDescription"),
  107 + "Reminder": c.PostForm("Reminder"),
  108 + "State": poststate,
103 109 }},
104 110 )
105 111  
... ... @@ -135,7 +141,6 @@ func UpdateItemTime(c *gin.Context) {
135 141 RedisData[v.Id] = v.Time
136 142 }
137 143  
138   -
139 144 DB.Redis.Set("AllItemTime", RedisData, time.Second*60*60*24*30)
140 145 c.JSON(200, tools.ResponseSeccess{
141 146 0,
... ... @@ -144,7 +149,6 @@ func UpdateItemTime(c *gin.Context) {
144 149  
145 150 }
146 151  
147   -
148 152 // @Title 获得所有设备的等待时间
149 153 // @Description 设备管理 - 获得所有设备的等待时间
150 154 // @Accept json
... ... @@ -160,11 +164,10 @@ func AllItemTime(c *gin.Context) {
160 164 json.Unmarshal([]byte(c.PostForm("items")), &ItemTime)
161 165  
162 166 allteim := DB.Redis.Get("AllItemTime")
163   - if allteim != nil{
  167 + if allteim != nil {
164 168 c.JSON(200, allteim)
165   - }else{
  169 + } else {
166 170 c.String(200, "{}")
167 171 }
168 172  
169   -
170 173 }
... ...
DB/db.go
... ... @@ -23,21 +23,25 @@ var CTrajectory *mgo.Collection //移动轨迹
23 23 var DB *mgo.Database
24 24  
25 25 type SItem struct {
26   - Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
27   - Name string `bson:"Name" json:"Name"`
28   - SubName string `bson:"SubName" json:"SubName"`
29   - Location SLocation `bson:"Location" json:"Location"`
30   - Tags []STag `bson:"Tags" json:"Tags"`
31   - Icon string `bson:"Icon" json:"Icon"`
32   - LimitHeight string `bson:"LimitHeight" json:"LimitHeight"` //限高
33   - PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` //游玩时长
34   - SceneTime string `bson:"SceneTime" json:"SceneTime"` //场次时间
35   - Picture []string `bson:"Picture" json:"Picture"`
36   - Voice string `bson:"Voice" json:"Voice"` //音频
37   - Tel string `bson:"Tel" json:"Tel"`
38   - AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"` //人均消费
39   - Menu string `bson:"Menu" json:"Menu"` //菜单
40   - Time string `bson:"Time" json:"Time"`
  26 + Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
  27 + Name string `bson:"Name" json:"Name"`
  28 + SubName string `bson:"SubName" json:"SubName"`
  29 + Location SLocation `bson:"Location" json:"Location"`
  30 + Tags []STag `bson:"Tags" json:"Tags"`
  31 + Icon string `bson:"Icon" json:"Icon"`
  32 + LimitHeight string `bson:"LimitHeight" json:"LimitHeight"` //限高
  33 + PlayDuration string `bson:"PlayDuration" json:"PlayDuration"` //游玩时长
  34 + SceneTime string `bson:"SceneTime" json:"SceneTime"` //场次时间
  35 + Picture []string `bson:"Picture" json:"Picture"`
  36 + Voice string `bson:"Voice" json:"Voice"` //音频
  37 + Tel string `bson:"Tel" json:"Tel"`
  38 + AverageConsumption string `bson:"AverageConsumption" json:"AverageConsumption"` //人均消费
  39 + Menu string `bson:"Menu" json:"Menu"` //目录
  40 + Time string `bson:"Time" json:"Time"`
  41 + OpenHours string `bson:"OpenHours" json:"OpenHours"` //开放时间
  42 + LocationDescription string `bson:"LocationDescription" json:"LocationDescription"` //位置描述
  43 + Reminder string `bson:"Reminder" json:"Reminder"` //温馨提示
  44 + State int `bson:"State" json:"State"` // 运行状态0=正常1=停运
41 45 }
42 46 type STrajectory struct {
43 47 UserId string `bson:"UserId" json:"UserId"` // 用户ID
... ...
README.md
... ... @@ -9,17 +9,19 @@
9 9  
10 10 ### API List
11 11 1. [查询所有商品](#allcommodity-get)
  12 +1. [投诉 - 查询所有投诉](#allcomplaint-get)
12 13 1. [设备管理 - 获得所有设备的等待时间](#allitemtime-get)
13 14 1. [设备管理 - 查询所有游玩项目](#allitems-get)
14 15 1. [查询所有线路](#allline-get)
15 16 1. [所有景区基础信息](#allscenic-get)
16 17 1. [查询商品信息](#commodityinfo-get)
17   -1. [增加投诉](#createcomplaint-post)
  18 +1. [投诉 - 增加投诉](#createcomplaint-post)
18 19 1. [查询用户的定时提醒](#dealymessage-info-get)
19 20 1. [创建提醒](#dealymessage-create-post)
20 21 1. [删除提醒](#dealymessage-remove-post)
21 22 1. [增加访问日志](#eventlog-post)
22   -1. [增加调查](#investigation-save-post)
  23 +1. [问券调查 - 增加调查](#investigation-save-post)
  24 +1. [问券调查 - 查询所有问券调查](#investigation-list-get)
23 25 1. [设备管理 - 查询设备信息](#iteminfo-get)
24 26 1. [查询线路信息](#lineinfo-get)
25 27 1. [用户管理 - 用户登录&注册](#loginuser-post)
... ... @@ -52,6 +54,25 @@
52 54  
53 55  
54 56  
  57 +<a name="allcomplaint-get"></a>
  58 +
  59 +#### /AllComplaint (GET)
  60 +
  61 +
  62 +投诉 - 查询所有投诉
  63 +
  64 +| Param Name | Example | Data Type | Description | Required? |
  65 +|-----|-----|-----|-----|-----|
  66 +| Page | 1 | int | 当前第几页 | Yes |
  67 +
  68 +
  69 +| Code | Type | Model | Message |
  70 +|-----|-----|-----|-----|
  71 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | |
  72 +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
  73 +
  74 +
  75 +
55 76 <a name="allitemtime-get"></a>
56 77  
57 78 #### /AllItemTime (GET)
... ... @@ -75,7 +96,7 @@
75 96  
76 97 | Code | Type | Model | Message |
77 98 |-----|-----|-----|-----|
78   -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单 |
  99 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运 |
79 100 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
80 101  
81 102  
... ... @@ -132,7 +153,7 @@
132 153 #### /CreateComplaint (POST)
133 154  
134 155  
135   -增加投诉
  156 +投诉 - 增加投诉
136 157  
137 158 | Param Name | Example | Data Type | Description | Required? |
138 159 |-----|-----|-----|-----|-----|
... ... @@ -242,7 +263,7 @@
242 263 #### /Investigation/Save (POST)
243 264  
244 265  
245   -增加调查
  266 +问券调查 - 增加调查
246 267  
247 268 | Param Name | Example | Data Type | Description | Required? |
248 269 |-----|-----|-----|-----|-----|
... ... @@ -257,6 +278,24 @@
257 278 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
258 279  
259 280  
  281 +<a name="investigation-list-get"></a>
  282 +
  283 +#### /Investigation/List (GET)
  284 +
  285 +
  286 +问券调查 - 查询所有问券调查
  287 +
  288 +| Param Name | Example | Data Type | Description | Required? |
  289 +|-----|-----|-----|-----|-----|
  290 +| Page | 1 | int | 当前第几页 | Yes |
  291 +
  292 +
  293 +| Code | Type | Model | Message |
  294 +|-----|-----|-----|-----|
  295 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"total":1,"currpage":1,"totalpages":1,"prepage":20,"result":} |
  296 +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
  297 +
  298 +
260 299  
261 300 <a name="iteminfo-get"></a>
262 301  
... ... @@ -272,7 +311,7 @@
272 311  
273 312 | Code | Type | Model | Message |
274 313 |-----|-----|-----|-----|
275   -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":{"Name":"名称","Describe":"介绍","OpenHours":"开放时间","Mobile":"电话","Address":"地址","SLocation":{"Latitude":0,"Longitude":0},"Picture":["照片1","照片2"]}} |
  314 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运 |
276 315 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
277 316  
278 317  
... ... @@ -412,7 +451,7 @@
412 451  
413 452 | Code | Type | Model | Message |
414 453 |-----|-----|-----|-----|
415   -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单 |
  454 +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运 |
416 455 | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} |
417 456  
418 457  
... ...
main.go
... ... @@ -74,6 +74,7 @@ func main() {
74 74 r.GET("/ItemInfo", Api.ItemInfo)
75 75 r.GET("/CommodityInfo", Api.CommodityInfo)
76 76 r.POST("/CreateComplaint", Api.CreateComplaint)
  77 + r.GET("/AllComplaint", Api.AllComplaint)
77 78 //r.POST("/CreateUser", Api.CreateUser)
78 79 r.POST("/LoginUser", Api.LoginUser)
79 80 r.POST("/UpdateUser", Api.UpdateUser)
... ... @@ -92,6 +93,7 @@ func main() {
92 93 r.GET("/EventLog", Api.EventLog)
93 94 r.POST("/Sms/Send", Api.Send)
94 95 r.POST("/Investigation/Save", Api.SaveInvestigation)
  96 + r.GET("/Investigation/List", Api.AllInvestigation)
95 97 r.POST("/Trajectory/Save", Api.SaveTrajectory)
96 98 r.POST("/DealyMessage/Create", Api.CreateDealyMessage)
97 99 r.GET("/DealyMessage/Info", Api.DealyMessageInfo)
... ...