Skip to content

Commit 215d7f0

Browse files
authored
Fix the ratio task bug (#194)
* fix: add feign client configurations * fix: add nacos configurations * fix: add python to gateway * fix: Fix the ratio task bug
1 parent 6d61348 commit 215d7f0

File tree

5 files changed

+33
-18
lines changed

5 files changed

+33
-18
lines changed

backend/api-gateway/src/main/java/com/datamate/gateway/ApiGatewayApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.cloud.gateway.route.RouteLocator;
66
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
7+
import org.springframework.cloud.openfeign.EnableFeignClients;
78
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.ComponentScan;
810

911
/**
1012
* API Gateway & Auth Service Application
1113
* 统一的API网关和认证授权微服务
1214
* 提供路由、鉴权、限流等功能
1315
*/
1416
@SpringBootApplication
17+
@ComponentScan(basePackages = {"com.datamate.gateway", "com.terrabase"})
18+
@EnableFeignClients(basePackages = {"com.terrabase"})
1519
public class ApiGatewayApplication {
1620

1721
public static void main(String[] args) {

backend/api-gateway/src/main/java/com/datamate/gateway/filter/UserContextFilter.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.datamate.gateway.filter;
22

3+
import com.terrabase.enterprise.api.UserManagementService;
34
import com.terrabase.enterprise.api.dto.LoginUserDto;
4-
import com.terrabase.enterprise.api.sdk.TerrabaseSDK;
5-
import com.terrabase.enterprise.api.sdk.TerrabaseSDKConfig;
6-
import jakarta.annotation.PostConstruct;
75
import lombok.extern.slf4j.Slf4j;
6+
import org.springframework.beans.factory.annotation.Autowired;
87
import org.springframework.beans.factory.annotation.Value;
98
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
109
import org.springframework.cloud.gateway.filter.GlobalFilter;
@@ -15,33 +14,23 @@
1514
/**
1615
* 用户信息过滤器
1716
*
18-
* @since 2025/12/22
1917
*/
2018
@Slf4j
2119
@Component
2220
public class UserContextFilter implements GlobalFilter {
23-
@Value("${terrabase.jar.path:/opt/terrabase}")
24-
private String jarPath;
25-
2621
@Value("${commercial.switch:false}")
2722
private boolean isCommercial;
2823

29-
private TerrabaseSDK terrabaseSDK;
30-
31-
@PostConstruct
32-
public void init() {
33-
TerrabaseSDKConfig sdkConfig = TerrabaseSDKConfig.createDefault();
34-
sdkConfig.setJarPath(jarPath);
35-
terrabaseSDK = TerrabaseSDK.init(sdkConfig);
36-
}
24+
@Autowired
25+
private UserManagementService userManagementService;
3726

3827
@Override
3928
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
4029
if (!isCommercial) {
4130
return chain.filter(exchange);
4231
}
4332
try {
44-
LoginUserDto loginUserDto = terrabaseSDK.userManagement().getCurrentUserInfo().getData().getFirst();
33+
LoginUserDto loginUserDto = userManagementService.getCurrentUserInfo().getData().getFirst();
4534
} catch (Exception e) {
4635
log.error("get current user info error", e);
4736
return chain.filter(exchange);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
spring:
2+
main:
3+
allow-circular-references: true
4+
application:
5+
name: datamate-gateway # 必须设置应用名
6+
7+
cloud:
8+
nacos:
9+
discovery:
10+
fail-fast: false
11+
# 显式设置端口
12+
port: ${server.port:30000} # 与服务端口一致
13+
server-addr: ${NACOS_ADDR:https://consulservice:18302}
14+
username: consul
15+
password:
16+
ip: ${spring.application.name}
17+
secure: true
18+
cluster-name: DEFAULT
19+
20+
# 服务器端口配置
21+
server:
22+
port: 8080 # 必须有这个配置

runtime/datamate-python/app/module/ratio/service/ratio_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def _filter_file(file: DatasetFiles, conditions: FilterCondition) -> bool:
294294
for tag in all_tags:
295295
if conditions.label.label and tag.get("label") != conditions.label.label:
296296
continue
297-
if conditions.label.value is not None:
297+
if conditions.label.value is None:
298298
return True
299299
if tag.get("value") == conditions.label.value:
300300
return True

scripts/images/gateway/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN cd /opt/gateway/api-gateway && \
1717
FROM eclipse-temurin:21-jdk
1818

1919
RUN apt-get update && \
20-
apt-get install -y vim wget curl dos2unix && \
20+
apt-get install -y vim wget curl python3 python3-pip python-is-python3 dos2unix && \
2121
apt-get clean && \
2222
rm -rf /var/lib/apt/lists/*
2323

0 commit comments

Comments
 (0)