<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*,java.lang.*,org.springframework.context.ApplicationContext"%>  
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>  
<%@ page import="com.iamberry.wechat.core.entity.WechatUtils"%>
<%@ page import="com.iamberry.wechat.face.activity.answer.*"%>
<%@ page import="com.iamberry.wechat.core.entity.activity.answer.*"%>
<%@ page import="com.iamberry.wechat.core.entity.member.*"%>  

<% 
	ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application); 
	WechatUtils wechatUtils = (WechatUtils)context.getBean("wechatUtils");
	AnswerPeopleDao answerPeopleDao = (AnswerPeopleDao)context.getBean("answerPeopleDaoImpl");
	//String openid = "o3dG7wViuhImN5I0w6N0upIUVw_0";
	String openid = "";
	try {
		Member member = wechatUtils.getUserBySession(request);
		openid = member.getUserOpenid();
	} catch (Exception e) {
		e.printStackTrace();
	}
	String userName = request.getParameter("userName");
	String userPhone = request.getParameter("userPhone");
	AnswerPeople people = new AnswerPeople();
	people.setpOpenid(openid);
	people.setUserName(userName);
	people.setPhone(userPhone);
	
	String result = "";
	Integer i = answerPeopleDao.updatePeopleByOpenid(people);
	if(i > 0 ){
		result = "{\"status\":\"success\",\"msg\":\"添加用户信息成功!\"}";
	}else{
		result = "{\"status\":\"failed\",\"msg\":\"添加用户信息失败!\"}";
	}
	response.getWriter().print(result);
%>
