|
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo> implements TenantInfoService {
|
|
@@ -51,7 +52,7 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void addTenant(TenantInfo tenantInfo) {
|
|
|
+ public void addTenant(TenantInfoDto tenantInfo) {
|
|
|
if(StringUtils.isBlank(tenantInfo.getContactPhone())){
|
|
|
throw new BizException("请填写手机号码");
|
|
|
}
|
|
@@ -71,8 +72,9 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
|
|
|
sysUser.setPhone(tenantInfo.getContactPhone());
|
|
|
sysUser.setRoles(tenantInfo.getSysUser().getRoles());
|
|
|
sysUserDao.insert(sysUser);
|
|
|
- if(sysUser.getRoles() != null && sysUser.getRoles().size() > 0){
|
|
|
- sysUserDao.batchAddEmployeeRole(sysUser.getId(),sysUser.getRoles());
|
|
|
+ if(StringUtils.isNotBlank(tenantInfo.getRoleIds())){
|
|
|
+ List<Integer> roleIds = Arrays.stream(tenantInfo.getRoleIds().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
|
|
|
+ sysUserDao.batchAddEmployeeRole(sysUser.getId(), roleIds);
|
|
|
}
|
|
|
|
|
|
Organization organ=new Organization();
|
|
@@ -101,7 +103,7 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int update(TenantInfo newTenantInfo) {
|
|
|
+ public void updateTenant(TenantInfoDto newTenantInfo) {
|
|
|
TenantInfo existTenantInfo = tenantInfoDao.get(newTenantInfo.getId());
|
|
|
if(Objects.isNull(existTenantInfo)){
|
|
|
throw new BizException("机构不存在");
|
|
@@ -110,11 +112,12 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
|
|
|
if(Objects.isNull(sysUser)){
|
|
|
throw new BizException("机构账户不存在");
|
|
|
}
|
|
|
- if(Objects.nonNull(newTenantInfo.getSysUser())&&!CollectionUtils.isEmpty(newTenantInfo.getSysUser().getRoles())){
|
|
|
+ if(StringUtils.isNotBlank(newTenantInfo.getRoleIds())){
|
|
|
+ List<Integer> roleIds = Arrays.stream(newTenantInfo.getRoleIds().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
|
|
|
//删除当前用户角色
|
|
|
sysUserDao.delEmployeeRole(sysUser.getId());
|
|
|
//新增用户角色
|
|
|
- sysUserDao.batchAddEmployeeRole(sysUser.getId(),sysUser.getRoles());
|
|
|
+ sysUserDao.batchAddEmployeeRole(sysUser.getId(),roleIds);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(newTenantInfo.getContactName())){
|
|
|
sysUser.setRealName(newTenantInfo.getContactName());
|
|
@@ -124,7 +127,7 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
|
|
|
}
|
|
|
sysUserDao.update(sysUser);
|
|
|
imFeignService.update(new ImUserModel(sysUser.getId().toString(),sysUser.getRealName(),sysUser.getAvatar()));
|
|
|
- return tenantInfoDao.update(newTenantInfo);
|
|
|
+ tenantInfoDao.update(newTenantInfo);
|
|
|
}
|
|
|
|
|
|
@Override
|