fix: 优化swagger&常规水电锚点查询按照当前用户权限查询
This commit is contained in:
parent
05a3d23f58
commit
5fcc7eca34
@ -1,5 +1,8 @@
|
|||||||
package com.yfd.platform.config;
|
package com.yfd.platform.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.Components;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springdoc.core.models.GroupedOpenApi;
|
import org.springdoc.core.models.GroupedOpenApi;
|
||||||
@ -12,13 +15,24 @@ public class SwaggerConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI projectOpenAPI() {
|
public OpenAPI projectOpenAPI() {
|
||||||
|
// 定义 Header 中的 Token 参数
|
||||||
|
SecurityScheme securityScheme = new SecurityScheme()
|
||||||
|
.type(SecurityScheme.Type.APIKEY) // 类型为 API Key
|
||||||
|
.in(SecurityScheme.In.HEADER) // 放在 Header 中
|
||||||
|
.name("token"); // Header 的名称(也可改为 Authorization)
|
||||||
|
|
||||||
|
SecurityRequirement securityRequirement = new SecurityRequirement()
|
||||||
|
.addList("tokenAuth"); // 关联上面的安全方案名称
|
||||||
|
|
||||||
return new OpenAPI()
|
return new OpenAPI()
|
||||||
.info(new Info()
|
.info(new Info()
|
||||||
.title("项目API 接口文档")
|
.title("项目API 接口文档")
|
||||||
.version("3.0")
|
.version("3.0")
|
||||||
.description("")
|
.description("")
|
||||||
.contact(new Contact().name("郑顺利").email("13910913995@163.com"))
|
.contact(new Contact().name("郑顺利").email("13910913995@163.com"))
|
||||||
);
|
)
|
||||||
|
.components(new Components().addSecuritySchemes("tokenAuth", securityScheme))
|
||||||
|
.addSecurityItem(securityRequirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Bean
|
// @Bean
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import com.yfd.platform.common.DataSourceResult;
|
|||||||
import com.yfd.platform.common.GroupHelper;
|
import com.yfd.platform.common.GroupHelper;
|
||||||
import com.yfd.platform.common.GroupingInfo;
|
import com.yfd.platform.common.GroupingInfo;
|
||||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||||
|
import com.yfd.platform.qgc_base.service.ICurrentUserDataScopeService;
|
||||||
import com.yfd.platform.qgc_data.domain.SysUserDataScope;
|
import com.yfd.platform.qgc_data.domain.SysUserDataScope;
|
||||||
import com.yfd.platform.qgc_data.mapper.SysUserDataScopeMapper;
|
import com.yfd.platform.qgc_data.mapper.SysUserDataScopeMapper;
|
||||||
import com.yfd.platform.qgc_base.domain.SdEngInfoBH;
|
import com.yfd.platform.qgc_base.domain.SdEngInfoBH;
|
||||||
@ -62,6 +63,9 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
|
|||||||
|
|
||||||
private static final Map<String, String> ENG_CODE_NAME_FIELD_MAP = new LinkedHashMap<>();
|
private static final Map<String, String> ENG_CODE_NAME_FIELD_MAP = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICurrentUserDataScopeService currentUserDataScopeService;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ENG_CODE_NAME_FIELD_MAP.put("baseId", "baseName");
|
ENG_CODE_NAME_FIELD_MAP.put("baseId", "baseName");
|
||||||
ENG_CODE_NAME_FIELD_MAP.put("hbrvcd", "hbrvcdName");
|
ENG_CODE_NAME_FIELD_MAP.put("hbrvcd", "hbrvcdName");
|
||||||
@ -2761,7 +2765,20 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
|
|||||||
.append("AND NVL(t.USFL, 1) = 1 ")
|
.append("AND NVL(t.USFL, 1) = 1 ")
|
||||||
.append("AND t.LGTD IS NOT NULL ")
|
.append("AND t.LGTD IS NOT NULL ")
|
||||||
.append("AND t.LTTD IS NOT NULL ");
|
.append("AND t.LTTD IS NOT NULL ");
|
||||||
|
if (!currentUserDataScopeService.getCurrentUserDataScope().isManagedAdmin()) {
|
||||||
|
Set<String> stationCodes = currentUserDataScopeService.getCurrentUserDataScope().getStationCodes();
|
||||||
|
if (!stationCodes.isEmpty()) {
|
||||||
|
// 每个值加单引号,并用逗号连接
|
||||||
|
String inClause = stationCodes.stream()
|
||||||
|
.map(code -> "'" + code + "'") // 如果值本身不含单引号,可简单处理;更严谨需转义
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
sql.append("AND t.STCD IN (").append(inClause).append(") ");
|
||||||
|
}else{
|
||||||
|
result.setData(new ArrayList<>());
|
||||||
|
result.setTotal(0L);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
String filterSql = buildEngPointFilterCondition(dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
String filterSql = buildEngPointFilterCondition(dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||||
if (StrUtil.isNotBlank(filterSql)) {
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
|||||||
@ -111,9 +111,11 @@ spring:
|
|||||||
matching-strategy: ant_path_matcher
|
matching-strategy: ant_path_matcher
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: "${REDIS_HOST:172.16.21.142}"
|
# host: "${REDIS_HOST:172.16.21.142}"
|
||||||
|
host: "${REDIS_HOST:localhost}"
|
||||||
port: "${REDIS_PORT:6379}"
|
port: "${REDIS_PORT:6379}"
|
||||||
password: "${REDIS_PASSWORD:zny5678}"
|
password: "${REDIS_PASSWORD:}"
|
||||||
|
# password: "${REDIS_PASSWORD:zny5678}"
|
||||||
database: "${REDIS_DATABASE:15}"
|
database: "${REDIS_DATABASE:15}"
|
||||||
timeout: 10000ms
|
timeout: 10000ms
|
||||||
lettuce:
|
lettuce:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user