refactor(ops): 安保工单图片预签名下沉至 SecurityOrderExtQueryHandler
将 OrderCenterController 中的 presignExtInfoImageUrls 方法移除, 预签名逻辑下沉至 SecurityOrderExtQueryHandler 数据组装阶段, 通过 OssPresignHelper 就地处理 imageUrl 和 resultImgUrls。 security-biz 新增 infra-api 依赖,RpcConfiguration 注册 FileApi。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package com.viewsh.module.ops.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.viewsh.framework.common.pojo.CommonResult;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.infra.api.file.FileApi;
|
||||
import com.viewsh.module.ops.api.clean.QuickStatsRespDTO;
|
||||
import com.viewsh.module.ops.controller.admin.workorder.vo.statistics.DashboardStatsRespVO;
|
||||
import com.viewsh.module.ops.controller.admin.workorder.vo.statistics.WorkspaceStatsRespVO;
|
||||
@@ -25,9 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.viewsh.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@@ -47,8 +43,6 @@ public class OrderCenterController {
|
||||
|
||||
@Resource
|
||||
private OrderQueryService orderQueryService;
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CleanDashboardService cleanDashboardService;
|
||||
@@ -69,10 +63,7 @@ public class OrderCenterController {
|
||||
@Parameter(name = "id", description = "工单ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order-center:query')")
|
||||
public CommonResult<OrderDetailVO> getDetail(@PathVariable("id") Long id) {
|
||||
OrderDetailVO detail = orderQueryService.getDetail(id);
|
||||
// 私有桶:对 extInfo 中的图片 URL 生成预签名访问地址
|
||||
presignExtInfoImageUrls(detail);
|
||||
return success(detail);
|
||||
return success(orderQueryService.getDetail(id));
|
||||
}
|
||||
|
||||
@GetMapping("/stats")
|
||||
@@ -135,43 +126,4 @@ public class OrderCenterController {
|
||||
return success(opsStatisticsService.getWorkspaceStats());
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 extInfo 中的图片 URL 生成预签名访问地址
|
||||
*/
|
||||
private void presignExtInfoImageUrls(OrderDetailVO detail) {
|
||||
if (detail == null || detail.getExtInfo() == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> extInfo = detail.getExtInfo();
|
||||
// imageUrl:单个告警截图
|
||||
Object imageUrl = extInfo.get("imageUrl");
|
||||
if (imageUrl instanceof String url && StrUtil.isNotEmpty(url)) {
|
||||
try {
|
||||
extInfo.put("imageUrl", fileApi.presignGetUrl(url, null).getCheckedData());
|
||||
} catch (Exception e) {
|
||||
log.warn("[presignExtInfoImageUrls] imageUrl 签名失败: {}", url, e);
|
||||
}
|
||||
}
|
||||
// resultImgUrls:处理结果图片,JSON 数组字符串 如 ["url1","url2"]
|
||||
Object resultImgUrls = extInfo.get("resultImgUrls");
|
||||
if (resultImgUrls instanceof String urlsJson && StrUtil.isNotEmpty(urlsJson)) {
|
||||
try {
|
||||
List<String> urls = cn.hutool.json.JSONUtil.toList(urlsJson, String.class);
|
||||
List<String> signedUrls = urls.stream()
|
||||
.map(u -> {
|
||||
try {
|
||||
return fileApi.presignGetUrl(u, null).getCheckedData();
|
||||
} catch (Exception e) {
|
||||
log.warn("[presignExtInfoImageUrls] resultImgUrl 签名失败: {}", u, e);
|
||||
return u;
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
extInfo.put("resultImgUrls", cn.hutool.json.JSONUtil.toJsonStr(signedUrls));
|
||||
} catch (Exception e) {
|
||||
log.warn("[presignExtInfoImageUrls] 解析 resultImgUrls 失败: {}", resultImgUrls, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.viewsh.module.ops.framework.rpc.config;
|
||||
|
||||
import com.viewsh.module.infra.api.file.FileApi;
|
||||
import com.viewsh.module.iot.api.device.IotDeviceControlApi;
|
||||
import com.viewsh.module.iot.api.device.IotDeviceQueryApi;
|
||||
import com.viewsh.module.iot.api.device.IotDeviceStatusQueryApi;
|
||||
@@ -12,7 +13,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
NotifyMessageSendApi.class,
|
||||
IotDeviceControlApi.class,
|
||||
IotDeviceQueryApi.class,
|
||||
IotDeviceStatusQueryApi.class
|
||||
IotDeviceStatusQueryApi.class,
|
||||
FileApi.class
|
||||
})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user