添加 TODO
(c *gin.Context)
| 28 | |
| 29 | // 添加 TODO |
| 30 | func (h *WorkPlanHandler) AddTODO(c *gin.Context) { |
| 31 | var req struct { |
| 32 | Hash string `json:"hash"` |
| 33 | Content string `json:"content"` |
| 34 | } |
| 35 | if err := c.ShouldBindJSON(&req); err != nil { |
| 36 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 37 | return |
| 38 | } |
| 39 | |
| 40 | pp := h.wp.GetPlan(req.Hash) |
| 41 | if pp == nil { |
| 42 | c.JSON(http.StatusBadRequest, gin.H{"error": "plan not found"}) |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | if err := pp.AddTODO(req.Content); err != nil { |
| 47 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | c.JSON(http.StatusOK, gin.H{"ok": true}) |
| 52 | } |
| 53 | |
| 54 | // 删除 TODO |
| 55 | func (h *WorkPlanHandler) DeleteTODO(c *gin.Context) { |