|
@@ -28,12 +28,14 @@ public class JzPeiXunController {
|
|
|
@RequestMapping(value = "/sendsms", method = RequestMethod.POST)
|
|
|
// public ResponseEntity sendSMSLogin(@RequestParam String telephoneNo, @RequestParam int type){
|
|
|
public ResponseEntity sendSMSLogin(@RequestBody JSONObject data) {
|
|
|
+// ResponseEntity responseEntity = null;
|
|
|
+ if (data.equals(null)){
|
|
|
+ return new ResponseEntity().failure("404","输入值为null");
|
|
|
+ }
|
|
|
|
|
|
- String telephoneNo = data.getString("telephoneNo");
|
|
|
- Integer type = data.getInteger("type");
|
|
|
-
|
|
|
- ResponseEntity responseEntity = null;
|
|
|
try {
|
|
|
+ String telephoneNo = data.getString("telephoneNo");
|
|
|
+ Integer type = data.getInteger("type");
|
|
|
if (PhoneFormatCheckUtils.isChinaPhoneLegal(telephoneNo) == true && PhoneFormatCheckUtils.isNumeric(String.valueOf(type))) {
|
|
|
//发短信息,手机号与短息验证码写入redis
|
|
|
SmsUtils smsUtils = new SmsUtils();
|
|
@@ -48,9 +50,10 @@ public class JzPeiXunController {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- return responseEntity.failure(ResponseConstant.CODE_000, "");
|
|
|
+ return new ResponseEntity().success(ResponseConstant.CODE_000,"短息验证码发送失败");
|
|
|
+
|
|
|
}
|
|
|
- return responseEntity;
|
|
|
+ return new ResponseEntity().success("200","短息验证发送成功");
|
|
|
}
|
|
|
|
|
|
//2.手机号+短信验证码,注册登录
|
|
@@ -58,6 +61,9 @@ public class JzPeiXunController {
|
|
|
public ResponseEntity SmsLogin(@RequestBody JSONObject data) {
|
|
|
ResponseEntity responseEntity = null;
|
|
|
HashMap map = new HashMap();
|
|
|
+ if (data.equals(null)){
|
|
|
+ return new ResponseEntity().failure("404","输入值为null");
|
|
|
+ }
|
|
|
try {
|
|
|
String telephoneNo = data.getString("telephoneNo");
|
|
|
String smsCode = data.getString("smsCode");
|
|
@@ -69,15 +75,21 @@ public class JzPeiXunController {
|
|
|
System.out.println(code1+"map存储获取的验证码");
|
|
|
if (code1.equals(smsCode)){
|
|
|
//执行登录操作
|
|
|
+ System.out.println("创建用户id111");
|
|
|
User user = jzPeiXunService.getUserInfoByTelePhone(telephoneNo);
|
|
|
- if (user.equals(null)) {
|
|
|
+ System.out.println("创建用户id222");
|
|
|
+ if (user==null) {
|
|
|
//注册用户 ---- 兼职教师登录
|
|
|
- jzPeiXunService.addUser(telephoneNo);
|
|
|
+ System.out.println("创建用户id333");
|
|
|
+ System.out.println("创建用户id");
|
|
|
+ Integer userid =jzPeiXunService.addUser(telephoneNo);
|
|
|
+ System.out.println("创建用户id"+userid);
|
|
|
+ map.put("userid",userid);
|
|
|
jzPeiXunService.authLogin(telephoneNo, smsCode);
|
|
|
} else {
|
|
|
//直接登录 --- 已注册兼职教师后者管理员登录
|
|
|
jzPeiXunService.authLogin(telephoneNo, smsCode);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -85,10 +97,9 @@ public class JzPeiXunController {
|
|
|
return new ResponseEntity().failure("404", "登录失败");
|
|
|
}
|
|
|
System.out.println("登录成功");
|
|
|
- return new ResponseEntity().success("505", "登录成功");
|
|
|
+ return new ResponseEntity().success("200", "登录成功",map);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//3.用户退出
|
|
|
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
|
|
public ResponseEntity logout() {
|
|
@@ -135,6 +146,7 @@ public class JzPeiXunController {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ System.out.println("------接口3---用户资料编辑成功-------");
|
|
|
return new ResponseEntity().success("", "用户资料编辑成功");
|
|
|
}
|
|
|
|
|
@@ -148,9 +160,11 @@ public class JzPeiXunController {
|
|
|
try {
|
|
|
Integer userId = data.getInteger("userid");
|
|
|
user = jzPeiXunService.getUserInfo(userId);
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ System.out.println("------接口4---获取用户资料成功-------");
|
|
|
return new ResponseEntity().success(user, "获取用户资料成功");
|
|
|
}
|
|
|
|
|
@@ -165,6 +179,7 @@ public class JzPeiXunController {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ System.out.println("------接口5---获取教师状态成功-------");
|
|
|
return list;
|
|
|
}
|
|
|
|