This commit is contained in:
chenyanchang
2026-06-16 13:02:49 +08:00
parent 73750cf238
commit 8555bc47a3
2 changed files with 24 additions and 22 deletions

View File

@@ -58,7 +58,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
public AppUser selectAppUserByUserId(Long userId) public AppUser selectAppUserByUserId(Long userId)
{ {
AppUser appUser = appUserMapper.selectById(userId); AppUser appUser = appUserMapper.selectById(userId);
if(StringUtils.isNotEmpty(appUser.getJobTitleId())){ if(appUser != null && StringUtils.isNotEmpty(appUser.getJobTitleId())){
List<String> list = Arrays.asList(appUser.getJobTitleId().split(",")); List<String> list = Arrays.asList(appUser.getJobTitleId().split(","));
List<Long> collect = list.stream().map(Long::valueOf).collect(Collectors.toList()); List<Long> collect = list.stream().map(Long::valueOf).collect(Collectors.toList());
List<JobTitle> jobs = jobTitleMapper.selectBatchIds(collect); List<JobTitle> jobs = jobTitleMapper.selectBatchIds(collect);
@@ -489,8 +489,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
} }
@Override @Override
public AppUser selectAppuserByIdcardAndUserType(String idCard, String userType) { public AppUser selectAppuserByIdcardAndUserType(String idCard, String isCompanyUser) {
return appUserMapper.selectOne(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getIdCard, idCard).eq(AppUser::getDelFlag,"0").eq(AppUser::getIsCompanyUser, userType).orderByDesc(AppUser::getUpdateTime).last("LIMIT 1")); return appUserMapper.selectOne(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getIdCard, idCard).eq(AppUser::getDelFlag,"0").eq(AppUser::getIsCompanyUser, isCompanyUser).orderByDesc(AppUser::getUpdateTime).last("LIMIT 1"));
} }
@Override @Override

View File

@@ -125,12 +125,12 @@ public class SsoService {
//用身份证号查询用户 用户类型01个人02企业 //用身份证号查询用户 用户类型01个人02企业
// 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用 // 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
String userType = userJson.getString("userType"); String isCompanyUser = userJson.getString("userType");
userType = "01".equals(userType) ? "1" : "0"; isCompanyUser = "01".equals(isCompanyUser) ? "1" : "0";
AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, userType); AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, isCompanyUser);
if (appUser == null) { if (appUser == null) {
//用户不存在,则先保存用户 //用户不存在,则先保存用户
appUser = saveAppUser(userJson, userType); appUser = saveAppUser(userJson, isCompanyUser);
} }
//用户存在生成本系统用户的token //用户存在生成本系统用户的token
String token = loginAppUser(appUser, userJson.getString("userName")); String token = loginAppUser(appUser, userJson.getString("userName"));
@@ -176,12 +176,12 @@ public class SsoService {
//用身份证号查询用户 用户类型01个人02企业 //用身份证号查询用户 用户类型01个人02企业
// 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用 // 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
String userType = userJson.getString("userType"); String isCompanyUser = userJson.getString("userType");
userType = "01".equals(userType) ? "1" : "0"; isCompanyUser = "01".equals(isCompanyUser) ? "1" : "0";
AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, userType); AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, isCompanyUser);
if (appUser == null) { if (appUser == null) {
//用户不存在,则先保存用户 //用户不存在,则先保存用户
appUser = saveAppUser(userJson, userType); appUser = saveAppUser(userJson, isCompanyUser);
} }
//用户存在生成本系统用户的token //用户存在生成本系统用户的token
String token = loginAppUser(appUser, userJson.getString("userName")); String token = loginAppUser(appUser, userJson.getString("userName"));
@@ -236,12 +236,12 @@ public class SsoService {
//用身份证号查询用户 用户类型01个人02企业 //用身份证号查询用户 用户类型01个人02企业
// 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用 // 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
//userType对应appuser的isCompanyUser //userType对应appuser的isCompanyUser
String userType = userJson.getString("userType"); String isCompanyUser = userJson.getString("userType");
userType = "01".equals(userType) ? "1" : "0"; isCompanyUser = "01".equals(isCompanyUser) ? "1" : "0";
//1.先查appuser,不存在,则新增 //1.先查appuser,不存在,则新增
AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, userType); AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, isCompanyUser);
if (appUser == null) { if (appUser == null) {
appUser = saveAppUser(userJson, userType); appUser = saveAppUser(userJson, isCompanyUser);
} }
//2.再查sysuser,不存在,则新增 //2.再查sysuser,不存在,则新增
SysUser sysUser = sysUserService.selectUserByIdCard(personCardNo); SysUser sysUser = sysUserService.selectUserByIdCard(personCardNo);
@@ -301,24 +301,24 @@ public class SsoService {
//用身份证号查询用户 用户类型01个人02企业 //用身份证号查询用户 用户类型01个人02企业
// 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用 // 转换成本地app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
//取角色判断是网格员2还是内部工作者3 //取角色判断是网格员2还是内部工作者3
String userType = null; String isCompanyUser = null;
if(userJson.containsKey("roles")) { if(userJson.containsKey("roles")) {
JSONObject role = userJson.getJSONArray("roles").getJSONObject(0); JSONObject role = userJson.getJSONArray("roles").getJSONObject(0);
if (role != null && role.containsKey("roleId")) { if (role != null && role.containsKey("roleId")) {
/*1101(求职者)、1102(招聘者)、1103(网格员)、1104(内部工作者)*/ /*1101(求职者)、1102(招聘者)、1103(网格员)、1104(内部工作者)*/
Long roleId = role.getLong("roleId"); Long roleId = role.getLong("roleId");
if (roleId != null && roleId.equals(1103L)) { if (roleId != null && roleId.equals(1103L)) {
userType = "2";//2网格员 isCompanyUser = "2";//2网格员
} }
} }
} }
Long appUserId = null; Long appUserId = null;
if (StringUtils.isNotEmpty(userType) && "2".equals(userType)) { if (StringUtils.isNotEmpty(isCompanyUser) && "2".equals(isCompanyUser)) {
//1.先查appuser,不存在,则新增 //1.先查appuser,不存在,则新增
AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, userType); AppUser appUser = appUserService.selectAppuserByIdcardAndUserType(personCardNo, isCompanyUser);
if (appUser == null) { if (appUser == null) {
appUser = saveAppUser(userJson, userType); appUser = saveAppUser(userJson, isCompanyUser);
appUserId = appUser.getUserId(); appUserId = appUser.getUserId();
} }
} }
@@ -402,6 +402,7 @@ public class SsoService {
//保存appuser用户 //保存appuser用户
private AppUser saveAppUser(JSONObject userJson, String isCompanyUser) { private AppUser saveAppUser(JSONObject userJson, String isCompanyUser) {
JSONObject info = userJson.containsKey("info") ? userJson.getJSONObject("info") : null; JSONObject info = userJson.containsKey("info") ? userJson.getJSONObject("info") : null;
System.out.println("userId===========" + userJson.getLong("userId"));
AppUser appUser = new AppUser(); AppUser appUser = new AppUser();
//app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用 //app角色0企业1求职者2网格员 3内部政府人员 4其他浪潮用
appUser.setIsCompanyUser(isCompanyUser); appUser.setIsCompanyUser(isCompanyUser);
@@ -439,7 +440,7 @@ public class SsoService {
appUser.setPhone(phone); appUser.setPhone(phone);
} }
AppUser checkUser = appUserService.selectAppUserByUserId(appUser.getUserId()); AppUser checkUser = appUserService.selectAppUserByUserId(userJson.getLong("userId"));
if (checkUser != null) { if (checkUser != null) {
appUserService.updateAppUser(appUser); appUserService.updateAppUser(appUser);
} else { } else {
@@ -456,6 +457,7 @@ public class SsoService {
*/ */
private SysUser saveSysUser(JSONObject userJson, Long appUserId) { private SysUser saveSysUser(JSONObject userJson, Long appUserId) {
JSONObject info = userJson.containsKey("info") ? userJson.getJSONObject("info") : null; JSONObject info = userJson.containsKey("info") ? userJson.getJSONObject("info") : null;
System.out.println("sysuserId==========" + userJson.getLong("userId"));
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setAppUserId(appUserId); sysUser.setAppUserId(appUserId);
sysUser.setUserId(userJson.getLong("userId")); sysUser.setUserId(userJson.getLong("userId"));
@@ -493,7 +495,7 @@ public class SsoService {
sysUser.setDeptId(deptId); sysUser.setDeptId(deptId);
} }
SysUser checkUser = sysUserService.selectUserById(sysUser.getUserId()); SysUser checkUser = sysUserService.selectUserById(userJson.getLong("userId"));
if (checkUser != null) { if (checkUser != null) {
sysUserService.updateUser(sysUser); sysUserService.updateUser(sysUser);
} else { } else {