设置 TODO 完成 / 未完成
(c *gin.Context)
| 104 | |
| 105 | // 设置 TODO 完成 / 未完成 |
| 106 | func (h *WorkPlanHandler) SetDone(c *gin.Context) { |
| 107 | var req struct { |
| 108 | Hash string `json:"hash"` |
| 109 | Id int `json:"id"` |
| 110 | } |
| 111 | if err := c.ShouldBindJSON(&req); err != nil { |
| 112 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 113 | return |
| 114 | } |
| 115 | |
| 116 | pp := h.wp.GetPlan(req.Hash) |
| 117 | if pp == nil { |
| 118 | c.JSON(http.StatusBadRequest, gin.H{"error": "plan not found"}) |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | if err := pp.SetTODODone(req.Id); err != nil { |
| 123 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 124 | return |
| 125 | } |
| 126 | |
| 127 | c.JSON(http.StatusOK, gin.H{"ok": true}) |
| 128 | } |
| 129 | |
| 130 | // 获取 TODO 列表 |
| 131 | func (h *WorkPlanHandler) GetTODOs(c *gin.Context) { |
nothing calls this directly
no test coverage detected