|
@@ -43,7 +43,7 @@ public class WxaUserApiController extends WxaController {
|
|
|
/**
|
|
|
* 登陆接口
|
|
|
*/
|
|
|
- public void login() {
|
|
|
+ public void login() {
|
|
|
String jsCode = getPara("code");
|
|
|
if (StrKit.isBlank(jsCode)) {
|
|
|
Kv data = Kv.by("errcode", 500).set("errmsg", "code is blank");
|
|
@@ -67,6 +67,7 @@ public class WxaUserApiController extends WxaController {
|
|
|
if (doctorsWechatfind == null) {
|
|
|
DoctorsWechat doctorsWechat = new DoctorsWechat();
|
|
|
doctorsWechat.setWxaOpenid(apiResult.getStr("openid"));
|
|
|
+ doctorsWechat.setDoctorId("");
|
|
|
if (!StrKit.isBlank(apiResult.getStr("unionid"))) {
|
|
|
doctorsWechat.setUnionid(apiResult.getStr("unionid"));
|
|
|
}
|
|
@@ -81,20 +82,20 @@ public class WxaUserApiController extends WxaController {
|
|
|
accessTokenCache.set("wxa:session:" + sessionId, apiResult.getJson());
|
|
|
LoginBean loginBean = new LoginBean();
|
|
|
loginBean.setSessionId(sessionId);
|
|
|
- Doctors doctors = Doctors.dao.findById(doctorsWechatfind.getDoctorId());
|
|
|
- if (doctors != null) {
|
|
|
- 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);
|
|
|
- }
|
|
|
+ Doctors doctors = Doctors.dao.findById(doctorsWechatfind.getDoctorId());
|
|
|
+ if (doctors != null) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
renderJson(new ResultBean(loginBean));
|
|
|
}
|
|
|
|
|
@@ -252,7 +253,6 @@ public class WxaUserApiController extends WxaController {
|
|
|
// String json = decrypt(encryptedData.replace(" ", "+"), iv, sessionKey);
|
|
|
ApiResult apiResult = wxaUserApi.getUserInfo(sessionKey, encryptedData.replace(" ", "+"), iv);
|
|
|
|
|
|
-
|
|
|
if (!apiResult.isSucceed()) {
|
|
|
ResultBean resultBean = new ResultBean(apiResult.getInt("errcode"), apiResult.getStr("errmsg"));
|
|
|
renderJson(resultBean);
|
|
@@ -262,21 +262,21 @@ public class WxaUserApiController extends WxaController {
|
|
|
// 同一用户,对同一个微信开放平台下的不同应用,unionid是相同的。
|
|
|
|
|
|
JSONObject object = JSON.parseObject(apiResult.getJson());
|
|
|
-
|
|
|
+
|
|
|
String phone = object.getString("purePhoneNumber");
|
|
|
if (StrKit.isBlank(phone)) {
|
|
|
renderJson(ErrorConstant.ERROR_PHONE_BLANK);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Doctors doctors = Doctors.dao.findFirst("select * from doctors where phone=?", phone);
|
|
|
if (doctors == null) {
|
|
|
renderJson(ErrorConstant.ERROR_DOCTOR_NOT_FIND);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- DoctorsWechat doctorsWechat = DoctorsWechat.dao.findFirst("select * from doctors_wechat where wxa_openid=?",sessionResult.get("openid"));
|
|
|
+
|
|
|
+ DoctorsWechat doctorsWechat = DoctorsWechat.dao.findFirst("select * from doctors_wechat where wxa_openid=?",
|
|
|
+ sessionResult.get("openid"));
|
|
|
doctorsWechat.setDoctorId(doctors.getId());
|
|
|
doctorsWechat.update();
|
|
|
LoginBean loginBean = new LoginBean();
|
|
@@ -295,7 +295,7 @@ public class WxaUserApiController extends WxaController {
|
|
|
renderJson(new ResultBean(loginBean));
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void sendSmsCode() {
|
|
|
String phone = getPara("phone");
|
|
|
String sessionId = getPara("wxa-sessionid");
|
|
@@ -304,7 +304,7 @@ public class WxaUserApiController extends WxaController {
|
|
|
renderJson(ErrorConstant.ERROR_WXA_SESSION_BLANK);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
IAccessTokenCache accessTokenCache = ApiConfigKit.getAccessTokenCache();
|
|
|
String sessionJson = accessTokenCache.get("wxa:session:" + sessionId);
|
|
|
if (StrKit.isBlank(sessionJson)) {
|
|
@@ -316,11 +316,11 @@ public class WxaUserApiController extends WxaController {
|
|
|
Boolean resultBoolean = sService.sendSmsCode(phone);
|
|
|
if (resultBoolean) {
|
|
|
renderJson(new ResultBean(Boolean.TRUE));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
renderJson(ErrorConstant.ERROR_SMS_SEND);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void checkCode() {
|
|
|
String phone = getPara("phone");
|
|
|
String code = getPara("code");
|
|
@@ -330,7 +330,7 @@ public class WxaUserApiController extends WxaController {
|
|
|
renderJson(ErrorConstant.ERROR_WXA_SESSION_BLANK);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
IAccessTokenCache accessTokenCache = ApiConfigKit.getAccessTokenCache();
|
|
|
String sessionJson = accessTokenCache.get("wxa:session:" + sessionId);
|
|
|
if (StrKit.isBlank(sessionJson)) {
|
|
@@ -346,7 +346,7 @@ public class WxaUserApiController extends WxaController {
|
|
|
if (loginBean != null) {
|
|
|
loginBean.setSessionId(sessionId);
|
|
|
renderJson(new ResultBean(loginBean));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
renderJson(ErrorConstant.ERROR_DOCTOR_NOT_FIND);
|
|
|
}
|
|
|
}
|