diff --git a/controller/plan.go b/controller/plan.go index a13dd05..809018d 100644 --- a/controller/plan.go +++ b/controller/plan.go @@ -158,7 +158,8 @@ func (this *PlanController) CreateUndo(c *gin.Context) { log.Print(e.Error()) return } - resp.Data = nil + log.Print(req.ID) + resp.Data = req.ID resp.Msg = "OK" resp.Status = 0 } @@ -185,19 +186,19 @@ func (this *PlanController) UpdateUndo(c *gin.Context) { } func (this *PlanController) GetUndo(c *gin.Context) { - type ReqGetUndo struct { - } - var req ReqGetUndo resp := RespBase{} defer func() { c.JSON(200, resp) }() - e := c.BindJSON(&req) - if nil != e { - logs.Error(e.Error()) + undos := []model.Undo{} + e := db.GetOrm().Model(&model.Undo{}).Find(&undos).Error + if nil != e{ + log.Print(e.Error()) return } - + resp.Data = undos + resp.Msg = "OK" + resp.Status = 0 } func (this *PlanController) GetPageUndo(c *gin.Context) { @@ -227,13 +228,18 @@ func (this *PlanController) GetPageUndo(c *gin.Context) { } -func DeleteUndo(c *gin.Context) { +func (this *PlanController) DeleteUndo(c *gin.Context) { resp := RespBase{} defer func() { c.JSON(200, resp) }() - - type ReqDeleteUndo struct { + sid := c.Param("id") + id := db.Atoi(sid) + e := db.GetOrm().Model(&model.Undo{}).Delete(&model.Undo{ID: int32(id)}).Error + if nil != e{ + log.Print(e.Error()) + return } - + resp.Status = 0 + resp.Msg = "OK" } diff --git a/main.go b/main.go index 4ef6e5b..ffee060 100644 --- a/main.go +++ b/main.go @@ -183,6 +183,9 @@ func main() { api.GET("/plan_types", planController.Types) api.PUT("/undo",planController.CreateUndo) + api.POST("/undo",planController.UpdateUndo) + api.GET("/undo",planController.GetUndo) + api.DELETE("/undo/:id",planController.DeleteUndo) } openapi := r.Group("openapi")