From 73745a17454008a4ac0a47d58172c65e09beac84 Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 8 Jan 2020 13:25:59 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=20=E4=BC=98=E5=8C=96=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TenantServiceImpl.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.java index d6e828fe..36efbb17 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.java @@ -26,12 +26,8 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.*; -import org.springblade.system.mapper.DeptMapper; -import org.springblade.system.mapper.MenuMapper; -import org.springblade.system.mapper.RoleMapper; import org.springblade.system.mapper.TenantMapper; -import org.springblade.system.service.IRoleMenuService; -import org.springblade.system.service.ITenantService; +import org.springblade.system.service.*; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; @@ -50,9 +46,9 @@ import java.util.stream.Collectors; public class TenantServiceImpl extends BaseServiceImpl implements ITenantService { private final TenantId tenantId; - private final RoleMapper roleMapper; - private final MenuMapper menuMapper; - private final DeptMapper deptMapper; + private final IRoleService roleService; + private final IMenuService menuService; + private final IDeptService deptService; private final IRoleMenuService roleMenuService; private final IUserClient userClient; @@ -90,7 +86,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp role.setRoleAlias("admin"); role.setSort(2); role.setIsDeleted(0); - roleMapper.insert(role); + roleService.save(role); // 新建租户对应的角色菜单权限 LinkedList userMenus = new LinkedList<>(); List menus = getMenus(menuCodes, userMenus); @@ -112,7 +108,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp dept.setDeptCategory(1); dept.setSort(2); dept.setIsDeleted(0); - deptMapper.insert(dept); + deptService.save(dept); // 新建租户对应的默认管理用户 User user = new User(); user.setTenantId(tenantId); @@ -143,7 +139,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp private List getMenus(List codes, LinkedList menus) { codes.forEach(code -> { - Menu menu = menuMapper.selectOne(Wrappers.query().lambda().eq(Menu::getCode, code).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); + Menu menu = menuService.getOne(Wrappers.query().lambda().eq(Menu::getCode, code).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); menus.add(menu); recursion(menu.getId(), menus); }); @@ -151,7 +147,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp } private void recursion(Long parentId, LinkedList menus) { - List menuList = menuMapper.selectList(Wrappers.query().lambda().eq(Menu::getParentId, parentId).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); + List menuList = menuService.list(Wrappers.query().lambda().eq(Menu::getParentId, parentId).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); menus.addAll(menuList); menuList.forEach(menu -> recursion(menu.getId(), menus)); }