| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.dev33.satoken.secure.BCrypt; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.common.core.constant.SystemConstants; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.service.WorkflowService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.SpringUtils; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | |
| | | |
| | | // 获取所有租户编号 |
| | | List<String> tenantIds = baseMapper.selectObjs( |
| | | new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), x -> {return Convert.toStr(x);}); |
| | | new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), x -> { |
| | | return Convert.toStr(x); |
| | | }); |
| | | String tenantId = generateTenantId(tenantIds); |
| | | add.setTenantId(tenantId); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | |
| | | config.setTenantId(tenantId); |
| | | } |
| | | configMapper.insertBatch(sysConfigList); |
| | | |
| | | // 未开启工作流不执行下方操作 |
| | | if (SpringUtils.getProperty("warm-flow.enabled", Boolean.class, false)) { |
| | | WorkflowService workflowService = SpringUtils.getBean(WorkflowService.class); |
| | | // 新增租户流程定义 |
| | | workflowService.syncDef(tenantId); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | role.setRoleName(TenantConstants.TENANT_ADMIN_ROLE_NAME); |
| | | role.setRoleKey(TenantConstants.TENANT_ADMIN_ROLE_KEY); |
| | | role.setRoleSort(1); |
| | | role.setStatus(TenantConstants.NORMAL); |
| | | role.setStatus(SystemConstants.NORMAL); |
| | | roleMapper.insert(role); |
| | | Long roleId = role.getRoleId(); |
| | | |
| | |
| | | // 获取所有租户编号 |
| | | List<String> tenantIds = baseMapper.selectObjs( |
| | | new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId) |
| | | .eq(SysTenant::getStatus, TenantConstants.NORMAL), x -> {return Convert.toStr(x);}); |
| | | .eq(SysTenant::getStatus, SystemConstants.NORMAL), x -> { |
| | | return Convert.toStr(x); |
| | | }); |
| | | List<SysDictType> saveTypeList = new ArrayList<>(); |
| | | List<SysDictData> saveDataList = new ArrayList<>(); |
| | | Set<String> set = new HashSet<>(); |
| | |
| | | Map<String, SysDictData> map = StreamUtils.toIdentityMap(dataListTenant, SysDictData::getDictValue); |
| | | for (SysDictData dictData : dataList) { |
| | | if (!map.containsKey(dictData.getDictValue())) { |
| | | SysDictData data = BeanUtil.toBean(dictData, SysDictData.class); |
| | | // 设置字典编码为 null |
| | | dictData.setDictCode(null); |
| | | dictData.setTenantId(tenantId); |
| | | dictData.setCreateTime(null); |
| | | dictData.setUpdateTime(null); |
| | | data.setDictCode(null); |
| | | data.setTenantId(tenantId); |
| | | data.setCreateTime(null); |
| | | data.setUpdateTime(null); |
| | | set.add(tenantId); |
| | | saveDataList.add(dictData); |
| | | saveDataList.add(data); |
| | | } |
| | | } |
| | | } else { |
| | | dictType.setDictId(null); |
| | | dictType.setTenantId(tenantId); |
| | | dictType.setCreateTime(null); |
| | | dictType.setUpdateTime(null); |
| | | SysDictType type = BeanUtil.toBean(dictType, SysDictType.class); |
| | | type.setDictId(null); |
| | | type.setTenantId(tenantId); |
| | | type.setCreateTime(null); |
| | | type.setUpdateTime(null); |
| | | set.add(tenantId); |
| | | saveTypeList.add(dictType); |
| | | saveTypeList.add(type); |
| | | if (CollUtil.isNotEmpty(dataList)) { |
| | | // 筛选出 dictType 对应的 data |
| | | for (SysDictData dictData : dataList) { |
| | | SysDictData data = BeanUtil.toBean(dictData, SysDictData.class); |
| | | // 设置字典编码为 null |
| | | dictData.setDictCode(null); |
| | | dictData.setTenantId(tenantId); |
| | | dictData.setCreateTime(null); |
| | | dictData.setUpdateTime(null); |
| | | data.setDictCode(null); |
| | | data.setTenantId(tenantId); |
| | | data.setCreateTime(null); |
| | | data.setUpdateTime(null); |
| | | set.add(tenantId); |
| | | saveDataList.add(data); |
| | | } |
| | | saveDataList.addAll(dataList); |
| | | } |
| | | } |
| | | } |