From a7b606d220dd16904e0a3b660f2c6fa06467ac3d Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Tue, 9 Mar 2021 23:21:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BE=85=E5=8A=9E=E4=BA=8B?= =?UTF-8?q?=E9=A1=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/plan.go | 30 ++++++++++++++++++------------ main.go | 3 +++ 2 files changed, 21 insertions(+), 12 deletions(-) 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")