You've already forked FrameTour-BE
feat(printer): 添加人脸图片URL重定向功能
- 实现通过人脸样本ID重定向到人脸图片URL的功能 - 实现通过人脸ID重定向到人脸图片URL的功能 - 添加404状态码处理当人脸数据不存在或URL为空的情况 - 使用response.sendRedirect实现URL重定向逻辑
This commit is contained in:
@@ -197,5 +197,36 @@ public class PrinterTvController {
|
|||||||
return ApiResponse.success(resp);
|
return ApiResponse.success(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过人脸样本ID重定向到人脸图片URL
|
||||||
|
*
|
||||||
|
* @param faceSampleId 人脸样本ID
|
||||||
|
* @param response HTTP响应
|
||||||
|
*/
|
||||||
|
@GetMapping("/faceSample/{faceSampleId}/url")
|
||||||
|
public void redirectToFaceSampleUrl(@PathVariable Long faceSampleId, HttpServletResponse response) throws Exception {
|
||||||
|
FaceSampleEntity faceSample = faceRepository.getFaceSample(faceSampleId);
|
||||||
|
if (faceSample == null || faceSample.getFaceUrl() == null) {
|
||||||
|
response.setStatus(404);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response.sendRedirect(faceSample.getFaceUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过人脸ID重定向到人脸图片URL
|
||||||
|
*
|
||||||
|
* @param faceId 人脸ID
|
||||||
|
* @param response HTTP响应
|
||||||
|
*/
|
||||||
|
@GetMapping("/face/{faceId}/url")
|
||||||
|
public void redirectToFaceUrl(@PathVariable Long faceId, HttpServletResponse response) throws Exception {
|
||||||
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
|
if (face == null || face.getFaceUrl() == null) {
|
||||||
|
response.setStatus(404);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response.sendRedirect(face.getFaceUrl());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user