Commit c57915202544b9e7940f81943c4a398954077dac

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

删定时任务接口

API/DealyMessage.go
... ... @@ -20,7 +20,7 @@ func DealyMessageInfo(c *gin.Context) {
20 20 c.Header("Access-Control-Allow-Credentials", "true")
21 21  
22 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 25 if aDelayMessage == nil {
26 26 aDelayMessage = []DelayMessage.Message{}
... ... @@ -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 112  
113 113 CDelayMessage.Remove(bson.M{"_id": bson.ObjectIdHex(id)})
114 114 i := dm.DelTask(id)
115   - println(strconv.Itoa(i))
  115 + println("删除定时任务:",strconv.Itoa(i))
116 116 }
117 117  
118 118 func (dm *DelayMessage) Show() {
... ...
README.md
... ... @@ -16,6 +16,7 @@
16 16 1. [增加投诉](#createcomplaint-post)
17 17 1. [查询用户的定时提醒](#dealymessage-info-get)
18 18 1. [创建提醒](#dealymessage-create-post)
  19 +1. [删除提醒](#dealymessage-remove-post)
19 20 1. [增加访问日志](#eventlog-post)
20 21 1. [增加调查](#investigation-save-post)
21 22 1. [查询设备信息](#iteminfo-get)
... ... @@ -177,6 +178,24 @@
177 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 200 <a name="eventlog-post"></a>
182 201  
... ...
main.go
... ... @@ -94,6 +94,7 @@ func main() {
94 94 r.POST("/Trajectory/Save", Api.SaveTrajectory)
95 95 r.POST("/DealyMessage/Create", Api.CreateDealyMessage)
96 96 r.GET("/DealyMessage/Info", Api.DealyMessageInfo)
  97 + r.GET("/DealyMessage/Remove", Api.RemoveDealyMessage)
97 98 //r.GET("/ws", Api.WsPage)
98 99  
99 100 r.Static("/Upload", "./Upload")
... ...