feat: 添加和删除养护事项

This commit is contained in:
Blizzard
2026-02-10 14:57:53 +08:00
parent 556ab6baff
commit 01f8306be2
6 changed files with 172 additions and 4 deletions
+44
View File
@@ -206,3 +206,47 @@ func (a *MyPlantApi) DeletePlans(c *gin.Context) {
}
response.OkWithMsg("删除任务成功", c)
}
// AddCarePlan 添加养护事项
// @Tags 我的植物
// @Summary 添加养护事项
// @Security BearerAuth
// @accept json
// @Produce application/json
// @Param data body plantReq.CreateCarePlan true "添加养护事项"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
// @Router /plant/plan/add [post]
func (a *MyPlantApi) AddCarePlan(c *gin.Context) {
var req plantReq.AddPlans
err := c.ShouldBindJSON(&req)
if err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
err = plantService.AddCarePlan(req)
if err != nil {
global.Logger.Error("添加任务失败", zap.Error(err))
response.FailWithMsg("添加任务失败", c)
return
}
response.OkWithMsg("添加任务成功", c)
}
// DeletePlan 删除养护事项
// @Tags 我的植物
// @Summary 删除养护事项
// @Security BearerAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /plant/plan/delete [get]
func (a *MyPlantApi) DeletePlan(c *gin.Context) {
id := c.Query("id")
err := plantService.DeletePlan(id)
if err != nil {
global.Logger.Error("删除任务失败", zap.Error(err))
response.FailWithMsg("删除任务失败", c)
return
}
response.OkWithMsg("删除任务成功", c)
}