|
|
@@ -16,8 +16,11 @@ import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.domain.CompanyMenu;
|
|
|
import com.fs.framework.datasource.DynamicDataSourceContextHolder;
|
|
|
import com.fs.framework.datasource.TenantDataSourceManager;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.tenant.domain.TenantInfo;
|
|
|
import com.fs.tenant.dto.MenuDto;
|
|
|
+import com.fs.tenant.dto.SysConfigDto;
|
|
|
import com.fs.tenant.mapper.TenantInfoMapper;
|
|
|
import com.fs.tenant.service.TenantInfoService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -43,6 +46,9 @@ public class TenantInfoController extends BaseController
|
|
|
@Autowired
|
|
|
private TenantInfoService tenantInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private TenantInfoMapper tenantInfoMapper;
|
|
|
|
|
|
@@ -179,6 +185,47 @@ public class TenantInfoController extends BaseController
|
|
|
return tenantInfoService.menuEdit(selected, unSelected, menuDto.getFlag(),null,addCompanyMenu);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 租户配置修改
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('tenant:config:edit')")
|
|
|
+ @PostMapping("/config/edit")
|
|
|
+ public R configEdit(@Validated @RequestBody SysConfigDto config)
|
|
|
+ {
|
|
|
+ TenantInfo tenantInfo = tenantInfoMapper.selectTenantInfoById(config.getId());
|
|
|
+ if (tenantInfo.getStatus() == 2) {
|
|
|
+ throw new CustomException("租户初始化中");
|
|
|
+ }
|
|
|
+
|
|
|
+ tenantDataSourceManager.switchTenant(tenantInfo);
|
|
|
+ //修复只能更新的BUG
|
|
|
+ if (null != config.getConfigId()) {
|
|
|
+ return R.ok().put("data", configService.updateConfig(config));
|
|
|
+ } else {
|
|
|
+ return R.ok().put("data", configService.insertConfig(config));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据租户id获取指定配置文件
|
|
|
+ *
|
|
|
+ * @param configKey
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getConfigByKey/{configKey}")
|
|
|
+ public AjaxResult getConfigByKey(@PathVariable String configKey,String id) {
|
|
|
+ TenantInfo tenantInfo = tenantInfoMapper.selectTenantInfoById(id);
|
|
|
+ if (tenantInfo.getStatus() == 2) {
|
|
|
+ throw new CustomException("租户初始化中");
|
|
|
+ }
|
|
|
+
|
|
|
+ tenantDataSourceManager.switchTenant(tenantInfo);
|
|
|
+ SysConfig config = configService.selectConfigByConfigKey(configKey);
|
|
|
+ return AjaxResult.success(config);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取需要更新的后台菜单
|
|
|
*/
|