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; } } } }
5、数据库的那些方法和接口就不写了,重点是小程序的前段和后端的交互。
到此这篇关于微信小程序以ssm做后台开发的实现示例的文章就介绍到这了,更多相关小程序ssm做后台开发内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章: