zoujiajian 1 年之前
父節點
當前提交
d2a31f973a

+ 4 - 1
netflix-service/src/main/java/com/cyksj/service/claude/ClaudeCodeService.java

@@ -4,6 +4,7 @@ import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.request.ClaudeCodeApiKeysReq;
 import com.cyksj.model.request.ClaudeCodeApiKeysStatusReq;
 import com.cyksj.model.response.ClaudeCodePointsHistoryResp;
+import com.cyksj.model.response.claudecode.ClaudeCodeResp;
 import com.cyksj.model.views.ClaudeCodeUserApiKeysView;
 import com.cyksj.model.views.ClaudeCodeUserPackageView;
 
@@ -49,5 +50,7 @@ public interface ClaudeCodeService {
 
 	ClaudeCodePointsHistoryResp getUserPointsDetail(Long userId, String type, Integer page, Integer limit) throws Exception;
 
-	void getUserPointsStatisticsData(long userId) throws Exception;
+	void getUserPointsStatisticsData(Long userId) throws Exception;
+
+	ClaudeCodeResp getUserDashboard(Long userId) throws Exception;
 }

+ 9 - 1
netflix-service/src/main/java/com/cyksj/service/claude/impl/ClaudeCodeServiceImpl.java

@@ -115,12 +115,20 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 	}
 
 	@Override
-	public void getUserPointsStatisticsData(long userId) throws Exception {
+	public void getUserPointsStatisticsData(Long userId) throws Exception {
 		String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/usage/stats", userId);
 		String responseBody = executeClaudeCodeGetApi(url);
 		ClaudeCodeResp claudeCodeResp = Jsons.parseObject(responseBody, ClaudeCodeResp.class);
 	}
 
+	@Override
+	public ClaudeCodeResp getUserDashboard(Long userId) throws Exception {
+		String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/dashboard", userId);
+		String responseBody = executeClaudeCodeGetApi(url);
+		ClaudeCodeResp claudeCodeResp = Jsons.parseObject(responseBody, ClaudeCodeResp.class);
+		return claudeCodeResp;
+	}
+
 	public void createOrUpdateClaudeCodeUserPackage(Long userId, String planName, Integer codePoints, Integer codeCreditRecovery, Date expiryTime) throws Exception {
 		Map<String, Object> parmas = new HashMap<>();
 		parmas.put("plan_name", planName.replaceAll(";", ""));

+ 12 - 0
netflix-web/src/main/java/com/cyksj/web/controller/claude/ClaudeCodeController.java

@@ -5,6 +5,7 @@ import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.request.ClaudeCodeApiKeysReq;
 import com.cyksj.model.request.ClaudeCodeApiKeysStatusReq;
 import com.cyksj.model.response.ClaudeCodePointsHistoryResp;
+import com.cyksj.model.response.claudecode.ClaudeCodeResp;
 import com.cyksj.model.views.ClaudeCodeUserApiKeysView;
 import com.cyksj.model.views.ClaudeCodeUserPackageView;
 import com.cyksj.service.claude.ClaudeCodeService;
@@ -102,4 +103,15 @@ public class ClaudeCodeController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	/**
+	 * 仪表盘聚合
+	 * 返回 当前订阅/余额卡片 + 今日汇总 + 今日请求列表
+	 */
+	@GetMapping("/get/dashboard")
+	public Result<ClaudeCodeResp> getUserDashboard() {
+		long userId = StpUserUtil.getLoginIdAsLong();
+		ClaudeCodeResp resp = claudeCodeService.getUserDashboard(userId);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
+	}
+
 }