|
|
@@ -8,14 +8,21 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.enums.DataSourceType;
|
|
|
+import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.framework.datasource.TenantDataSourceManager;
|
|
|
import com.fs.tenant.domain.TenantInfo;
|
|
|
+import com.fs.tenant.dto.MenuDto;
|
|
|
+import com.fs.tenant.mapper.TenantInfoMapper;
|
|
|
import com.fs.tenant.service.TenantInfoService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 租户基础信息Controller(SaaS 下租户表仅在主库,强制走主库)
|
|
|
@@ -31,6 +38,11 @@ public class TenantInfoController extends BaseController
|
|
|
@Autowired
|
|
|
private TenantInfoService tenantInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TenantInfoMapper tenantInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TenantDataSourceManager tenantDataSourceManager;
|
|
|
/**
|
|
|
* 查询租户基础信息列表
|
|
|
*/
|
|
|
@@ -92,7 +104,7 @@ public class TenantInfoController extends BaseController
|
|
|
* 修改租户基础信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('tenant:tenant:edit')")
|
|
|
- @Log(title = "租户基础信息", businessType = BusinessType.UPDATE)
|
|
|
+ @Log(title = "修改租户基础信息", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody TenantInfo tenantInfo)
|
|
|
{
|
|
|
@@ -103,10 +115,43 @@ public class TenantInfoController extends BaseController
|
|
|
* 删除租户基础信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('tenant:tenant:remove')")
|
|
|
- @Log(title = "租户基础信息", businessType = BusinessType.DELETE)
|
|
|
+ @Log(title = "删除租户基础信息", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable String[] ids)
|
|
|
{
|
|
|
return toAjax(tenantInfoService.deleteTenantInfoByIds(ids));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 租户菜单修改(获取租户菜单)
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('tenant:tenant:edit')")
|
|
|
+ @GetMapping("/menu/{id}")
|
|
|
+ public R menuChange(@PathVariable String id)
|
|
|
+ {
|
|
|
+ TenantInfo tenantInfo = tenantInfoMapper.selectTenantInfoById(id);
|
|
|
+ if (tenantInfo.getStatus() == 2) {
|
|
|
+ throw new CustomException("租户初始化中");
|
|
|
+ }
|
|
|
+ tenantDataSourceManager.switchTenant(tenantInfo);
|
|
|
+ return tenantInfoService.menuChange(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 租户菜单修改
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('tenant:tenant:edit')")
|
|
|
+ @PostMapping("/menu/edit")
|
|
|
+ public R menuEdit(@RequestBody MenuDto menuDto)
|
|
|
+ {
|
|
|
+ TenantInfo tenantInfo = tenantInfoMapper.selectTenantInfoById(menuDto.getId());
|
|
|
+
|
|
|
+ if (tenantInfo.getStatus() == 2) {
|
|
|
+ throw new CustomException("租户初始化中");
|
|
|
+ }
|
|
|
+ tenantDataSourceManager.switchTenant(tenantInfo);
|
|
|
+ List<Long> selected = menuDto.getSelected();
|
|
|
+ List<Long> unSelected = menuDto.getUnSelected();
|
|
|
+ return tenantInfoService.menuEdit(selected, unSelected);
|
|
|
+ }
|
|
|
}
|