package org.lg.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.lg.entity.user;
import org.lg.entity.wcuser;
import org.lg.service.roomlistService;
import org.lg.service.roomtypesService;
import org.lg.service.wcuserService;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.databind.util.JSONPObject;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("wechat")
public class wechatController {
@Autowired
public wcuserService wcservice;
@Autowired
public roomlistService roomlistservice;
@Autowired
public roomtypesService roomtypesservice;
//用户注册
@RequestMapping("add")
@ResponseBody
public JSONObject adduser(@RequestParam("openid") String openid,@RequestParam("name") String name,@RequestParam("sex") String sex,@RequestParam("tel") String tel,
@RequestParam("email") String email,@RequestParam("vip") String vip,HttpServletRequest request,
HttpServletResponse response,@RequestParam("userpassword") String userpassword) {
System.out.println(openid+name+sex+tel+email+vip);
Map<String, String> map = new HashMap<String, String>();
if(openid!=null) {
//判断openid在注册的列表中是否存在
wcuser queryopenid = wcservice.queryopenid(openid);
//String openid2 = queryopenid.getOpenid();
if(queryopenid!=null) {
map.put("msg","您已经注册过,请不要重复注册");
JSONObject json = JSONObject.fromObject(map);
return json;
}else{
wcservice.adduc(openid,name, sex, tel, email, vip,userpassword);
//map.put("status","succ");
map.put("msg","注册成功");
JSONObject json = JSONObject.fromObject(map);
return json;
}
}else {
wcuser wcuser1 = wcservice.queryopenid(openid);
String openid2 = wcuser1.getOpenid();
if(openid2!=null) {
map.put("msg","请不要重复注册");
JSONObject json = JSONObject.fromObject(map);
return json;
}else {
map.put("msg","完善信息");
JSONObject json = JSONObject.fromObject(map);
return json;
}
}
}
}
暂时没有评论,来抢沙发吧~