Commit c57915202544b9e7940f81943c4a398954077dac
1 parent
248adced
Exists in
v1.2
and in
2 other branches
删定时任务接口
Showing
4 changed files
with
43 additions
and
2 deletions
Show diff stats
API/DealyMessage.go
@@ -20,7 +20,7 @@ func DealyMessageInfo(c *gin.Context) { | @@ -20,7 +20,7 @@ func DealyMessageInfo(c *gin.Context) { | ||
20 | c.Header("Access-Control-Allow-Credentials", "true") | 20 | c.Header("Access-Control-Allow-Credentials", "true") |
21 | 21 | ||
22 | var aDelayMessage []DelayMessage.Message | 22 | var aDelayMessage []DelayMessage.Message |
23 | - DelayMessage.CDelayMessage.Find(bson.M{"UserId": c.Query("userid")}).All(&aDelayMessage) | 23 | + DelayMessage.CDelayMessage.Find(bson.M{"UserId": c.Query("UserId")}).All(&aDelayMessage) |
24 | 24 | ||
25 | if aDelayMessage == nil { | 25 | if aDelayMessage == nil { |
26 | aDelayMessage = []DelayMessage.Message{} | 26 | aDelayMessage = []DelayMessage.Message{} |
@@ -64,3 +64,24 @@ func CreateDealyMessage(c *gin.Context) { | @@ -64,3 +64,24 @@ func CreateDealyMessage(c *gin.Context) { | ||
64 | } | 64 | } |
65 | 65 | ||
66 | } | 66 | } |
67 | + | ||
68 | +// @Title 删除提醒 | ||
69 | +// @Description 删除提醒 | ||
70 | +// @Accept json | ||
71 | +// @Produce json | ||
72 | +// @Param id 5dfb03070a9ac17ac7a82054 string true "提醒id" | ||
73 | +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" | ||
74 | +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | ||
75 | +// @Router /DealyMessage/Remove? [post] | ||
76 | +func RemoveDealyMessage(c *gin.Context) { | ||
77 | + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | ||
78 | + c.Header("Access-Control-Allow-Credentials", "true") | ||
79 | + | ||
80 | + DelayMessage.GlobalDM.DelTaskForId(c.PostForm("id")) | ||
81 | + | ||
82 | + c.JSON(200, tools.ResponseSeccess{ | ||
83 | + 0, | ||
84 | + "ok", | ||
85 | + }) | ||
86 | + | ||
87 | +} |
Lib/DelayMessage/delaymessage.go
@@ -112,7 +112,7 @@ func (dm *DelayMessage) DelTaskForId(id string) { | @@ -112,7 +112,7 @@ func (dm *DelayMessage) DelTaskForId(id string) { | ||
112 | 112 | ||
113 | CDelayMessage.Remove(bson.M{"_id": bson.ObjectIdHex(id)}) | 113 | CDelayMessage.Remove(bson.M{"_id": bson.ObjectIdHex(id)}) |
114 | i := dm.DelTask(id) | 114 | i := dm.DelTask(id) |
115 | - println(strconv.Itoa(i)) | 115 | + println("删除定时任务:",strconv.Itoa(i)) |
116 | } | 116 | } |
117 | 117 | ||
118 | func (dm *DelayMessage) Show() { | 118 | func (dm *DelayMessage) Show() { |
README.md
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | 1. [增加投诉](#createcomplaint-post) | 16 | 1. [增加投诉](#createcomplaint-post) |
17 | 1. [查询用户的定时提醒](#dealymessage-info-get) | 17 | 1. [查询用户的定时提醒](#dealymessage-info-get) |
18 | 1. [创建提醒](#dealymessage-create-post) | 18 | 1. [创建提醒](#dealymessage-create-post) |
19 | +1. [删除提醒](#dealymessage-remove-post) | ||
19 | 1. [增加访问日志](#eventlog-post) | 20 | 1. [增加访问日志](#eventlog-post) |
20 | 1. [增加调查](#investigation-save-post) | 21 | 1. [增加调查](#investigation-save-post) |
21 | 1. [查询设备信息](#iteminfo-get) | 22 | 1. [查询设备信息](#iteminfo-get) |
@@ -177,6 +178,24 @@ | @@ -177,6 +178,24 @@ | ||
177 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | 178 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | |
178 | 179 | ||
179 | 180 | ||
181 | +<a name="dealymessage-remove-post"></a> | ||
182 | + | ||
183 | +#### /DealyMessage/Remove (POST) | ||
184 | + | ||
185 | + | ||
186 | +删除提醒 | ||
187 | + | ||
188 | +| Param Name | Example | Data Type | Description | Required? | | ||
189 | +|-----|-----|-----|-----|-----| | ||
190 | +| id | 5dfb03070a9ac17ac7a82054 | string | 提醒id | Yes | | ||
191 | + | ||
192 | + | ||
193 | +| Code | Type | Model | Message | | ||
194 | +|-----|-----|-----|-----| | ||
195 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":"ok"} | | ||
196 | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | ||
197 | + | ||
198 | + | ||
180 | 199 | ||
181 | <a name="eventlog-post"></a> | 200 | <a name="eventlog-post"></a> |
182 | 201 |
main.go
@@ -94,6 +94,7 @@ func main() { | @@ -94,6 +94,7 @@ func main() { | ||
94 | r.POST("/Trajectory/Save", Api.SaveTrajectory) | 94 | r.POST("/Trajectory/Save", Api.SaveTrajectory) |
95 | r.POST("/DealyMessage/Create", Api.CreateDealyMessage) | 95 | r.POST("/DealyMessage/Create", Api.CreateDealyMessage) |
96 | r.GET("/DealyMessage/Info", Api.DealyMessageInfo) | 96 | r.GET("/DealyMessage/Info", Api.DealyMessageInfo) |
97 | + r.GET("/DealyMessage/Remove", Api.RemoveDealyMessage) | ||
97 | //r.GET("/ws", Api.WsPage) | 98 | //r.GET("/ws", Api.WsPage) |
98 | 99 | ||
99 | r.Static("/Upload", "./Upload") | 100 | r.Static("/Upload", "./Upload") |