1.添加岗位取消接口
2.添加岗位取消列表 3.修改对应的统计 4.app_user添加orgType机构类型字段
This commit is contained in:
@@ -269,7 +269,7 @@ public class SysLoginService
|
||||
AppUser existingUser=appUserService.selectByOpenid(openid,dto.getUserType());
|
||||
if(existingUser!=null){
|
||||
if(StringUtils.isEmpty(existingUser.getIsCompanyUser())){
|
||||
updateAppUserCommon(existingUser,openid,unionid,dto.getUserType());
|
||||
updateAppUserCommon(existingUser,openid,unionid,dto.getUserType(),dto.getOrgType());
|
||||
}
|
||||
String token = loginUserIdApp(existingUser);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
@@ -290,7 +290,7 @@ public class SysLoginService
|
||||
String token="";
|
||||
boolean isNewUser=false;
|
||||
if (existUser != null) {
|
||||
updateAppUserCommon(existUser,openid,unionid,dto.getUserType());
|
||||
updateAppUserCommon(existUser,openid,unionid,dto.getUserType(),dto.getOrgType());
|
||||
// 5. 生成系统令牌
|
||||
token = loginUserIdApp(existUser);
|
||||
ajax.put("idCard",existUser.getIdCard());
|
||||
@@ -374,12 +374,12 @@ public class SysLoginService
|
||||
// 6.1 优先匹配「OpenID+前端传入角色」的老用户
|
||||
AppUser existingUser = appUserService.selectByOpenid(openid, userType);
|
||||
if (existingUser != null) {
|
||||
System.out.printf("小程序登录-匹配到普通老用户:openid=%s, userType=%s%n", openid, userType);
|
||||
return handleExistingUser(existingUser, userType);
|
||||
System.out.printf("小程序登录-匹配到普通老用户:openid=%s, userType=%s%n", openid, userType, dto.getOrgType());
|
||||
return handleExistingUser(existingUser, userType,dto.getOrgType());
|
||||
}
|
||||
|
||||
// 6.2 处理普通用户的匹配与注册(手机号绑定、新用户创建等)
|
||||
return handleUserMatchAndRegister(openid, unionid, phone, userType);
|
||||
return handleUserMatchAndRegister(openid, unionid, phone, userType,dto.getOrgType());
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("小程序登录异常:" + e.getMessage());
|
||||
@@ -470,21 +470,21 @@ public class SysLoginService
|
||||
* @param userType
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult handleUserMatchAndRegister(String openid, String unionid, String phone, String userType) {
|
||||
private AjaxResult handleUserMatchAndRegister(String openid, String unionid, String phone, String userType,String orgType) {
|
||||
// 匹配「手机号+角色」的用户
|
||||
AppUser phoneRoleUser = appUserService.getPhoneAndUserType(phone, userType);
|
||||
if (phoneRoleUser != null) {
|
||||
return handlePhoneBoundUser(phoneRoleUser, openid, unionid, userType);
|
||||
return handlePhoneBoundUser(phoneRoleUser, openid, unionid, userType,orgType);
|
||||
}
|
||||
|
||||
// 匹配无角色历史数据
|
||||
AppUser noRoleUser = appUserService.getPhoneAndNoRole(phone);
|
||||
if (noRoleUser != null) {
|
||||
return handleNoRoleUserBinding(openid, unionid, phone, userType, noRoleUser);
|
||||
return handleNoRoleUserBinding(openid, unionid, phone, userType, noRoleUser,orgType);
|
||||
}
|
||||
|
||||
// 全新用户注册
|
||||
return handleNewUserRegistration(openid, unionid, phone, userType);
|
||||
return handleNewUserRegistration(openid, unionid, phone, userType,orgType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +496,7 @@ public class SysLoginService
|
||||
* @param noRoleUser
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult handleNoRoleUserBinding(String openid, String unionid, String phone, String userType, AppUser noRoleUser) {
|
||||
private AjaxResult handleNoRoleUserBinding(String openid, String unionid, String phone, String userType, AppUser noRoleUser,String orgType) {
|
||||
String lockKey = "login_no_role_bind_" + phone + "_" + userType;
|
||||
try (DistributedLockUtil.AutoReleaseLock lock = distributedLockUtil.tryLock(lockKey, 3, TimeUnit.SECONDS)) {
|
||||
if (!lock.isLocked()) {
|
||||
@@ -505,9 +505,9 @@ public class SysLoginService
|
||||
// 双重检查
|
||||
AppUser doubleCheck = appUserService.getPhoneAndUserType(phone, userType);
|
||||
if (doubleCheck != null) {
|
||||
return handlePhoneBoundUser(doubleCheck, openid, unionid, userType);
|
||||
return handlePhoneBoundUser(doubleCheck, openid, unionid, userType,orgType);
|
||||
}
|
||||
return handlePhoneBoundUser(noRoleUser, openid, unionid, userType);
|
||||
return handlePhoneBoundUser(noRoleUser, openid, unionid, userType,orgType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ public class SysLoginService
|
||||
* @param userType
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult handleNewUserRegistration(String openid, String unionid, String phone, String userType) {
|
||||
private AjaxResult handleNewUserRegistration(String openid, String unionid, String phone, String userType,String orgType) {
|
||||
String createLockKey = "login_create_" + phone + "_" + userType;
|
||||
try (DistributedLockUtil.AutoReleaseLock lock = distributedLockUtil.tryLock(createLockKey, 3, TimeUnit.SECONDS)) {
|
||||
if (!lock.isLocked()) {
|
||||
@@ -528,9 +528,9 @@ public class SysLoginService
|
||||
// 双重检查
|
||||
AppUser checkNew = appUserService.getPhoneAndUserType(phone, userType);
|
||||
if (checkNew != null) {
|
||||
return handlePhoneBoundUser(checkNew, openid, unionid, userType);
|
||||
return handlePhoneBoundUser(checkNew, openid, unionid, userType,orgType);
|
||||
}
|
||||
return handleNewUser(openid, unionid, phone, userType);
|
||||
return handleNewUser(openid, unionid, phone, userType,orgType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ public class SysLoginService
|
||||
}
|
||||
// 原有逻辑(更新登录时间、生成token)
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
updateAppUserCommon(specialUser, null, null, null);
|
||||
updateAppUserCommon(specialUser, null, null, null,specialUser.getOrgType());
|
||||
String token = loginUserIdApp(specialUser);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("isNewUser", false);
|
||||
@@ -565,9 +565,9 @@ public class SysLoginService
|
||||
* 处理老用户登录(日志用println)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult handleExistingUser(AppUser existingUser, String userType) {
|
||||
public AjaxResult handleExistingUser(AppUser existingUser, String userType,String orgType) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
updateAppUserCommon(existingUser, null, null, userType);
|
||||
updateAppUserCommon(existingUser, null, null, userType,orgType);
|
||||
String token = loginUserIdApp(existingUser);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("isNewUser", false);
|
||||
@@ -583,7 +583,7 @@ public class SysLoginService
|
||||
* 处理手机号已绑定的用户
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult handlePhoneBoundUser(AppUser phoneUser, String openid, String unionid, String userType) {
|
||||
public AjaxResult handlePhoneBoundUser(AppUser phoneUser, String openid, String unionid, String userType,String orgType) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
if (StringUtils.hasText(phoneUser.getOpenid()) && !openid.equals(phoneUser.getOpenid())) {
|
||||
System.out.printf("手机号绑定冲突,phone:%s, oldOpenid:%s, newOpenid:%s%n",
|
||||
@@ -591,7 +591,7 @@ public class SysLoginService
|
||||
return AjaxResult.error("该手机号已绑定其他微信账号");
|
||||
}
|
||||
//修改用户信息
|
||||
updateAppUserCommon(phoneUser, openid, unionid, userType);
|
||||
updateAppUserCommon(phoneUser, openid, unionid, userType,orgType);
|
||||
phoneUser.setOpenid(openid);
|
||||
phoneUser.setUnionid(unionid);
|
||||
phoneUser.setIsCompanyUser(userType);
|
||||
@@ -609,7 +609,7 @@ public class SysLoginService
|
||||
* 处理新用户注册
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult handleNewUser(String openid, String unionid, String phone, String userType) {
|
||||
public AjaxResult handleNewUser(String openid, String unionid, String phone, String userType,String orgType) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
AppUser newUser = new AppUser();
|
||||
newUser.setOpenid(openid);
|
||||
@@ -617,6 +617,7 @@ public class SysLoginService
|
||||
newUser.setPhone(phone);
|
||||
newUser.setIsCompanyUser(userType);
|
||||
newUser.setLoginDate(new Date());
|
||||
newUser.setOrgType(orgType);
|
||||
appUserService.insertAppUser(newUser);
|
||||
String token = loginUserIdApp(newUser);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
@@ -631,7 +632,7 @@ public class SysLoginService
|
||||
/**
|
||||
* 抽取用户更新公共方法
|
||||
*/
|
||||
private void updateAppUserCommon(AppUser targetUser, String openid, String unionid, String userType) {
|
||||
private void updateAppUserCommon(AppUser targetUser, String openid, String unionid, String userType,String orgType) {
|
||||
AppUser updateParm = new AppUser();
|
||||
updateParm.setUserId(targetUser.getUserId());
|
||||
|
||||
@@ -651,6 +652,9 @@ public class SysLoginService
|
||||
updateParm.setUnionid(unionid);
|
||||
targetUser.setUnionid(unionid);
|
||||
}
|
||||
if(StringUtils.isNotBlank(orgType)){
|
||||
updateParm.setOrgType(orgType);
|
||||
}
|
||||
//最后登录时间
|
||||
updateParm.setLoginDate(new Date());
|
||||
appUserService.updateAppUser(updateParm);
|
||||
|
||||
Reference in New Issue
Block a user