This commit is contained in:
chenyanchang
2026-06-29 17:08:06 +08:00
parent 48c62c7328
commit 5c933d6fd0

View File

@@ -128,7 +128,7 @@ public class SsoService {
// 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
String isCompanyUser = userJson.getString("userType");
isCompanyUser = "01".equals(isCompanyUser) ? "1" : "0";
AppUser appUser = saveAppUser(userJson, isCompanyUser);
AppUser appUser = saveAppUser(userJson, isCompanyUser, webAppId, webAppSecret);
//用户存在生成本系统用户的token
String token = loginAppUser(appUser, userJson.getString("userName"));
JSONObject backJson = new JSONObject();
@@ -161,7 +161,7 @@ public class SsoService {
// 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
String isCompanyUser = userJson.getString("userType");
isCompanyUser = "01".equals(isCompanyUser) ? "1" : "0";
AppUser appUser = saveAppUser(userJson, isCompanyUser);
AppUser appUser = saveAppUser(userJson, isCompanyUser, webAppId, webAppSecret);
//用户存在生成本系统用户的token
String token = loginAppUser(appUser, userJson.getString("userName"));
JSONObject backJson = new JSONObject();
@@ -229,9 +229,9 @@ public class SsoService {
}
//1.先查appuser,不存在,则新增
AppUser appUser = saveAppUser(userJson, isCompanyUser);
AppUser appUser = saveAppUser(userJson, isCompanyUser, webAppId, webAppSecret);
//2.再查sysuser,不存在,则新增
SysUser sysUser = saveSysUser(userJson, appUser.getUserId(), isCompanyUser);
SysUser sysUser = saveSysUser(userJson, appUser.getUserId(), isCompanyUser, webAppId, webAppSecret);
//用户存在生成本系统用户的token
String token = loginSysUser(sysUser, userJson.getString("userName"));
@@ -307,14 +307,14 @@ public class SsoService {
Long appUserId = null;
if (StringUtils.isNotEmpty(isCompanyUser) && "2".equals(isCompanyUser)) {
//1.先查appuser,不存在,则新增
AppUser appUser = saveAppUser(userJson, isCompanyUser);
AppUser appUser = saveAppUser(userJson, isCompanyUser, cmsAppId, cmsAppSecret);
appUserId = appUser.getUserId();
} /*else {
throw new RuntimeException("非网格员不允许执行此操作");
}*/
//2.再查sysuser,不存在,则新增
//身份证为空则查userId
SysUser sysUser = saveSysUser(userJson, appUserId, isCompanyUser);
SysUser sysUser = saveSysUser(userJson, appUserId, isCompanyUser, cmsAppId, cmsAppSecret);
//用户存在生成本系统用户的token
String token = loginSysUser(sysUser, userJson.getString("userName"));
@@ -394,7 +394,7 @@ public class SsoService {
}
//保存appuser用户
private AppUser saveAppUser(JSONObject userJson, String isCompanyUser) {
private AppUser saveAppUser(JSONObject userJson, String isCompanyUser, String appId, String appSecret) {
JSONObject info = userJson.containsKey("info") ? userJson.getJSONObject("info") : null;
System.out.println("userId===========" + userJson.getLong("userId"));
System.out.println("userJson===========" + JSONObject.toJSONString(userJson));
@@ -422,7 +422,7 @@ public class SsoService {
String phone = info.getString("entAdminPhone");
//解密电话号码
if (StringUtils.isNotEmpty(phone)) {
phone = EncryptUtil.decryptByAppIdAndSecret(phone, cmsAppId, cmsAppSecret);
phone = EncryptUtil.decryptByAppIdAndSecret(phone, appId, appSecret);
appUser.setPhone(phone);
}
@@ -438,12 +438,12 @@ public class SsoService {
appUser.setDomicileAddress(info.getString("householdAddress"));
//证件号
personCardNo = info != null && info.containsKey("personCardNo") ? info.getString("personCardNo") : userJson.getString("idCardNo");
personCardNo = EncryptUtil.decryptByAppIdAndSecret(personCardNo, webAppId, webAppSecret);
personCardNo = EncryptUtil.decryptByAppIdAndSecret(personCardNo, appId, appSecret);
appUser.setAge(StringUtil.getAgeByIdNumber(personCardNo));
String phone = info != null ? info.getString("personPhone") : userJson.getString("phonenumber");
//解密电话号码
if (StringUtils.isNotEmpty(phone)) {
phone = EncryptUtil.decryptByAppIdAndSecret(phone, webAppId, webAppSecret);
phone = EncryptUtil.decryptByAppIdAndSecret(phone, appId, appSecret);
appUser.setPhone(phone);
}
}
@@ -466,7 +466,7 @@ public class SsoService {
* @param userJson
* @return
*/
private SysUser saveSysUser(JSONObject userJson, Long appUserId, String isCompanyUser) {
private SysUser saveSysUser(JSONObject userJson, Long appUserId, String isCompanyUser, String appId, String appSecret) {
JSONObject info = userJson.containsKey("info") ? userJson.getJSONObject("info") : null;
System.out.println("sysuserId==========" + userJson.getLong("userId"));
System.out.println("userJson==========" + JSONObject.toJSONString(userJson));
@@ -494,16 +494,16 @@ public class SsoService {
String phone = info.getString("entAdminPhone");
//解密电话号码
if (StringUtils.isNotEmpty(phone)) {
phone = EncryptUtil.decryptByAppIdAndSecret(phone, cmsAppId, cmsAppSecret);
phone = EncryptUtil.decryptByAppIdAndSecret(phone, appId, appSecret);
sysUser.setPhonenumber(phone);
}
} else {
personCardNo = info != null && info.containsKey("personCardNo") ? info.getString("personCardNo") : userJson.getString("idCardNo");
personCardNo = EncryptUtil.decryptByAppIdAndSecret(personCardNo, webAppId, webAppSecret);
personCardNo = EncryptUtil.decryptByAppIdAndSecret(personCardNo, appId, appSecret);
String phone = info != null && info.containsKey("personPhone") ? info.getString("personPhone") : userJson.getString("phonenumber");
//解密电话号码
if (StringUtils.isNotEmpty(phone)) {
phone = EncryptUtil.decryptByAppIdAndSecret(phone, webAppId, webAppSecret);
phone = EncryptUtil.decryptByAppIdAndSecret(phone, appId, appSecret);
sysUser.setPhonenumber(phone);
}
}