|
@@ -62,36 +62,47 @@ public class SmsService {
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
|
|
|
- public LoginBean checkCode(String phone,String code, String openid) {
|
|
|
+ /*
|
|
|
+ * 检查code是否存在和正确
|
|
|
+ */
|
|
|
+ public String checkCodeStore(String phone,String code) {
|
|
|
String cacheKey = "SMS_CODE_" + phone;
|
|
|
String content = Redis.use("weixin_doctor").get(cacheKey);
|
|
|
if (content != null && content.equals(code)) {
|
|
|
Redis.use().del(cacheKey);
|
|
|
- Doctors doctors = Doctors.dao.findFirst("select * from doctors where phone=?", phone);
|
|
|
- if (doctors == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- DoctorsWechat doctorsWechat = DoctorsWechat.dao.findFirst("select * from doctors_wechat where wxa_openid=?", openid);
|
|
|
- doctorsWechat.setDoctorId(doctors.getId());
|
|
|
- doctorsWechat.update();
|
|
|
- LoginBean loginBean = new LoginBean();
|
|
|
- doctors.setPassword("");
|
|
|
- DoctorBean doctorBean = JSON.parseObject(doctors.toJson(), DoctorBean.class);
|
|
|
- Institution institution = Institution.dao.findById(doctorBean.getInstitution_id());
|
|
|
- doctorBean.setInstitution(institution.getName());
|
|
|
- StringBuilder sb = new StringBuilder(doctorBean.getPhone());
|
|
|
- sb.replace(3, 7, "****");
|
|
|
- doctorBean.setPhone(sb.toString());
|
|
|
- String tokenKey = "TOKEN_WXA_" + StrKit.getRandomUUID();
|
|
|
- Redis.use("pc").setex("think" + tokenKey, 7200, doctors.toJson());
|
|
|
- loginBean.setDoctorBean(doctorBean);
|
|
|
- loginBean.setToken(tokenKey);
|
|
|
- return loginBean;
|
|
|
+ return content;
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * 检查code正确性
|
|
|
+ */
|
|
|
+ public LoginBean checkCode(String openid,String phone) {
|
|
|
+ Doctors doctors = Doctors.dao.findFirst("select * from doctors where phone=?", phone);
|
|
|
+ if (doctors == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ DoctorsWechat doctorsWechat = DoctorsWechat.dao.findFirst("select * from doctors_wechat where wxa_openid=?",
|
|
|
+ openid);
|
|
|
+ doctorsWechat.setDoctorId(doctors.getId());
|
|
|
+ doctorsWechat.update();
|
|
|
+ LoginBean loginBean = new LoginBean();
|
|
|
+ doctors.setPassword("");
|
|
|
+ DoctorBean doctorBean = JSON.parseObject(doctors.toJson(), DoctorBean.class);
|
|
|
+ Institution institution = Institution.dao.findById(doctorBean.getInstitution_id());
|
|
|
+ doctorBean.setInstitution(institution.getName());
|
|
|
+ StringBuilder sb = new StringBuilder(doctorBean.getPhone());
|
|
|
+ sb.replace(3, 7, "****");
|
|
|
+ doctorBean.setPhone(sb.toString());
|
|
|
+ String tokenKey = "TOKEN_WXA_" + StrKit.getRandomUUID();
|
|
|
+ Redis.use("pc").setex("think" + tokenKey, 7200, doctors.toJson());
|
|
|
+ loginBean.setDoctorBean(doctorBean);
|
|
|
+ loginBean.setToken(tokenKey);
|
|
|
+ return loginBean;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* 生成四位验证码
|
|
|
*/
|