|
|
@@ -1,17 +1,16 @@
|
|
|
package com.fs.tenant.service.impl;
|
|
|
|
|
|
-import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.common.constant.UserConstants;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.TreeSelect;
|
|
|
import com.fs.common.core.domain.entity.SysMenu;
|
|
|
-import com.fs.common.core.domain.entity.SysUser;
|
|
|
+import com.fs.common.core.domain.entity.TenantCompanyMenu;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
-import com.fs.company.domain.CompanyMenu;
|
|
|
+
|
|
|
import com.fs.system.service.ISysMenuService;
|
|
|
import com.fs.tenant.domain.TenantInfo;
|
|
|
import com.fs.tenant.mapper.TenantInfoMapper;
|
|
|
@@ -26,7 +25,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -97,7 +95,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
|
|
|
// 从主库查询租户后台菜单表和销售菜单表
|
|
|
List<SysMenu> sysMenus = baseMapper.selectMenuList(new SysMenu());
|
|
|
- List<CompanyMenu> companyMenus = baseMapper.selectCompanyMenuList(new CompanyMenu());
|
|
|
+ List<TenantCompanyMenu> companyMenus = baseMapper.selectCompanyMenuList(new TenantCompanyMenu());
|
|
|
|
|
|
|
|
|
// 异步初始化表和数据
|
|
|
@@ -179,15 +177,15 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R menuChange(String flag,List<SysMenu> sysMenus, List<CompanyMenu> companyMenus) {
|
|
|
+ public R menuChange(String flag,List<SysMenu> sysMenus, List<TenantCompanyMenu> companyMenus) {
|
|
|
if ("sys".equals(flag)) {
|
|
|
List<SysMenu> menuList = baseMapper.selectTenantMenu();
|
|
|
List<SysMenu> result = mergeSysMenu(sysMenus, menuList);
|
|
|
List<TreeSelect> treeSelects = menuService.buildMenuTreeSelect(result);
|
|
|
return R.ok().put("menus", treeSelects);
|
|
|
}
|
|
|
- List<CompanyMenu> menuList = baseMapper.selectTenantComMenu();
|
|
|
- List<CompanyMenu> result = mergeComMenu(companyMenus, menuList);
|
|
|
+ List<TenantCompanyMenu> menuList = baseMapper.selectTenantComMenu();
|
|
|
+ List<TenantCompanyMenu> result = mergeComMenu(companyMenus, menuList);
|
|
|
List<TreeSelect> treeSelects = menuService.buildComMenuTreeSelect(result);
|
|
|
return R.ok().put("menus", treeSelects);
|
|
|
}
|
|
|
@@ -225,13 +223,13 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
* @param tenantList 租户菜单
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<CompanyMenu> mergeComMenu(List<CompanyMenu> standardList, List<CompanyMenu> tenantList) {
|
|
|
+ private List<TenantCompanyMenu> mergeComMenu(List<TenantCompanyMenu> standardList, List<TenantCompanyMenu> tenantList) {
|
|
|
// 租户菜单转成 map:key = menuId
|
|
|
- Map<Long, CompanyMenu> tenantMap = tenantList.stream()
|
|
|
- .collect(Collectors.toMap(CompanyMenu::getMenuId, item -> item));
|
|
|
+ Map<Long, TenantCompanyMenu> tenantMap = tenantList.stream()
|
|
|
+ .collect(Collectors.toMap(TenantCompanyMenu::getMenuId, item -> item));
|
|
|
|
|
|
- List<CompanyMenu> result = new ArrayList<>();
|
|
|
- for (CompanyMenu standard : standardList) {
|
|
|
+ List<TenantCompanyMenu> result = new ArrayList<>();
|
|
|
+ for (TenantCompanyMenu standard : standardList) {
|
|
|
Long menuId = standard.getMenuId();
|
|
|
// 租户有 → 覆盖
|
|
|
if (tenantMap.containsKey(menuId)) {
|
|
|
@@ -247,7 +245,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R menuEdit(List<Long> selected, List<Long> unSelected,String flag,List<SysMenu> addSysMenu,List<CompanyMenu> addCompanyMenu) {
|
|
|
+ public R menuEdit(List<Long> selected, List<Long> unSelected,String flag,List<SysMenu> addSysMenu,List<TenantCompanyMenu> addCompanyMenu) {
|
|
|
if ("sys".equals(flag)){
|
|
|
// 更新选中的
|
|
|
int pitch = baseMapper.updatePitchMenu(selected);
|
|
|
@@ -340,8 +338,8 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CompanyMenu> selectCompanyMenuList(CompanyMenu menu, Long userId) {
|
|
|
- List<CompanyMenu> menuList = baseMapper.selectCompanyMenuList(menu);
|
|
|
+ public List<TenantCompanyMenu> selectCompanyMenuList(TenantCompanyMenu menu, Long userId) {
|
|
|
+ List<TenantCompanyMenu> menuList = baseMapper.selectCompanyMenuList(menu);
|
|
|
// 管理员显示所有菜单信息
|
|
|
// if (SysUser.isAdmin(userId))
|
|
|
// {
|
|
|
@@ -356,14 +354,14 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CompanyMenu getTenantComMenu(Long menuId) {
|
|
|
+ public TenantCompanyMenu getTenantComMenu(Long menuId) {
|
|
|
return baseMapper.selectCompanyMenuById(menuId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String checkComMenuNameUnique(CompanyMenu menu) {
|
|
|
+ public String checkComMenuNameUnique(TenantCompanyMenu menu) {
|
|
|
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
|
|
- CompanyMenu info = baseMapper.checkComMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
|
|
+ TenantCompanyMenu info = baseMapper.checkComMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
|
|
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
|
|
|
{
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
@@ -372,12 +370,12 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int insertComMenu(CompanyMenu menu) {
|
|
|
+ public int insertComMenu(TenantCompanyMenu menu) {
|
|
|
return baseMapper.insertComMenu(menu);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int updateComMenu(CompanyMenu menu) {
|
|
|
+ public int updateComMenu(TenantCompanyMenu menu) {
|
|
|
return baseMapper.updateComMenu(menu);
|
|
|
}
|
|
|
|