From d73bcf75d359be0280f2d323096800ab9ae9d0c2 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 26 Apr 2020 13:07:25 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E9=80=BB=E8=BE=91=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=97=B6=E5=90=8C=E6=AD=A5=E8=B6=85=E7=AE=A1=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E9=BB=98=E8=AE=A4=E4=B8=9A=E5=8A=A1=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/TenantController.java | 2 +- .../system/service/ITenantService.java | 2 +- .../system/service/impl/TenantServiceImpl.java | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java index 477683f0..6bc4d33f 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java @@ -123,7 +123,7 @@ public class TenantController extends BladeController { @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) public R submit(@Valid @RequestBody Tenant tenant) { CacheUtil.clear(SYS_CACHE); - return R.status(tenantService.saveTenant(tenant)); + return R.status(tenantService.submitTenant(tenant)); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/ITenantService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/ITenantService.java index e369bcc7..f6fa9f1a 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/ITenantService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/ITenantService.java @@ -52,7 +52,7 @@ public interface ITenantService extends BaseService { * @param tenant * @return */ - boolean saveTenant(Tenant tenant); + boolean submitTenant(Tenant tenant); /** * 删除 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 d0bda963..7e7ab751 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 @@ -58,6 +58,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp private final IDeptService deptService; private final IPostService postService; private final IRoleMenuService roleMenuService; + private final IDictBizService dictBizService; private final IUserClient userClient; @Override @@ -72,7 +73,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp @Override @Transactional(rollbackFor = Exception.class) - public boolean saveTenant(Tenant tenant) { + public boolean submitTenant(Tenant tenant) { if (Func.isEmpty(tenant.getId())) { List tenants = baseMapper.selectList(Wrappers.query().lambda().eq(Tenant::getIsDeleted, BladeConstant.DB_NOT_DELETED)); List codes = tenants.stream().map(Tenant::getTenantId).collect(Collectors.toList()); @@ -88,7 +89,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp role.setRoleName("管理员"); role.setRoleAlias("admin"); role.setSort(2); - role.setIsDeleted(0); + role.setIsDeleted(BladeConstant.DB_NOT_DELETED); roleService.save(role); // 新建租户对应的角色菜单权限 LinkedList userMenus = new LinkedList<>(); @@ -112,7 +113,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp dept.setFullName(tenant.getTenantName()); dept.setDeptCategory(1); dept.setSort(2); - dept.setIsDeleted(0); + dept.setIsDeleted(BladeConstant.DB_NOT_DELETED); deptService.save(dept); // 新建租户对应的默认岗位 Post post = new Post(); @@ -122,6 +123,13 @@ public class TenantServiceImpl extends BaseServiceImpl imp post.setPostName("首席执行官"); post.setSort(1); postService.save(post); + // 新建租户对应的默认业务字典 + List dictBizList = dictBizService.list(); + dictBizList.forEach(dictBiz -> { + dictBiz.setId(null); + dictBiz.setTenantId(tenantId); + }); + dictBizService.saveBatch(dictBizList); // 新建租户对应的默认管理用户 User user = new User(); user.setTenantId(tenantId); @@ -136,7 +144,7 @@ public class TenantServiceImpl extends BaseServiceImpl imp user.setPostId(String.valueOf(post.getId())); user.setBirthday(new Date()); user.setSex(1); - user.setIsDeleted(0); + user.setIsDeleted(BladeConstant.DB_NOT_DELETED); boolean temp = super.saveOrUpdate(tenant); R result = userClient.saveUser(user); if (!result.isSuccess()) {