@@ -142,11 +142,7 @@ public class SsoService {
// 转换成本地: app角色: 0企业, 1求职者, 2网格员 3内部政府人员 4其他( 浪潮用)
String isCompanyUser = userJson . getString ( " userType " ) ;
isCompanyUser = " 01 " . equals ( isCompanyUser ) ? " 1 " : " 0 " ;
AppUser appUser = appUserService . selectAppuserByIdcardAndUserType ( p ersonCardNo , isCompanyUser ) ;
if ( appUser = = null ) {
//用户不存在,则先保存用户
appUser = saveAppUser ( userJson , isCompanyUser ) ;
}
AppUser appUser = saveAppUser ( us erJ son, isCompanyUser ) ;
//用户存在, 生成本系统用户的token
String token = loginAppUser ( appUser , userJson . getString ( " userName " ) ) ;
JSONObject backJson = new JSONObject ( ) ;
@@ -193,11 +189,7 @@ public class SsoService {
// 转换成本地: app角色: 0企业, 1求职者, 2网格员 3内部政府人员 4其他( 浪潮用)
String isCompanyUser = userJson . getString ( " userType " ) ;
isCompanyUser = " 01 " . equals ( isCompanyUser ) ? " 1 " : " 0 " ;
AppUser appUser = appUserService . selectAppuserByIdcardAndUserType ( p ersonCardNo , isCompanyUser ) ;
if ( appUser = = null ) {
//用户不存在,则先保存用户
appUser = saveAppUser ( userJson , isCompanyUser ) ;
}
AppUser appUser = saveAppUser ( us erJ son, isCompanyUser ) ;
//用户存在, 生成本系统用户的token
String token = loginAppUser ( appUser , userJson . getString ( " userName " ) ) ;
JSONObject backJson = new JSONObject ( ) ;
@@ -277,15 +269,9 @@ public class SsoService {
String isCompanyUser = userJson . getString ( " userType " ) ;
isCompanyUser = " 01 " . equals ( isCompanyUser ) ? " 1 " : " 0 " ;
//1.先查appuser,不存在,则新增
AppUser appUser = appUserService . selectAppuserByIdcardAndUserType ( p ersonCardNo , isCompanyUser ) ;
if ( appUser = = null ) {
appUser = saveAppUser ( userJson , isCompanyUser ) ;
}
AppUser appUser = saveAppUser ( us erJ son, isCompanyUser ) ;
//2.再查sysuser,不存在,则新增
SysUser sysUser = sysUserService . selectUserByIdCard ( personCardNo ) ;
if ( sysUser = = null ) {
sysUser = saveSysUser ( userJson , appUser . getUserId ( ) , isCompanyUser ) ;
}
SysUser sysUser = saveS ysUser( userJson , appUser . getUserId ( ) , isCompanyUser ) ;
//用户存在, 生成本系统用户的token
String token = loginSysUser ( sysUser , userJson . getString ( " userName " ) ) ;
@@ -369,24 +355,14 @@ public class SsoService {
Long appUserId = null ;
if ( StringUtils . isNotEmpty ( isCompanyUser ) & & " 2 " . equals ( isCompanyUser ) ) {
//1.先查appuser,不存在,则新增
AppUser appUser = appUserService . selectAppuserByIdcardAndUserType ( p ersonCardNo , isCompanyUser ) ;
if ( appUser = = null ) {
appUser = saveAppUser ( userJson , isCompanyUser ) ;
AppUser appUser = saveAppUser ( us erJ son, isCompanyUser ) ;
appUserId = appUser . getUserId ( ) ;
}
} else {
throw new RuntimeException ( " 非网格员不允许执行此操作 " ) ;
}
//2.再查sysuser,不存在,则新增
//身份证为空则查userId
SysUser sysUser = null ;
if ( StringUtils . isNotEmpty ( personCardNo ) ) {
sysUser = sysUserService . selectUserByIdCard ( personCardNo ) ;
} else {
sysUser = sysUserService . selectUserById ( userJson . getLong ( " userId " ) ) ;
}
if ( sysUser = = null ) {
sysUser = saveSysUser ( userJson , appUserId , isCompanyUser ) ;
}
SysUser sysUser = saveSysUser ( userJson , appUserId , isCompanyUser ) ;
//用户存在, 生成本系统用户的token
String token = loginSysUser ( sysUser , userJson . getString ( " userName " ) ) ;
@@ -472,18 +448,8 @@ public class SsoService {
AppUser appUser = new AppUser ( ) ;
//app角色: 0企业, 1求职者, 2网格员 3内部政府人员 4其他( 浪潮用)
appUser . setIsCompanyUser ( isCompanyUser ) ;
appUser. setUserId( userJson. getLong( " userId " ) ) ;
appUser . setName ( info ! = null ? info . getString ( " personName " ) : userJson . getString ( " nickName " ) ) ;
appUser . setSex ( info ! = null ? info . getString ( " personSex " ) : userJson . getString ( " sex " ) ) ;
if ( info ! = null ) {
appUser . setBirthDate ( info . getString ( " personBirthday " ) ) ;
appUser . setEducation ( StringUtil . convertEducation ( info . getString ( " personEducation " ) ) ) ;
appUser . setPoliticalAffiliation ( info . getString ( " personPolitical " ) ) ;
appUser . setAddress ( info . getString ( " liveAddress " ) ) ;
appUser . setWorkExperience ( StringUtil . convertExp ( info . getInteger ( " personYearsWorking " ) ) ) ;
appUser . setNation ( info . getString ( " personNation " ) ) ;
appUser . setDomicileAddress ( info . getString ( " householdAddress " ) ) ;
}
// appUser. setUserId( userJson. getLong("userId")) ;
String date = new SimpleDateFormat ( " yyyy-MM-dd hh:mm:ss " ) . format ( new Date ( ) ) ;
appUser . setCreateTime ( date ) ;
appUser . setUpdateTime ( date ) ;
@@ -492,22 +458,44 @@ public class SsoService {
appUser . setLoginIp ( IpUtils . getIpAddr ( ) ) ;
//获取身份证,再获取年龄
String personCardNo = info ! = null ? info . getString ( " personCardNo " ) : userJson . getString ( " idCardNo " ) ;
//解密处理
if ( StringUtils . isNotEmpty ( personCardNo ) ) {
String personCardNo = null ;
//1.求职者 2.网格员
if ( " 1 " . equals ( isCompanyUser ) | | " 2 " . equals ( isCompanyUser ) ) {
appUser . setName ( info ! = null ? info . getString ( " personName " ) : userJson . getString ( " nickName " ) ) ;
appUser . setSex ( info ! = null ? info . getString ( " personSex " ) : userJson . getString ( " sex " ) ) ;
appUser . setBirthDate ( info . getString ( " personBirthday " ) ) ;
appUser . setEducation ( StringUtil . convertEducation ( info . getString ( " personEducation " ) ) ) ;
appUser . setPoliticalAffiliation ( info . getString ( " personPolitical " ) ) ;
appUser . setAddress ( info . getString ( " liveAddress " ) ) ;
appUser . setWorkExperience ( StringUtil . convertExp ( info . getInteger ( " personYearsWorking " ) ) ) ;
appUser . setNation ( info . getString ( " personNation " ) ) ;
appUser . setDomicileAddress ( info . getString ( " householdAddress " ) ) ;
//证件号
personCardNo = info ! = null & & info . containsKey ( " personCardNo " ) ? info . getString ( " personCardNo " ) : userJson . getString ( " idCardNo " ) ;
personCardNo = EncryptUtil . decryptByAppIdAndSecret ( personCardNo , webAppId , webAppSecret ) ;
appUser . setAge ( StringUtil . getAgeByIdNumber ( personCardNo ) ) ;
appUser . setIdCard ( personCardNo ) ;
}
String phone = info ! = null ? info . getString ( " personPhone " ) : userJson . getString ( " phonenumber " ) ;
//解密电话号码
if ( StringUtils . isNotEmpty ( phone ) ) {
phone = EncryptUtil . decryptByAppIdAndSecret ( phone , webAppId , webAppSecret ) ;
appUser . setPhone ( phone ) ;
}
} else {
personCardNo = info . getString ( " entCreditCode " ) ;
appUser . setAddress ( info . getString ( " entRegisteredAddress " ) ) ;
String phone = info . getString ( " entAdminPhone " ) ;
//解密电话号码
if ( StringUtils . isNotEmpty ( phone ) ) {
phone = EncryptUtil . decryptByAppIdAndSecret ( phone , webAppId , webAppSecret ) ;
appUser . setPhone ( phone ) ;
}
AppUser checkUser = appUserService . selectAppUserByUserId ( userJson . getLong ( " userId " ) ) ;
}
appUser . setIdCard ( personCardNo ) ;
AppUser checkUser = appUserService . selectAppuserByIdcardAndUserType ( personCardNo , isCompanyUser ) ;
if ( checkUser ! = null ) {
appUser . setUserId ( checkUser . getUserId ( ) ) ;
appUserService . updateAppUser ( appUser ) ;
} else {
appUserService . insertAppUser ( appUser ) ;
@@ -521,7 +509,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 ) {
JSONObject info = userJson . containsKey ( " info " ) ? userJson . getJSONObject ( " info " ) : null ;
System . out . println ( " sysuserId========== " + userJson . getLong ( " userId " ) ) ;
System . out . println ( " userJson========== " + JSONObject . toJSONString ( userJson ) ) ;
@@ -543,22 +531,30 @@ public class SsoService {
//获取身份证
String personCardNo = " " ;
//0.企业 1.求职者 2.风格员
if ( " 0 " . equals ( isCompanyUser ) ) {
personCardNo = info . getString ( " entCreditCode " ) ;
} else {
String phone = info . getString ( " entAdminPhone " ) ;
//解密电话号码
if ( StringUtils . isNotEmpty ( phone ) ) {
phone = EncryptUtil . decryptByAppIdAndSecret ( phone , webAppId , webAppSecret ) ;
sysUser . setPhonenumber ( phone ) ;
}
} else {
personCardNo = info ! = null & & info . containsKey ( " personCardNo " ) ? info . getString ( " personCardNo " ) : userJson . getString ( " idCardNo " ) ;
personCardNo = EncryptUtil . decryptByAppIdAndSecret ( personCardNo , webAppId , webAppSecret ) ;
}
//解密处理
if ( StringUtils . isNotEmpty ( personCardNo ) ) {
sysUser . setIdCard ( personCardNo ) ;
}
String phone = info ! = null & & info . containsKey ( " personPhone " ) ? info . getString ( " personPhone " ) : userJson . getString ( " phonenumber " ) ;
//解密电话号码
if ( StringUtils . isNotEmpty ( phone ) ) {
phone = EncryptUtil . decryptByAppIdAndSecret ( phone , webAppId , webAppSecret ) ;
sysUser . setPhonenumber ( phone ) ;
}
}
//解密处理
if ( StringUtils . isNotEmpty ( personCardNo ) ) {
sysUser . setIdCard ( personCardNo ) ;
}
//部门
if ( userJson . containsKey ( " dept " ) ) {
JSONObject dept = userJson . getJSONObject ( " dept " ) ;