|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.jw.security.oauth2.provider.endpoint;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
|
@ -2404,16 +2405,19 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (wlyyHospitalSysDictDO!=null){
|
|
|
isNeedGeet=wlyyHospitalSysDictDO.getDictValue();
|
|
|
}
|
|
|
if ("1".equalsIgnoreCase(isNeedGeet)){
|
|
|
String geetestChallenge = parameters.get("geetestChallenge");
|
|
|
String geetestValidate = parameters.get("geetestValidate");
|
|
|
String geetestSeccode = parameters.get("geetestSeccode");
|
|
|
JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
throw new Exception("验证失败");
|
|
|
}
|
|
|
if (parameters.get("mobile")==null){
|
|
|
if ("1".equalsIgnoreCase(isNeedGeet)){
|
|
|
String geetestChallenge = parameters.get("geetestChallenge");
|
|
|
String geetestValidate = parameters.get("geetestValidate");
|
|
|
String geetestSeccode = parameters.get("geetestSeccode");
|
|
|
JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"1");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
throw new Exception("验证失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//图形验证码验证
|
|
|
String key = parameters.get("key");
|
|
|
String text = parameters.get("text");
|
|
@ -2441,7 +2445,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
if (!object.getString("code").equalsIgnoreCase("200")){
|
|
|
throw new Exception(object.getString("msg"));
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
|
return getFailedResponse(object.getString("msg"),-1,userSimple);
|
|
|
}else {
|
|
|
JSONObject jsonObject = object.getJSONObject("data");
|
|
|
if (jsonObject!=null){
|
|
@ -2597,7 +2602,182 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
}
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
} else if (!StringUtils.isEmpty(loginType)&&"3".equalsIgnoreCase(loginType)){
|
|
|
}else if (parameters.get("mobile") != null) {
|
|
|
KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
|
|
|
String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
|
|
|
logger.info("mobile:"+mobile);
|
|
|
String password = null;
|
|
|
String res = ykyyService.getPatientPhone(mobile);
|
|
|
if (res!=null&&res!=""){
|
|
|
JSONObject object = JSONObject.parseObject(res);
|
|
|
if (object.getString("code").equalsIgnoreCase("200")){
|
|
|
password = object.getString("data");
|
|
|
}else {
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
|
return getFailedResponse(object.getString("msg"),-1,userSimple);
|
|
|
}
|
|
|
}
|
|
|
String response = ykyyService.yktLogin(parameters.get("username"),password);
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
if (!object.getString("code").equalsIgnoreCase("200")){
|
|
|
throw new Exception(object.getString("msg"));
|
|
|
}else {
|
|
|
JSONObject jsonObject = object.getJSONObject("data");
|
|
|
if (jsonObject!=null){
|
|
|
String userId= jsonObject.getString("ID");
|
|
|
String tel = jsonObject.getString("LOGINID");
|
|
|
List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(tel);
|
|
|
if (basePatientDOS==null||basePatientDOS.size()==0){
|
|
|
BasePatientDO basePatientDO = new BasePatientDO();
|
|
|
String familyList = ykyyService.getFamilyList(null,userId);
|
|
|
JSONObject familyJson = JSONObject.parseObject(familyList);
|
|
|
if (familyJson.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = familyJson.getJSONObject("data");
|
|
|
JSONArray list = object1.getJSONArray("list");
|
|
|
List<String> iliness = new ArrayList<>();
|
|
|
if (list!=null&&list.size()!=0){
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
JSONObject family = list.getJSONObject(i);
|
|
|
iliness.add(family.getString("ILLNESS"));
|
|
|
if (family.getString("ILLNESS").equalsIgnoreCase("本人")&&tel.equalsIgnoreCase(family.getString("TEL"))){
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setName(family.getString("NAME"));
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setYktId(family.getString("ID"));
|
|
|
basePatientDO.setUserId(userId);
|
|
|
basePatientDO.setIdcard(family.getString("IDCARD"));
|
|
|
String idcard = family.getString("IDCARD");
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(idcard);
|
|
|
String sex = IdCardUtil.getSexForIdcard_new(idcard);
|
|
|
Integer sexx = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex)){
|
|
|
sexx = Integer.parseInt(sex);
|
|
|
}
|
|
|
String birthDay = family.getString("BIRTHDAY");
|
|
|
Date birthday = null;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthDay)){
|
|
|
birthday = DateUtil.strToDate(birthDay+" 00:00:00");;
|
|
|
}
|
|
|
basePatientDO.setBirthday(birthday);
|
|
|
basePatientDO.setSex(sexx);
|
|
|
basePatientDO.setMobile(tel);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = idcard.substring(idcard.length()-6,idcard.length());
|
|
|
basePatientDO.setIdcard(idcard);
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setVerifyCode(jsonObject.getString("TOKEN"));
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
}else {
|
|
|
List<BasePatientDO> basePatientDOList = basePatientDao.findByMobile(tel);
|
|
|
if(basePatientDOList==null||basePatientDOList.size()==0){
|
|
|
basePatientDO.setDel("1");
|
|
|
if (jsonObject.getString("USERNAME").length()>=2){
|
|
|
basePatientDO.setName(jsonObject.getString("USERNAME"));
|
|
|
}else {
|
|
|
basePatientDO.setName(tel);
|
|
|
}
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setYktId(jsonObject.getString("ID"));
|
|
|
basePatientDO.setUserId(userId);
|
|
|
basePatientDO.setMobile(tel);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = tel.substring(tel.length()-6,tel.length());
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
|
|
|
if (jsonObject.getString("USERNAME").length()>=2){
|
|
|
basePatientDO.setName(jsonObject.getString("USERNAME"));
|
|
|
}else {
|
|
|
basePatientDO.setName(tel);
|
|
|
}
|
|
|
basePatientDO.setDel("1");
|
|
|
basePatientDO.setCreateTime(new Date());
|
|
|
basePatientDO.setUpdateTime(new Date());
|
|
|
basePatientDO.setUserId(userId);
|
|
|
basePatientDO.setMobile(tel);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = tel.substring(tel.length()-6,tel.length());
|
|
|
basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
basePatientDO.setSalt(salt);
|
|
|
basePatientDO.setLocked(0);
|
|
|
basePatientDO.setEnabled(1);
|
|
|
basePatientDO.setPatientStatus("1");
|
|
|
basePatientDao.save(basePatientDO);
|
|
|
}
|
|
|
/*String birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
|
|
|
Integer age = com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
|
|
|
Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
|
|
|
if (iliness!=null&&iliness.size()!=0){
|
|
|
if (!iliness.contains("本人")){
|
|
|
ykyyService.addFamily(basePatientDO.getUserId(),basePatientDO.getIdcard(),basePatientDO.getName(),sex+"",birdth,age+"",basePatientDO.getMobile());
|
|
|
}
|
|
|
}else {
|
|
|
ykyyService.addFamily(basePatientDO.getUserId(),basePatientDO.getIdcard(),basePatientDO.getName(),sex+"",birdth,age+"",basePatientDO.getMobile());
|
|
|
}*/
|
|
|
}
|
|
|
}else {
|
|
|
logger.info("======"+jsonObject.getString("USERNAME")+"======");
|
|
|
logger.info("tel"+jsonObject.getString("USERNAME"));
|
|
|
BasePatientDO basePatientDO1 = basePatientDOS.get(0);
|
|
|
if (basePatientDO1.getName()==null||basePatientDO1.getName()==""){
|
|
|
if (jsonObject.getString("USERNAME").length()>=2){
|
|
|
basePatientDO1.setName(jsonObject.getString("USERNAME"));
|
|
|
}else {
|
|
|
basePatientDO1.setName(tel);
|
|
|
}
|
|
|
}
|
|
|
basePatientDO1.setVerifyCode(jsonObject.getString("TOKEN"));
|
|
|
basePatientDO1.setUserId(userId);
|
|
|
basePatientDao.save(basePatientDO1);
|
|
|
/*String familyList = ykyyService.getFamilyList(null,userId);
|
|
|
JSONObject familyJson = JSONObject.parseObject(familyList);
|
|
|
if (familyJson.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject object1 = familyJson.getJSONObject("data");
|
|
|
JSONArray list = object1.getJSONArray("list");
|
|
|
List<String> iliness = new ArrayList<>();
|
|
|
if (list!=null&&list.size()!=0){
|
|
|
for (int i=0;i<list.size();i++) {
|
|
|
JSONObject family = list.getJSONObject(i);
|
|
|
iliness.add(family.getString("ILLNESS"));
|
|
|
}
|
|
|
}
|
|
|
String birdth = null;
|
|
|
Integer age = 0;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(basePatientDO1.getIdcard())){
|
|
|
birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO1.getIdcard());
|
|
|
age =com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO1.getIdcard());
|
|
|
}
|
|
|
Integer sex = basePatientDO1.getSex()!=null?basePatientDO1.getSex():0;
|
|
|
if (iliness!=null&&iliness.size()!=0){
|
|
|
if (!iliness.contains("本人")){
|
|
|
ykyyService.addFamily(basePatientDO1.getUserId(),basePatientDO1.getIdcard(),basePatientDO1.getName(),sex+"",birdth,age+"",basePatientDO1.getMobile());
|
|
|
}
|
|
|
}else {
|
|
|
ykyyService.addFamily(basePatientDO1.getUserId(),basePatientDO1.getIdcard(),basePatientDO1.getName(),sex+"",birdth,age+"",basePatientDO1.getMobile());
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
} else if (!StringUtils.isEmpty(loginType)&&"3".equalsIgnoreCase(loginType)){
|
|
|
if (wlyyRedisVerifyCodeService.verification(client_id, username, captcha)) {
|
|
|
//验证码正确
|
|
|
}
|
|
@ -2765,13 +2945,15 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (wlyyHospitalSysDictDO1!=null){
|
|
|
isNeedGeet=wlyyHospitalSysDictDO1.getDictValue();
|
|
|
}
|
|
|
if("1".equalsIgnoreCase(isNeedGeet)){
|
|
|
String geetestChallenge = parameters.get("geetestChallenge");
|
|
|
String geetestValidate = parameters.get("geetestValidate");
|
|
|
String geetestSeccode = parameters.get("geetestSeccode");
|
|
|
JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"2");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
throw new Exception("验证失败");
|
|
|
if (parameters.get("mobile")==null){
|
|
|
if("1".equalsIgnoreCase(isNeedGeet)){
|
|
|
String geetestChallenge = parameters.get("geetestChallenge");
|
|
|
String geetestValidate = parameters.get("geetestValidate");
|
|
|
String geetestSeccode = parameters.get("geetestSeccode");
|
|
|
JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"2");
|
|
|
if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
|
|
|
throw new Exception("验证失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedPictureCode");
|
|
@ -2808,6 +2990,53 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
|
|
|
logger.info("password:"+password);
|
|
|
String response = ykyyService.DoctorLogin(parameters.get("username"),password);
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
logger.info("眼科通登陆返回参数:"+object);
|
|
|
if (!object.getString("code").equalsIgnoreCase("10000")){
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
|
return getFailedResponse(object.getString("msg"),-1,userSimple);
|
|
|
}else {
|
|
|
JSONObject jsonObject = object.getJSONObject("value");
|
|
|
if (jsonObject!=null) {
|
|
|
String idCard = jsonObject.getString("idCard");
|
|
|
String verifyCode = jsonObject.getString("verifyCode");
|
|
|
String yktDoctorId= jsonObject.getString("id");
|
|
|
BaseDoctorDO doctorDOs = doctorDao.findByIdcard(idCard);
|
|
|
if (doctorDOs!=null){
|
|
|
doctorDOs.setVerifyCode(verifyCode);
|
|
|
doctorDOs.setYktDoctorId(yktDoctorId);
|
|
|
/*doctorDOs.setYktCode();*/
|
|
|
doctorDao.save(doctorDOs);
|
|
|
}else {
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
|
return getFailedResponse("您的账号未认证,请联系互联网医院工作人员,联系电话0592-2108763。",-1,userSimple);
|
|
|
}
|
|
|
if (idCard==null||idCard==""){
|
|
|
logger.info("身份证为空");
|
|
|
}else {
|
|
|
ykyyService.updateYkyyDoctor(idCard,verifyCode,yktDoctorId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
} else if (parameters.get("mobile") != null) {
|
|
|
KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
|
|
|
String mobile = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("mobile"), keyPair);
|
|
|
logger.info("mobile:"+mobile);
|
|
|
String password = null;
|
|
|
String res = ykyyService.getDoctorPhone(mobile);
|
|
|
if (res!=null&&res!=""){
|
|
|
JSONObject object = JSONObject.parseObject(res);
|
|
|
if (object.getString("code").equalsIgnoreCase("200")){
|
|
|
password = object.getString("data");
|
|
|
}else {
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
|
return getFailedResponse(object.getString("msg"),-1,userSimple);
|
|
|
}
|
|
|
}
|
|
|
String response = ykyyService.DoctorLogin(parameters.get("username"),password);
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
logger.info("眼科通登陆返回参数:"+object);
|
|
@ -2824,6 +3053,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
if (doctorDOs!=null){
|
|
|
doctorDOs.setVerifyCode(verifyCode);
|
|
|
doctorDOs.setYktDoctorId(yktDoctorId);
|
|
|
/*doctorDOs.setYktCode();*/
|
|
|
doctorDao.save(doctorDOs);
|
|
|
}else {
|
|
|
WlyyUserSimple userSimple = new WlyyUserSimple();
|
|
@ -2838,7 +3068,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
}
|
|
|
}
|
|
|
parameters.remove("password");
|
|
|
} else {
|
|
|
}else {
|
|
|
//第三方同步账号模式登录
|
|
|
parameters.put("grant_type", "ihealthDcotor");
|
|
|
}
|