zoujiajian il y a 11 mois
Parent
commit
034518c20d

+ 10 - 0
netflix-service/src/main/java/com/cyksj/service/codex/CodexService.java

@@ -57,4 +57,14 @@ public interface CodexService {
      * 获取用户仪表盘数据
      */
     ClaudeCodeResp getUserDashboard(Long userId);
+    
+    /**
+     * 获取Java系统专用的用户OpenAI控制台数据
+     */
+    ClaudeCodeResp getJavaUserDashboard(Long userId);
+    
+    /**
+     * 获取Java系统专用的用户OpenAI图表+明细联动数据
+     */
+    ClaudeCodeResp getJavaUserAnalytics(Long userId);
 }

+ 31 - 0
netflix-service/src/main/java/com/cyksj/service/codex/impl/CodexServiceImpl.java

@@ -423,6 +423,37 @@ public class CodexServiceImpl implements CodexService {
 			throw new BusinessRuntimeException("获取用户仪表盘数据失败");
 		}
 	}
+	
+	@Override
+	public ClaudeCodeResp getJavaUserDashboard(Long userId) {
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		CodexUser codexUser = codexUserMapper.selectOne(Wrappers.lambdaQuery(CodexUser.class).in(CodexUser::getUserId, userIdList).last("limit 1"));
+
+		if (codexUser == null) {
+			throw new BusinessRuntimeException("用户未开通Codex服务");
+		}
+
+		// 调用Codex API获取用户控制台数据
+		String dashboardUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/java/dashboard", userId);
+		ClaudeCodeResp codexResp = executeCodexGetApi(dashboardUrl);
+		return codexResp;
+	}
+	
+	@Override
+	public ClaudeCodeResp getJavaUserAnalytics(Long userId) {
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		CodexUser codexUser = codexUserMapper.selectOne(Wrappers.lambdaQuery(CodexUser.class).in(CodexUser::getUserId, userIdList).last("limit 1"));
+
+		if (codexUser == null) {
+			throw new BusinessRuntimeException("用户未开通Codex服务");
+		}
+
+		// 调用Codex API获取用户分析数据
+		String analyticsUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/java/analytics", userId);
+		ClaudeCodeResp codexResp = executeCodexGetApi(analyticsUrl);
+
+		return codexResp;
+	}
 
 	/**
 	 * Codex DELETE请求

+ 22 - 2
netflix-web/src/main/java/com/cyksj/web/controller/codex/CodexController.java

@@ -111,9 +111,29 @@ public class CodexController {
      * 返回用户的OpenAI使用概览、限额信息、最近活动等综合数据
      */
     @GetMapping("/api/openai/users/dashboard")
-    public Result<ClaudeCodeResp> getUserDashboard() {
+    public ClaudeCodeResp getUserDashboard() {
         long userId = StpUserUtil.getLoginIdAsLong();
         ClaudeCodeResp response = codexService.getUserDashboard(userId);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(response);
+        return response;
+    }
+    
+    /**
+     * 用户OpenAI控制台数据 (Java系统专用接口)
+     */
+    @GetMapping("/api/openai/users/dashboard")
+    public ClaudeCodeResp getJavaUserDashboard() {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        ClaudeCodeResp dashboard = codexService.getJavaUserDashboard(userId);
+        return dashboard;
+    }
+
+    /**
+     * 用户OpenAI图表+明细联动 (Java系统专用接口)
+     */
+    @GetMapping("/api/openai/users/analytics")
+    public ClaudeCodeResp getJavaUserAnalytics() {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        ClaudeCodeResp analytics = codexService.getJavaUserAnalytics(userId);
+        return analytics;
     }
 }