You've already forked FrameTour-BE
feat(video): 添加通过faceId查询最新视频记录功能
- 在AppVideoController中新增getLatestByFaceId接口 - 添加VideoRespVO响应对象导入 - 实现通过faceId和可选templateId查询最新视频记录的功能 - 在VideoMapper中定义queryLatestByFaceIdAndTemplateId方法 - 在VideoRepository中实现查询逻辑 - 在VideoMapper.xml中添加对应的SQL查询语句 - 支持根据faceId和templateId条件查询最新视频记录 - 添加相应的日志记录和异常处理机制
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ycwl.basic.controller.mobile;
|
||||
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.model.mobile.video.dto.VideoViewPermissionDTO;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.model.task.req.VideoInfoReq;
|
||||
import com.ycwl.basic.repository.VideoRepository;
|
||||
import com.ycwl.basic.service.mobile.VideoViewPermissionService;
|
||||
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@@ -90,4 +92,33 @@ public class AppVideoController {
|
||||
return ApiResponse.fail("权限检查失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过faceId和templateId(可选)查询最新的视频记录
|
||||
*
|
||||
* @param faceId 人脸ID
|
||||
* @param templateId 模板ID(可选)
|
||||
* @return 最新的视频记录
|
||||
*/
|
||||
@GetMapping("/latest")
|
||||
public ApiResponse<VideoRespVO> getLatestByFaceId(
|
||||
@RequestParam("faceId") Long faceId,
|
||||
@RequestParam(value = "templateId", required = false) Long templateId) {
|
||||
try {
|
||||
log.debug("查询最新视频记录: faceId={}, templateId={}", faceId, templateId);
|
||||
|
||||
VideoRespVO video = videoRepository.queryLatestByFaceIdAndTemplateId(faceId, templateId);
|
||||
|
||||
if (video == null) {
|
||||
log.info("未找到视频记录: faceId={}, templateId={}", faceId, templateId);
|
||||
return ApiResponse.fail("未找到视频记录");
|
||||
}
|
||||
|
||||
return ApiResponse.success(video);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("查询最新视频记录失败: faceId={}, templateId={}", faceId, templateId, e);
|
||||
return ApiResponse.fail("查询失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,12 @@ public interface VideoMapper {
|
||||
* @return 已购买记录数量
|
||||
*/
|
||||
int countBuyRecordByVideoId(Long videoId);
|
||||
|
||||
/**
|
||||
* 通过faceId和templateId(可选)查询最新的视频记录
|
||||
* @param faceId 人脸ID
|
||||
* @param templateId 模板ID(可选)
|
||||
* @return 最新的视频记录
|
||||
*/
|
||||
VideoRespVO queryLatestByFaceIdAndTemplateId(@NonNull Long faceId, Long templateId);
|
||||
}
|
||||
|
||||
@@ -129,4 +129,14 @@ public class VideoRepository {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过faceId和templateId(可选)查询最新的视频记录
|
||||
* @param faceId 人脸ID
|
||||
* @param templateId 模板ID(可选)
|
||||
* @return 最新的视频记录
|
||||
*/
|
||||
public VideoRespVO queryLatestByFaceIdAndTemplateId(Long faceId, Long templateId) {
|
||||
return videoMapper.queryLatestByFaceIdAndTemplateId(faceId, templateId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,4 +185,20 @@
|
||||
from member_video
|
||||
where video_id = #{videoId} and is_buy = 1
|
||||
</select>
|
||||
|
||||
<!-- 通过faceId和templateId(可选)查询最新的视频记录 -->
|
||||
<select id="queryLatestByFaceIdAndTemplateId" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
|
||||
select v.id, v.scenic_id, v.template_id, v.task_id, v.face_id, tk.worker_id, v.video_url, v.create_time, v.update_time,
|
||||
t.name templateName, t.price templatePrice, t.cover_url templateCoverUrl,
|
||||
tk.task_params taskParams, tk.start_time, tk.end_time, v.height, v.width, v.duration
|
||||
from video v
|
||||
left join template t on v.template_id = t.id
|
||||
left join task tk on v.task_id = tk.id
|
||||
where v.face_id = #{faceId}
|
||||
<if test="templateId != null">
|
||||
and v.template_id = #{templateId}
|
||||
</if>
|
||||
order by v.create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user