temp
This commit is contained in:
@@ -213,6 +213,33 @@ func (h *UserHandler) ChangePassword(c *gin.Context) {
|
||||
h.response.Success(c, nil, "密码修改成功")
|
||||
}
|
||||
|
||||
// ResetPassword 重置密码
|
||||
// @Summary 重置密码
|
||||
// @Description 使用手机号、验证码和新密码重置用户密码(忘记密码时使用)
|
||||
// @Tags 用户认证
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body commands.ResetPasswordCommand true "重置密码请求"
|
||||
// @Success 200 {object} map[string]interface{} "密码重置成功"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误或验证码无效"
|
||||
// @Failure 404 {object} map[string]interface{} "用户不存在"
|
||||
// @Failure 500 {object} map[string]interface{} "服务器内部错误"
|
||||
// @Router /api/v1/users/reset-password [post]
|
||||
func (h *UserHandler) ResetPassword(c *gin.Context) {
|
||||
var cmd commands.ResetPasswordCommand
|
||||
if err := h.validator.BindAndValidate(c, &cmd); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.appService.ResetPassword(c.Request.Context(), &cmd); err != nil {
|
||||
h.logger.Error("重置密码失败", zap.Error(err))
|
||||
h.response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
h.response.Success(c, nil, "密码重置成功")
|
||||
}
|
||||
|
||||
// getCurrentUserID 获取当前用户ID
|
||||
func (h *UserHandler) getCurrentUserID(c *gin.Context) string {
|
||||
if userID, exists := c.Get("user_id"); exists {
|
||||
|
||||
Reference in New Issue
Block a user