|
@@ -3,9 +3,11 @@ package org.dromara.system.service.impl;
|
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.dromara.common.core.constant.TenantConstants;
|
|
|
import org.dromara.common.core.domain.model.LoginUser;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
+import org.dromara.common.core.utils.ClassUtils;
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -24,9 +26,7 @@ import org.dromara.system.service.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Collection;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 智慧校园_审核意见Service业务层处理
|
|
@@ -71,6 +71,9 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
|
|
|
private final SysDictDataMapper dictDataMapper;
|
|
|
private final SysConfigMapper configMapper;
|
|
|
private final SysRoleMapper sysRoleMapper;
|
|
|
+ private final ISysRoleService sysRoleService;
|
|
|
+ private final SysMenuMapper sysMenuMapper;
|
|
|
+ private final SysRoleMenuMapper roleMenuMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询智慧校园_审核意见
|
|
@@ -163,7 +166,7 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
|
|
|
tenantBo.setId(sysTenant.getId());
|
|
|
|
|
|
copyDict(tenantId);
|
|
|
- copyRole(tenantId);
|
|
|
+ List<SysRole> roleList = copyRole(tenantId);
|
|
|
//部门表生成学校
|
|
|
SysDept dept = new SysDept();
|
|
|
dept.setParentId(0L);
|
|
@@ -200,7 +203,13 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
|
|
|
}
|
|
|
//新增用户与角色管理
|
|
|
//查询当前租户下的学校角色
|
|
|
- Long roleId = sysRoleMapper.selectRoleIdBytenantId(tenantId,"school");
|
|
|
+ Long roleId = 0L;
|
|
|
+ for (SysRole sysRole : roleList) {
|
|
|
+ if("school".equals(sysRole.getRoleKey())){
|
|
|
+ roleId = sysRole.getRoleId();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
Long[] roleIds = {roleId};
|
|
|
sysUserServiceImpl.insertUserRole(use.getUserId(), roleIds,false);
|
|
|
}else{
|
|
@@ -259,7 +268,7 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
|
|
|
}
|
|
|
|
|
|
//新增用户与角色管理
|
|
|
- Long roleId = sysRoleMapper.selectRoleIdBytenantId(sysDept.getTenantId(),"school");
|
|
|
+ Long roleId = sysRoleMapper.selectRoleIdBytenantId(sysDept.getTenantId(),"teacher");
|
|
|
Long[] roleIds = {roleId};
|
|
|
sysUserServiceImpl.insertUserRole(use.getUserId(), roleIds,false);
|
|
|
//老师-班级(学科)数据
|
|
@@ -395,14 +404,24 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
- private void copyRole(String tenantId) {
|
|
|
+ @SneakyThrows
|
|
|
+ private List<SysRole> copyRole(String tenantId) {
|
|
|
String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID;
|
|
|
List<SysRole> roleList = sysRoleMapper.selectList(
|
|
|
new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, defaultTenantId));
|
|
|
for (SysRole sysRole : roleList) {
|
|
|
+ Set<Long> menuIdList = sysMenuMapper.getMenuIdListByRoleId(sysRole.getRoleId());
|
|
|
+ sysRole.setRoleId(null);
|
|
|
sysRole.setTenantId(tenantId);
|
|
|
+ SysRoleBo role = new SysRoleBo();
|
|
|
+ ClassUtils.copyProperties(sysRole, role);
|
|
|
+ Long[] menuIds = menuIdList.toArray(new Long[0]);
|
|
|
+ role.setMenuIds(menuIds);
|
|
|
+ sysRoleService.insertRole(role);
|
|
|
+ sysRole.setRoleId(role.getRoleId());
|
|
|
}
|
|
|
- sysRoleMapper.insertBatch(roleList);
|
|
|
+
|
|
|
+ return roleList;
|
|
|
}
|
|
|
|
|
|
/***
|