1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| @RequestMapping("/enroll") @ApiImplicitParams({ @ApiImplicitParam(name="userPhone",value="用户电话",required = true), @ApiImplicitParam(name="userPassword",value="密码",required = true), @ApiImplicitParam(name="userName",value="用户名",required = true), @ApiImplicitParam(name="userCompany",value="公司",required = true), @ApiImplicitParam(name="loginName",value="平台登录账户",required = true), @ApiImplicitParam(name="loginPassword",value="平台登录密码",required = true) }) @ResponseBody public ModelAndView enroll(HttpSession session,String userPhone, String userPassword,String userName, String userCompany,String loginName,String loginPassword) throws Exception { String md5password=""; if(userPassword!=null){ //md5加密密码 md5password=AppMD5Util.MD5(userPassword); } ModelAndView modelAndView = new ModelAndView(); String res = mainService.enrollUser(userPhone,md5password,userName,userCompany,loginName,loginPassword); modelAndView.setViewName("index"); return modelAndView; }
// md5加密 public static String MD5(String s) { char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; try { byte[] btInput = s.getBytes(); // 获得MD5摘要算法的 MessageDigest 对象 MessageDigest mdInst = MessageDigest.getInstance("MD5"); // 使用指定的字节更新摘要 mdInst.update(btInput); // 获得密文 byte[] md = mdInst.digest(); // 把密文转换成十六进制的字符串形式 int j = md.length; char str[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = md[i]; str[k++] = hexDigits[byte0 >>> 4 & 0xf]; str[k++] = hexDigits[byte0 & 0xf]; } return new String(str); } catch (Exception e) { e.printStackTrace(); return null; } } // md5加密后解密 public static String JM(String inStr) { char[] a = inStr.toCharArray(); for (int i = 0; i < a.length; i++) { a[i] = (char) (a[i] ^ 't'); } String k = new String(a); return k; }
@Override public String enrollUser(String userPhone, String userPassword,String userName, String userCompany,String loginName,String loginPassword) { String res = ""; try { int i =mainMapper.findUserLoginCount(userPhone); if(i>0) { res = "此手机号已注册,请直接登录!"; return res; } TongYiUserLoginModel userLogin = new TongYiUserLoginModel(); TongYiUserAndPlatform uap = new TongYiUserAndPlatform(); //userLogin.setUserId(); userLogin.setUserPhone(userPhone); userLogin.setUserPassword(userPassword); userLogin.setUserName(userName); userLogin.setUserCompany(userCompany); userLogin.setUserRole(-1); userLogin.setUserStatus(0); //userLogin.setUserOpenId(""); //userLogin.setUserCreateTime(""); //userLogin.setUserBluetooth(); userLogin.setUserBluetoothTime(null); //userLogin.setUserCheck(""); userLogin.setUserCheckTime(null); userLogin.setUserRemark(""); userLogin.setUloginName(loginName); userLogin.setUloginPassword(loginPassword); mainMapper.saveUserLogin(userLogin); res = "注册成功"; } catch (Exception e) { res = "注册失败"; } return res; }
<select id="findUserLoginCount" resultType="int"> select count(*) from t_login_user where UserPhone = #{userPhone} </select> <insert id="saveUserLogin"> <selectKey keyProperty="userId" resultType="int" order="AFTER"> select @@identity </selectKey> INSERT INTO t_login_user(UserPhone, UserPassword, UserName, UserCompany, UserRole, UserStatus, UserOpenId, UserCreateTime, UserBluetooth, UserBluetoothTime, UserCheck, UserCheckTime, UserRemark,UloginName,UloginPassword) VALUES (#{userPhone},#{userPassword},#{userName}, #{userCompany},#{userRole},#{userStatus},#{userOpenId}, sysdate(),#{userBluetooth},#{userBluetoothTime}, #{userCheck},#{userCheckTime},#{userRemark},#{uloginName},#{uloginPassword}); </insert>
|