add
This commit is contained in:
@ -33,7 +33,6 @@ qiaoba:
|
|||||||
- /register
|
- /register
|
||||||
- /captchaImage
|
- /captchaImage
|
||||||
- /tenant/normal-list
|
- /tenant/normal-list
|
||||||
- /tenant/test
|
|
||||||
|
|
||||||
springdoc:
|
springdoc:
|
||||||
swagger-ui:
|
swagger-ui:
|
||||||
|
@ -17,8 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户管理 Web层
|
* 租户管理 Web层
|
||||||
*
|
*
|
||||||
@ -63,21 +61,14 @@ public class SysTenantController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/normal-list")
|
@GetMapping("/normal-list")
|
||||||
@Operation(summary = "获取正常列表")
|
@Operation(summary = "获取正常列表[开放接口]")
|
||||||
public TableDataInfo<SysTenant> normalPageList(PageQuery pageQuery) {
|
public TableDataInfo<SysTenant> normalPageList(PageQuery pageQuery) {
|
||||||
return sysTenantService.selectPageList(SysTenantParam.buildNormalSelectParam(), pageQuery);
|
return sysTenantService.selectPageList(SysTenantParam.buildNormalSelectParam(), pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getSetting/{tenantId}")
|
|
||||||
@Operation(summary = "查看设置信息")
|
|
||||||
@PreAuthorize("hasAuthority('tenant:query')")
|
|
||||||
public AjaxResult getSetting(@PathVariable String tenantId) {
|
|
||||||
return AjaxResult.success(sysTenantService.getSetting(tenantId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('tenant:edit')")
|
@PreAuthorize("hasAuthority('tenant:edit')")
|
||||||
@PutMapping("/setting")
|
@PutMapping("/setting")
|
||||||
@Operation(summary = "修改设置信息")
|
@Operation(summary = "修改模式")
|
||||||
public AjaxResult setting(TenantSettingDto dto) {
|
public AjaxResult setting(TenantSettingDto dto) {
|
||||||
return AjaxResult.success(sysTenantService.update(BeanUtil.copyProperties(dto, SysTenant.class)));
|
return AjaxResult.success(sysTenantService.update(BeanUtil.copyProperties(dto, SysTenant.class)));
|
||||||
}
|
}
|
||||||
@ -89,8 +80,12 @@ public class SysTenantController {
|
|||||||
sysTenantService.initData(tenantId);
|
sysTenantService.initData(tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/test")
|
@PreAuthorize("hasAuthority('tenant:remove')")
|
||||||
public void test(HttpServletResponse response) throws Exception {
|
@DeleteMapping("/refreshCache")
|
||||||
sysTenantService.initData("2");
|
@Operation(summary = "刷新缓存")
|
||||||
|
public AjaxResult refreshCache() {
|
||||||
|
sysTenantService.resetCache();
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,8 @@ public class SysTenant extends BaseEntity {
|
|||||||
|
|
||||||
private String mode;
|
private String mode;
|
||||||
|
|
||||||
|
private String initialized;
|
||||||
|
|
||||||
public SysTenant(String tenantId, String status) {
|
public SysTenant(String tenantId, String status) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.qiaoba.module.tenant.filters;
|
package com.qiaoba.module.tenant.filters;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.qiaoba.common.base.code.TenantErrorCode;
|
import com.qiaoba.common.base.code.TenantErrorCode;
|
||||||
import com.qiaoba.common.base.constants.TenantConstant;
|
import com.qiaoba.common.base.constants.TenantConstant;
|
||||||
@ -7,6 +8,7 @@ import com.qiaoba.common.base.context.BaseContext;
|
|||||||
import com.qiaoba.common.database.config.DynamicDataSourceConfig;
|
import com.qiaoba.common.database.config.DynamicDataSourceConfig;
|
||||||
import com.qiaoba.common.database.constants.DynamicDatasourceConstant;
|
import com.qiaoba.common.database.constants.DynamicDatasourceConstant;
|
||||||
import com.qiaoba.common.web.utils.ResponseUtil;
|
import com.qiaoba.common.web.utils.ResponseUtil;
|
||||||
|
import com.qiaoba.common.web.utils.UriUtil;
|
||||||
import com.qiaoba.module.tenant.entity.SysTenant;
|
import com.qiaoba.module.tenant.entity.SysTenant;
|
||||||
import com.qiaoba.module.tenant.enums.TenantStatusEnum;
|
import com.qiaoba.module.tenant.enums.TenantStatusEnum;
|
||||||
import com.qiaoba.module.tenant.service.SysTenantService;
|
import com.qiaoba.module.tenant.service.SysTenantService;
|
||||||
@ -22,6 +24,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,6 +44,8 @@ public class DynamicDataSourceFilter extends OncePerRequestFilter {
|
|||||||
@Resource
|
@Resource
|
||||||
private DynamicDataSourceConfig dynamicDataSourceConfig;
|
private DynamicDataSourceConfig dynamicDataSourceConfig;
|
||||||
|
|
||||||
|
private static final List<String> NOT_NEED_TENANT_URIS = ListUtil.toList("/**/*.html",
|
||||||
|
"/**/*.css", "/**/*.js", "/swagger-resources", "/v3/api-docs/**", "/favicon.ico");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
@ -54,6 +59,13 @@ public class DynamicDataSourceFilter extends OncePerRequestFilter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 不需要租户ID的接口
|
||||||
|
for (String uri : NOT_NEED_TENANT_URIS) {
|
||||||
|
if (UriUtil.match(uri, request.getRequestURI())) {
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SysTenant sysTenant = sysTenantService.selectFromCache(tenantId);
|
SysTenant sysTenant = sysTenantService.selectFromCache(tenantId);
|
||||||
// 检查租户是否允许访问
|
// 检查租户是否允许访问
|
||||||
|
@ -58,14 +58,6 @@ public interface SysTenantService {
|
|||||||
*/
|
*/
|
||||||
SysTenant selectFromCache(String tenantId);
|
SysTenant selectFromCache(String tenantId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取设置信息
|
|
||||||
*
|
|
||||||
* @param tenantId tenantId
|
|
||||||
* @return setting
|
|
||||||
*/
|
|
||||||
TenantSettingVo getSetting(String tenantId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化数据
|
* 初始化数据
|
||||||
*
|
*
|
||||||
|
@ -108,16 +108,6 @@ public class SysTenantServiceImpl implements SysTenantService {
|
|||||||
return sysTenant;
|
return sysTenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TenantSettingVo getSetting(String tenantId) {
|
|
||||||
SysTenant sysTenant = selectById(tenantId);
|
|
||||||
if (Objects.isNull(sysTenant)) {
|
|
||||||
throw new ServiceException("租户不存在");
|
|
||||||
}
|
|
||||||
List<SysTenantDatasource> datasourceList = sysTenantDatasourceService.selectList(tenantId);
|
|
||||||
return new TenantSettingVo(tenantId, sysTenant.getMode(), datasourceList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData(String tenantId) throws Exception {
|
public void initData(String tenantId) throws Exception {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user