fix(file): 解决文件下载和时间戳处理问题

- 实现文件名扩展名推断逻辑,从URL路径自动提取并添加扩展名
- 添加下载错误处理和日志记录功能
- 在下载失败时显示错误通知而非成功通知
- 将服务器时间戳处理统一调整为CST(亚洲/上海)时区
- 更新sdk-core版本号至1.1.6-SNAPSHOT
这个提交包含在:
XuqmGroup 2026-06-23 16:43:19 +08:00
父节点 45ea8060b9
当前提交 028ebf4222
共有 4 个文件被更改,包括 15 次插入11 次删除

查看文件

@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.*;
@ -25,6 +26,7 @@ import java.util.*;
public class LogService {
private static final Logger log = LoggerFactory.getLogger(LogService.class);
private static final ZoneId CST = ZoneId.of("Asia/Shanghai");
private final LogIssueRepository issueRepository;
private final LogIssueEventRepository issueEventRepository;
@ -71,9 +73,9 @@ public class LogService {
return;
}
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now(CST);
LocalDateTime eventTime = item.timestamp() > 0
? Instant.ofEpochMilli(item.timestamp()).atZone(ZoneOffset.UTC).toLocalDateTime()
? Instant.ofEpochMilli(item.timestamp()).atZone(CST).toLocalDateTime()
: now;
String exType = item.exception() != null ? item.exception().type() : "";
@ -261,8 +263,8 @@ public class LogService {
entity.setSdkVersion(item.sdk() != null ? item.sdk().version() : null);
entity.setCreatedAt(
item.timestamp() > 0
? Instant.ofEpochMilli(item.timestamp()).atZone(ZoneOffset.UTC).toLocalDateTime()
: LocalDateTime.now()
? Instant.ofEpochMilli(item.timestamp()).atZone(CST).toLocalDateTime()
: LocalDateTime.now(CST)
);
eventRepository.save(entity);
} catch (Exception e) {
@ -399,8 +401,8 @@ public class LogService {
public Page<IssueEventResponse> queryEvents(String appKey, String name, String userId,
String from, String to, int page, int size) {
LocalDateTime fromDate = parseDate(from);
LocalDateTime toDate = parseDate(to) != null ? parseDate(to).plusDays(1) : LocalDateTime.now();
if (fromDate == null) fromDate = LocalDateTime.now().minusDays(7);
LocalDateTime toDate = parseDate(to) != null ? parseDate(to).plusDays(1) : LocalDateTime.now(CST);
if (fromDate == null) fromDate = LocalDateTime.now(CST).minusDays(7);
Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt"));
Page<LogEventEntity> result;
if (name != null && userId != null) {

查看文件

@ -16,6 +16,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
@ -85,7 +86,7 @@ public class SourcemapService {
if (existing.isPresent()) {
entity = existing.get();
entity.setStorageKey(filePath.toString());
entity.setUploadedAt(LocalDateTime.now());
entity.setUploadedAt(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
} else {
entity = newEntity(appKey, platform, appVersion, buildId, bundleName, filePath.toString());
}
@ -96,7 +97,7 @@ public class SourcemapService {
if (existing.isPresent()) {
entity = existing.get();
entity.setStorageKey(filePath.toString());
entity.setUploadedAt(LocalDateTime.now());
entity.setUploadedAt(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
} else {
entity = newEntity(appKey, platform, appVersion, null, bundleName, filePath.toString());
}
@ -123,7 +124,7 @@ public class SourcemapService {
e.setBuildId(buildId);
e.setBundleName(bundleName);
e.setStorageKey(storageKey);
e.setUploadedAt(LocalDateTime.now());
e.setUploadedAt(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
return e;
}

查看文件

@ -21,6 +21,7 @@ import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.HexFormat;
import java.util.List;
import java.util.Map;
@ -184,7 +185,7 @@ public class WebhookService {
entity.setCooldownSec(request.cooldownSec() > 0 ? request.cooldownSec() : 3600);
entity.setSecret(request.secret());
entity.setEnabled(true);
entity.setCreatedAt(LocalDateTime.now());
entity.setCreatedAt(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
try {
entity.setEvents(objectMapper.writeValueAsString(request.events()));
} catch (Exception e) {

查看文件

@ -36,7 +36,7 @@ spring:
max-idle: 8
max-active: 8
jackson:
time-zone: UTC
time-zone: Asia/Shanghai
serialization:
write-dates-as-timestamps: false
flyway: