|
|
|
@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.cloud.kicc.system.api.entity.Role; |
|
|
|
|
import com.cloud.kicc.system.api.entity.RoleMenu; |
|
|
|
|
import com.cloud.kicc.system.api.entity.RoleTenant; |
|
|
|
|
import com.cloud.kicc.system.mapper.RoleMapper; |
|
|
|
|
import com.cloud.kicc.system.service.RoleMenuService; |
|
|
|
|
import com.cloud.kicc.system.service.RoleService; |
|
|
|
|
import com.cloud.kicc.system.service.RoleTenantService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -27,12 +29,14 @@ import java.util.List;
@@ -27,12 +29,14 @@ import java.util.List;
|
|
|
|
|
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService { |
|
|
|
|
|
|
|
|
|
private final RoleMenuService roleMenuService; |
|
|
|
|
private final RoleTenantService RoleTenantService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean insertRole(Role role) { |
|
|
|
|
// 新增角色信息
|
|
|
|
|
baseMapper.insert(role); |
|
|
|
|
insertRoleTenant(role); |
|
|
|
|
return insertRoleMenu(role); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -61,6 +65,22 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
@@ -61,6 +65,22 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|
|
|
|
return rows; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean insertRoleTenant(Role role) { |
|
|
|
|
boolean rows = true; |
|
|
|
|
// 新增用户与多租户管理
|
|
|
|
|
List<RoleTenant> list = new ArrayList(); |
|
|
|
|
for (String tenantId : role.getTenantIds()) { |
|
|
|
|
RoleTenant rt = new RoleTenant(); |
|
|
|
|
rt.setRoleId(role.getId()); |
|
|
|
|
rt.setMultiTenantId(tenantId); |
|
|
|
|
list.add(rt); |
|
|
|
|
} |
|
|
|
|
if (list.size() > 0) { |
|
|
|
|
rows = RoleTenantService.saveBatch(list); |
|
|
|
|
} |
|
|
|
|
return rows; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Role> selectMyRolesByUserId(String userId) { |
|
|
|
|
return baseMapper.selectRolesByUserId(userId); |
|
|
|
|