package plant import ( "sundynix-go/model/commom/response" "sundynix-go/model/plant/request" "sundynix-go/utils/auth" "github.com/gin-gonic/gin" ) type UserProfileApi struct{} // UpdateProfile 修改用户信息 // @Tags 个人中心 // @Summary 修改用户信息 // @Security BearerAuth // @accept json // @Produce application/json // @Param data body request.UpdateProfile true "修改用户信息" // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /profile/update [post] func (a *UserProfileApi) UpdateProfile(c *gin.Context) { var req request.UpdateProfile if err := c.ShouldBindJSON(&req); err != nil { response.FailWithMsg("请求参数错误", c) return } userId := auth.GetUserId(c) if err := userProfileService.UpdateProfile(req, userId); err != nil { response.FailWithMsg("更新失败", c) return } response.OkWithMsg("更新成功", c) } // ProfileDetail 用户详情 // @Tags 个人中心 // @Summary 用户详情 // @Security BearerAuth // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /profile/detail [get] func (a *UserProfileApi) ProfileDetail(c *gin.Context) { userId := auth.GetUserId(c) res, err := userProfileService.ProfileDetail(userId) if err != nil { response.FailWithMsg("查询失败", c) return } response.OkWithData(res, c) }