邀请用户加入租户,支持通过用户账号

pull/8722/head
JEECG 2025-08-12 18:17:55 +08:00
parent 420d6db3fb
commit 3d9f59c69b
3 changed files with 25 additions and 9 deletions

View File

@ -412,8 +412,11 @@ public class SysTenantController {
*/
@PutMapping("/invitationUserJoin")
@RequiresPermissions("system:tenant:invitation:user")
public Result<String> invitationUserJoin(@RequestParam("ids") String ids,@RequestParam("phone") String phone){
sysTenantService.invitationUserJoin(ids,phone);
public Result<String> invitationUserJoin(@RequestParam("ids") String ids,@RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "username", required = false) String username){
if(oConvertUtils.isEmpty(phone) && oConvertUtils.isEmpty(username)){
return Result.error("手机号和用户账号不能同时为空!");
}
sysTenantService.invitationUserJoin(ids,phone,username);
return Result.ok("邀请用户成功");
}

View File

@ -49,8 +49,9 @@ public interface ISysTenantService extends IService<SysTenant> {
* ,
* @param ids
* @param phone
* @param username
*/
void invitationUserJoin(String ids, String phone);
void invitationUserJoin(String ids, String phone,String username);
/**
*

View File

@ -104,15 +104,27 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
@Override
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
public void invitationUserJoin(String ids, String phone) {
public void invitationUserJoin(String ids, String phone,String username) {
String[] idArray = ids.split(SymbolConstant.COMMA);
String userId = null;
SysUser userByPhone = null;
//update-begin---author:wangshuai ---date:20230313 for【QQYUN-4605】后台的邀请谁加入租户没办法选不是租户下的用户通过手机号邀请------------
SysUser userByPhone = userService.getUserByPhone(phone);
//说明用户不存在
if(null == userByPhone){
throw new JeecgBootException("当前用户不存在,请核对手机号");
if(oConvertUtils.isNotEmpty(phone)){
userByPhone = userService.getUserByPhone(phone);
//说明用户不存在
if(null == userByPhone){
throw new JeecgBootException("当前用户不存在,请核对手机号");
}
userId = userByPhone.getId();
}else{
userByPhone = userService.getUserByName(username);
//说明用户不存在
if(null == userByPhone){
throw new JeecgBootException("当前用户不存在,请核对手机号");
}
userId = userByPhone.getId();
}
String userId = userByPhone.getId();
//循环租户id
for (String id:idArray) {
//update-begin---author:wangshuai ---date:20221223 for[QQYUN-3371]租户逻辑改造,改成关系表------------