package com.wechat.controller;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.wechat.model.responseDto.ResultEntity;
import com.wechat.service.ForgetPasswordService;

@Controller
@RequestMapping("forgetPassword")
public class ForgetPasswordController {

	@Autowired
	private ForgetPasswordService forgetPasswordService;

//	@Autowired
//	private VerificationCodeService verificationCodeService;

	/**
	 * @author zhouyd 忘记密码
	 * 
	 * @param request
	 * @param response
	 * 
	 */
	@RequestMapping(value = "forgetPassword", method = RequestMethod.POST)
	@ResponseBody
	public ResultEntity<String> forgetPassword(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
		String line;
		StringBuilder sb = new StringBuilder();
		while ((line = br.readLine()) != null) {
			sb.append(line);
		}
		JSONObject jo = JSONObject.parseObject(sb.toString());
		// 修改密码

		return forgetPasswordService.forgetPassWord(jo, request);
	}

}
