需求背景:账号信息由三方系统管理,包含账号状态,所以需要通过提供给三方的 Rest 接口中,实现账号锁定与解锁。
参考基线版本:10.0.2506.01,过低的版本可能无法使用。
锁定分为两种:
(1)租户级别锁定,用户在某个租户中账号被锁定,可以切换到其他租户继续登录
(2)系统级别锁定,用户无法登录任意租户系统
如果调用 RPC 接口出现以下问题,可以联系注册登录模块人员出包升级 weaver-passport 处理。
相关代码 【lock-租户级别锁定、unlock-租户级别解锁、sysLock-系统级锁定、sysUnLock-系统级解锁】
java
@GetMapping("/lock")
public WeaResult<BasicCommonI18nResult<Boolean>> lock() {
log.error("当前要锁定账户 ---> ");
Long employeeId = Convert.toLong("1161719504622239745");
Long userId = Convert.toLong("6855375158169694729");
BatchBasicCommonUserLockDto batchDto = new BatchBasicCommonUserLockDto().setOnceOffLine(true);//是否下线
List<BasicCommonUserLockDto> dtoList = new ArrayList<>();
BasicCommonUserLockDto dto = new BasicCommonUserLockDto()
.setEmployeeId(employeeId).setTenantKey("tv6f3n07lw")
.setUserId(userId).setLockType("EMPLOYEE_LOCK").setSourceType("SECOND_DEVELOP");
dtoList.add(dto);
batchDto.setDtoList(dtoList);
BasicCommonI18nResult<Boolean> result = remotePassportBaseService.batchCommonLockUser(batchDto);
log.error("锁定账户结果 ---> " + result);
return WeaResult.success(result);
}
@GetMapping("/unlock")
public WeaResult<BasicCommonI18nResult<Boolean>> unlock() {
log.error("当前要解锁账户 ---> ");
Long employeeId = Convert.toLong("1161719504622239745");
BatchBasicCommonUserLockDto batchDto = new BatchBasicCommonUserLockDto();
BasicCommonUserLockDto dto = new BasicCommonUserLockDto().setEmployeeId(employeeId).setLockType("EMPLOYEE_LOCK");
batchDto.setDtoList(Collections.singletonList(dto));
BasicCommonI18nResult<Boolean> result = remotePassportBaseService.batchCommonUnLockUser(batchDto);
log.error("解锁账户结果 ---> " + result);
return WeaResult.success(result);
}
@GetMapping("sysLock")
public WeaResult<BasicCommonI18nResult<Boolean>> sysLock() {
log.error("系统级锁定账户 ---> ");
Long employeeId = Convert.toLong("1161719504622239745");
Long userId = Convert.toLong("6855375158169694729");
BatchBasicCommonUserLockDto batchDto = new BatchBasicCommonUserLockDto().setOffLineMsg("您的账号已被管理员锁定").setOffLineI18nId("175861").setOnceOffLine(true);
List<BasicCommonUserLockDto> dtoList = new ArrayList<>();
BasicCommonUserLockDto dto = new BasicCommonUserLockDto()
.setEmployeeId(employeeId).setTenantKey("all_teams")
.setUserId(userId).setLockType("ACCOUNT_LOCK").setSourceType("SECOND_DEVELOP");
dtoList.add(dto);
batchDto.setDtoList(dtoList);
BasicCommonI18nResult<Boolean> result = remotePassportBaseService.batchCommonLockUser(batchDto);
log.error("系统级锁定结果 ---> " + result);
return WeaResult.success(result);
}
@GetMapping("/sysUnLock")
public WeaResult<BasicCommonI18nResult<Boolean>> sysUnLock() {
log.error("系统级解锁 --->");
Long userId = Convert.toLong("6855375158169694729");
BatchBasicCommonUserLockDto batchDto = new BatchBasicCommonUserLockDto();
BasicCommonUserLockDto dto = new BasicCommonUserLockDto().setUserId(userId).setLockType("ACCOUNT_LOCK");
batchDto.setDtoList(Collections.singletonList(dto));
BasicCommonI18nResult<Boolean> result = remotePassportBaseService.batchCommonUnLockUser(batchDto);
log.error("系统级解锁结果 ---> " + result);
return WeaResult.success(result);
}