!296 add 新增租户套餐同步功能

* update 修改按钮简化为同步套餐
* update 修改同步租户套餐接口message错误描述
* update 修改同步租户套餐权限字符
* update 修改状态修改权限字符
* add 租户管理新增租户套餐同步功能
feature/model
Yjoioooo 2 years ago committed by MichelleChung
parent b4645daf2a
commit 0fdd97203f

@ -122,8 +122,8 @@ public class SysTenantController extends BaseController {
* *
*/ */
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
@SaCheckPermission("system:tenantPackage:edit") @SaCheckPermission("system:tenant:edit")
@Log(title = "租户套餐", businessType = BusinessType.UPDATE) @Log(title = "租户", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus") @PutMapping("/changeStatus")
public R<Void> changeStatus(@RequestBody SysTenantBo bo) { public R<Void> changeStatus(@RequestBody SysTenantBo bo) {
return toAjax(sysTenantService.updateTenantStatus(bo)); return toAjax(sysTenantService.updateTenantStatus(bo));
@ -165,4 +165,19 @@ public class SysTenantController extends BaseController {
return R.ok(); 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<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, @NotBlank(message = "套餐ID不能为空") String packageId) {
return toAjax(sysTenantService.syncTenantPackage(tenantId, packageId));
}
} }

@ -69,4 +69,9 @@ public interface ISysTenantService {
* *
*/ */
String checkExpireTime(String tenantId); String checkExpireTime(String tenantId);
/**
*
*/
Boolean syncTenantPackage(String tenantId, String packageId);
} }

@ -335,4 +335,38 @@ public class SysTenantServiceImpl implements ISysTenantService {
return TenantConstants.NOT_PASS; return TenantConstants.NOT_PASS;
} }
/**
*
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean syncTenantPackage(String tenantId, String packageId) {
TenantHelper.enableIgnore();
SysTenantPackage tenantPackage = sysTenantPackageMapper.selectById(packageId);
List<SysRole> roles = sysRoleMapper.selectList(
new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, tenantId));
List<Long> roleIds = new ArrayList<>(roles.size() - 1);
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
roles.forEach(item -> {
if (TenantConstants.TENANT_ADMIN_ROLE_KEY.equals(item.getRoleKey())) {
List<SysRoleMenu> 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<SysRoleMenu>().eq(SysRoleMenu::getRoleId, item.getRoleId()));
sysRoleMenuMapper.insertBatch(roleMenus);
} else {
roleIds.add(item.getRoleId());
}
});
if (!roleIds.isEmpty()) {
sysRoleMenuMapper.delete(
new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds));
}
TenantHelper.disableIgnore();
return true;
}
} }

@ -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
})
}

@ -117,6 +117,13 @@
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['system:tenant:edit']" v-hasPermi="['system:tenant:edit']"
>修改</el-button> >修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleSyncTenantPackage(scope.row)"
v-hasPermi="['system:tenant:edit']"
>同步套餐</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -192,7 +199,7 @@
</template> </template>
<script> <script>
import { listTenant, getTenant, delTenant, addTenant, updateTenant, changeTenantStatus } from "@/api/system/tenant"; import { listTenant, getTenant, delTenant, addTenant, updateTenant, changeTenantStatus, syncTenantPackage} from "@/api/system/tenant";
import { listTenantPackage } from "@/api/system/tenantPackage"; import { listTenantPackage } from "@/api/system/tenantPackage";
export default { export default {
@ -406,6 +413,20 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
/** 同步租户套餐按钮操作 */
handleSyncTenantPackage(row) {
this.$modal.confirm('是否确认同步租户套餐租户编号为"' + row.tenantId + '"的数据项?').then(() => {
this.loading = true;
return syncTenantPackage(row.tenantId, row.packageId);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("同步成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
this.download('system/tenant/export', { this.download('system/tenant/export', {

Loading…
Cancel
Save