完善待办事项管理

master
DESKTOP-4RNDQIC\29019 2021-03-09 23:21:12 +08:00
parent 26c0c0bdfd
commit a7b606d220
2 changed files with 21 additions and 12 deletions

View File

@ -158,7 +158,8 @@ func (this *PlanController) CreateUndo(c *gin.Context) {
log.Print(e.Error()) log.Print(e.Error())
return return
} }
resp.Data = nil log.Print(req.ID)
resp.Data = req.ID
resp.Msg = "OK" resp.Msg = "OK"
resp.Status = 0 resp.Status = 0
} }
@ -185,19 +186,19 @@ func (this *PlanController) UpdateUndo(c *gin.Context) {
} }
func (this *PlanController) GetUndo(c *gin.Context) { func (this *PlanController) GetUndo(c *gin.Context) {
type ReqGetUndo struct {
}
var req ReqGetUndo
resp := RespBase{} resp := RespBase{}
defer func() { defer func() {
c.JSON(200, resp) c.JSON(200, resp)
}() }()
e := c.BindJSON(&req) undos := []model.Undo{}
if nil != e { e := db.GetOrm().Model(&model.Undo{}).Find(&undos).Error
logs.Error(e.Error()) if nil != e{
log.Print(e.Error())
return return
} }
resp.Data = undos
resp.Msg = "OK"
resp.Status = 0
} }
func (this *PlanController) GetPageUndo(c *gin.Context) { 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{} resp := RespBase{}
defer func() { defer func() {
c.JSON(200, resp) c.JSON(200, resp)
}() }()
sid := c.Param("id")
type ReqDeleteUndo struct { 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"
} }

View File

@ -183,6 +183,9 @@ func main() {
api.GET("/plan_types", planController.Types) api.GET("/plan_types", planController.Types)
api.PUT("/undo",planController.CreateUndo) 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") openapi := r.Group("openapi")