From dea5038de212f54f57d69ed251d10eea05af0af4 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Fri, 19 Jun 2026 03:01:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20bugcollect=20=E6=B7=BB=E5=8A=A0=20Sourc?= =?UTF-8?q?emap=20=E5=88=97=E8=A1=A8=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 GET /bugcollect/v1/sourcemaps 端点 - SourcemapService 新增 listByAppKey 方法 - 新增 SourcemapInfo DTO - LogSourcemapRepository 新增 findByAppKey 查询 Co-Authored-By: Claude --- .../bugcollect/controller/LogController.java | 5 +++++ .../com/xuqm/bugcollect/dto/SourcemapInfo.java | 14 ++++++++++++++ .../repository/LogSourcemapRepository.java | 3 +++ .../bugcollect/service/SourcemapService.java | 17 +++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/dto/SourcemapInfo.java diff --git a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/controller/LogController.java b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/controller/LogController.java index 73e240e..7ff36ea 100644 --- a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/controller/LogController.java +++ b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/controller/LogController.java @@ -203,6 +203,11 @@ public class LogController { return ApiResponse.success(sourcemapService.upload(appKey, platform, appVersion, bundleVersion, bundleName, file)); } + @GetMapping("/sourcemaps") + public ApiResponse> listSourcemaps(@RequestParam String appKey) { + return ApiResponse.success(sourcemapService.listByAppKey(appKey)); + } + // ── Webhooks ─────────────────────────────────────────────────────────────── @GetMapping("/webhooks") diff --git a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/dto/SourcemapInfo.java b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/dto/SourcemapInfo.java new file mode 100644 index 0000000..3d3c757 --- /dev/null +++ b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/dto/SourcemapInfo.java @@ -0,0 +1,14 @@ +package com.xuqm.bugcollect.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.LocalDateTime; + +public record SourcemapInfo( + @JsonProperty("id") Long id, + @JsonProperty("appKey") String appKey, + @JsonProperty("platform") String platform, + @JsonProperty("appVersion") String appVersion, + @JsonProperty("bundleName") String bundleName, + @JsonProperty("storageKey") String storageKey, + @JsonProperty("uploadedAt") LocalDateTime uploadedAt +) {} diff --git a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/repository/LogSourcemapRepository.java b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/repository/LogSourcemapRepository.java index 4fffcaa..f8663f3 100644 --- a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/repository/LogSourcemapRepository.java +++ b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/repository/LogSourcemapRepository.java @@ -3,6 +3,7 @@ package com.xuqm.bugcollect.repository; import com.xuqm.bugcollect.entity.LogSourcemapEntity; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface LogSourcemapRepository extends JpaRepository { @@ -10,5 +11,7 @@ public interface LogSourcemapRepository extends JpaRepository findByAppKeyAndPlatformAndAppVersionAndBundleName( String appKey, String platform, String appVersion, String bundleName); + List findByAppKey(String appKey); + void deleteByAppKey(String appKey); } diff --git a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/service/SourcemapService.java b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/service/SourcemapService.java index ba0c590..077ff8f 100644 --- a/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/service/SourcemapService.java +++ b/xuqm-bugcollect-service/src/main/java/com/xuqm/bugcollect/service/SourcemapService.java @@ -1,5 +1,6 @@ package com.xuqm.bugcollect.service; +import com.xuqm.bugcollect.dto.SourcemapInfo; import com.xuqm.bugcollect.dto.SourcemapUploadResponse; import com.xuqm.bugcollect.entity.LogSourcemapEntity; import com.xuqm.bugcollect.repository.LogSourcemapRepository; @@ -15,6 +16,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.time.LocalDateTime; +import java.util.List; import java.util.Set; @Service @@ -110,4 +112,19 @@ public class SourcemapService { public String readSourceMapContent(String storageKey) throws IOException { return Files.readString(Paths.get(storageKey)); } + + public List listByAppKey(String appKey) { + return sourcemapRepository.findByAppKey(appKey) + .stream() + .map(entity -> new SourcemapInfo( + entity.getId(), + entity.getAppKey(), + entity.getPlatform(), + entity.getAppVersion(), + entity.getBundleName(), + entity.getStorageKey(), + entity.getUploadedAt() + )) + .toList(); + } }