|
@@ -1,27 +1,15 @@
|
|
|
package com.zskk.controller;
|
|
|
|
|
|
-import java.security.AlgorithmParameters;
|
|
|
-import java.security.Key;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.crypto.Cipher;
|
|
|
-import javax.crypto.spec.IvParameterSpec;
|
|
|
-import javax.crypto.spec.SecretKeySpec;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.jfinal.aop.Duang;
|
|
|
-import com.jfinal.kit.Base64Kit;
|
|
|
import com.jfinal.kit.Kv;
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
import com.jfinal.plugin.redis.Redis;
|
|
|
import com.jfinal.weixin.sdk.api.ApiConfigKit;
|
|
|
import com.jfinal.weixin.sdk.api.ApiResult;
|
|
|
import com.jfinal.weixin.sdk.cache.IAccessTokenCache;
|
|
|
-import com.jfinal.weixin.sdk.utils.Charsets;
|
|
|
import com.jfinal.wxaapp.api.WxaUserApi;
|
|
|
import com.jfinal.wxaapp.jfinal.WxaController;
|
|
|
import com.zskk.controller.bean.DoctorBean;
|
|
@@ -136,7 +124,26 @@ public class WxaUserApiController extends WxaController {
|
|
|
Doctors doctors = Doctors.dao.findById(doctorsWechat.getDoctorId());
|
|
|
LoginBean loginBean = new LoginBean();
|
|
|
loginBean.setSessionId(sessionId);
|
|
|
-// loginBean.setDoctorBean(doctors);
|
|
|
+ if (doctors != null) {
|
|
|
+ try {
|
|
|
+ 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);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ loginBean = new LoginBean();
|
|
|
+ loginBean.setSessionId(sessionId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
renderJson(new ResultBean(loginBean));
|
|
|
}
|
|
|
|
|
@@ -269,21 +276,17 @@ public class WxaUserApiController extends WxaController {
|
|
|
}
|
|
|
// 如果开发者拥有多个移动应用、网站应用、和公众帐号(包括小程序),可通过unionid来区分用户的唯一性
|
|
|
// 同一用户,对同一个微信开放平台下的不同应用,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.setDoctorId(doctors.getId());
|
|
@@ -364,7 +367,6 @@ public class WxaUserApiController extends WxaController {
|
|
|
*/
|
|
|
public void unbind() {
|
|
|
IAccessTokenCache accessTokenCache = ApiConfigKit.getAccessTokenCache();
|
|
|
-// String sessionId = getHeader("wxa-sessionid");
|
|
|
String sessionId = getPara("wxa-sessionid");
|
|
|
if (StrKit.isBlank(sessionId)) {
|
|
|
Kv data = Kv.by("errcode", 500).set("errmsg", "wxa_session Header is blank");
|
|
@@ -389,8 +391,9 @@ public class WxaUserApiController extends WxaController {
|
|
|
doctorsWechat.setDoctorId("");
|
|
|
doctorsWechat.setCreateAt(new Date());
|
|
|
doctorsWechat.update();
|
|
|
-// accessTokenCache.remove("wxa:session:" + sessionId);
|
|
|
- renderJson(new ResultBean("Unbind Account Succeed"));
|
|
|
+ LoginBean loginBean = new LoginBean();
|
|
|
+ loginBean.setSessionId(sessionId);
|
|
|
+ renderJson(new ResultBean(loginBean));
|
|
|
}
|
|
|
|
|
|
}
|