feat: 添加和删除养护事项
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"sundynix-go/model/commom/response"
|
||||
"sundynix-go/model/system"
|
||||
systemReq "sundynix-go/model/system/request"
|
||||
"sundynix-go/utils/auth"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
@@ -14,6 +15,24 @@ import (
|
||||
type UserApi struct {
|
||||
}
|
||||
|
||||
// CurrentUser
|
||||
// @tags 用户管理
|
||||
// @Summary 当前登录用户
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": {}, "msg": "添加成功"}"
|
||||
// @Router /user/info [get]
|
||||
func (u *UserApi) CurrentUser(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
user, err := userService.GetUserById(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("获取用户信息失败!", zap.Error(err))
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(user, c)
|
||||
}
|
||||
|
||||
// SaveUser
|
||||
// @tags 用户管理
|
||||
// @Summary 新增用户
|
||||
|
||||
Reference in New Issue
Block a user