From 0fdd97203f1f8a7f3e4df221e8d79a4f387d14d6 Mon Sep 17 00:00:00 2001 From: Yjoioooo <5403234+zj_Gitttttttte@user.noreply.gitee.com> Date: Mon, 6 Mar 2023 11:07:00 +0000 Subject: [PATCH] =?UTF-8?q?!296=20add=20=E6=96=B0=E5=A2=9E=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E5=A5=97=E9=A4=90=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20*=20update=20=E4=BF=AE=E6=94=B9=E6=8C=89=E9=92=AE=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E4=B8=BA=E5=90=8C=E6=AD=A5=E5=A5=97=E9=A4=90=20*=20up?= =?UTF-8?q?date=20=E4=BF=AE=E6=94=B9=E5=90=8C=E6=AD=A5=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E5=A5=97=E9=A4=90=E6=8E=A5=E5=8F=A3message=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=20*=20update=20=E4=BF=AE=E6=94=B9=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=A7=9F=E6=88=B7=E5=A5=97=E9=A4=90=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=20*=20update=20=E4=BF=AE=E6=94=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=20*=20add=20=E7=A7=9F=E6=88=B7=E7=AE=A1=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=A7=9F=E6=88=B7=E5=A5=97=E9=A4=90=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysTenantController.java | 19 +++++++++-- .../system/service/ISysTenantService.java | 5 +++ .../service/impl/SysTenantServiceImpl.java | 34 +++++++++++++++++++ ruoyi-ui/src/api/system/tenant.js | 13 +++++++ ruoyi-ui/src/views/system/tenant/index.vue | 23 ++++++++++++- 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysTenantController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysTenantController.java index 5a582caf..2d9d7cd2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysTenantController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysTenantController.java @@ -122,8 +122,8 @@ public class SysTenantController extends BaseController { * 状态修改 */ @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) - @SaCheckPermission("system:tenantPackage:edit") - @Log(title = "租户套餐", businessType = BusinessType.UPDATE) + @SaCheckPermission("system:tenant:edit") + @Log(title = "租户", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") public R changeStatus(@RequestBody SysTenantBo bo) { return toAjax(sysTenantService.updateTenantStatus(bo)); @@ -165,4 +165,19 @@ public class SysTenantController extends BaseController { return R.ok(); } + + /** + * 同步租户套餐 + * + * @param tenantId 租户id + * @param packageId 套餐id + */ + @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) + @SaCheckPermission("system:tenant:edit") + @Log(title = "租户", businessType = BusinessType.UPDATE) + @GetMapping("/syncTenantPackage") + public R syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, @NotBlank(message = "套餐ID不能为空") String packageId) { + return toAjax(sysTenantService.syncTenantPackage(tenantId, packageId)); + } + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java index ee707255..1885bc8d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java @@ -69,4 +69,9 @@ public interface ISysTenantService { * 校验有效期 */ String checkExpireTime(String tenantId); + + /** + * 同步租户套餐 + */ + Boolean syncTenantPackage(String tenantId, String packageId); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java index ea2bc54f..02665add 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java @@ -335,4 +335,38 @@ public class SysTenantServiceImpl implements ISysTenantService { return TenantConstants.NOT_PASS; } + /** + * 同步租户套餐 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean syncTenantPackage(String tenantId, String packageId) { + TenantHelper.enableIgnore(); + SysTenantPackage tenantPackage = sysTenantPackageMapper.selectById(packageId); + List roles = sysRoleMapper.selectList( + new LambdaQueryWrapper().eq(SysRole::getTenantId, tenantId)); + List roleIds = new ArrayList<>(roles.size() - 1); + List menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong); + roles.forEach(item -> { + if (TenantConstants.TENANT_ADMIN_ROLE_KEY.equals(item.getRoleKey())) { + List roleMenus = new ArrayList<>(menuIds.size()); + menuIds.forEach(menuId -> { + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(item.getRoleId()); + roleMenu.setMenuId(menuId); + roleMenus.add(roleMenu); + }); + sysRoleMenuMapper.delete(new LambdaQueryWrapper().eq(SysRoleMenu::getRoleId, item.getRoleId())); + sysRoleMenuMapper.insertBatch(roleMenus); + } else { + roleIds.add(item.getRoleId()); + } + }); + if (!roleIds.isEmpty()) { + sysRoleMenuMapper.delete( + new LambdaQueryWrapper().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds)); + } + TenantHelper.disableIgnore(); + return true; + } } diff --git a/ruoyi-ui/src/api/system/tenant.js b/ruoyi-ui/src/api/system/tenant.js index bb8ebfa0..82535af5 100644 --- a/ruoyi-ui/src/api/system/tenant.js +++ b/ruoyi-ui/src/api/system/tenant.js @@ -73,3 +73,16 @@ export function dynamicClear() { }) } +// 同步租户套餐 +export function syncTenantPackage(tenantId, packageId) { + const data = { + tenantId, + packageId + } + return request({ + url: '/system/tenant/syncTenantPackage', + method: 'get', + params: data + }) +} + diff --git a/ruoyi-ui/src/views/system/tenant/index.vue b/ruoyi-ui/src/views/system/tenant/index.vue index 5f137d2d..571e33a0 100644 --- a/ruoyi-ui/src/views/system/tenant/index.vue +++ b/ruoyi-ui/src/views/system/tenant/index.vue @@ -117,6 +117,13 @@ @click="handleUpdate(scope.row)" v-hasPermi="['system:tenant:edit']" >修改 + 同步套餐