feat(source): 添加缩略图字段支持

- 在SourceEntity中新增thumbUrl字段用于存储缩略图地址- 在ZTSourceDataService中设置缩略图URL并优化裁剪配置逻辑
- 更新SourceMapper.xml中的SQL语句以支持缩略图字段的插入和更新
- 移除不必要的URL查询条件以提高查询灵活性
This commit is contained in:
2025-10-20 10:05:22 +08:00
parent 2b79302874
commit 8eed685373
3 changed files with 11 additions and 5 deletions

View File

@@ -41,6 +41,10 @@ public class SourceEntity {
* 视频文件存储地址
*/
private String videoUrl;
/**
* 缩略图存储地址
*/
private String thumbUrl;
/**
* 是否被购买 0未购买 1已购买
*/

View File

@@ -56,6 +56,7 @@ public class ZTSourceDataService {
DeviceConfigManager configManager = deviceRepository.getDeviceConfigManager(sourceEntity.getDeviceId());
if (configManager != null) {
if (Strings.isNotBlank(configManager.getString("crop_config"))) {
// 如果有裁剪配置,主URL使用缩略图,同时保持缩略图字段
sourceEntity.setUrl(message.getThumbnailUrl());
}
}
@@ -114,6 +115,7 @@ public class ZTSourceDataService {
entity.setScenicId(message.getScenicId());
entity.setDeviceId(message.getDeviceId());
entity.setUrl(message.getSourceUrl()); // 使用sourceUrl,不使用缩略图
entity.setThumbUrl(message.getThumbnailUrl()); // 设置缩略图URL
entity.setType(2); // 照片类型
// 人脸样本ID处理

View File

@@ -2,12 +2,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ycwl.basic.mapper.SourceMapper">
<insert id="add">
insert into source(id, scenic_id, device_id, url, video_url, `type`, face_sample_id, pos_json, create_time)
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{videoUrl}, #{type}, #{faceSampleId}, #{posJson}, #{createTime})
insert into source(id, scenic_id, device_id, url, video_url, thumb_url, `type`, face_sample_id, pos_json, create_time)
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{videoUrl}, #{thumbUrl}, #{type}, #{faceSampleId}, #{posJson}, #{createTime})
</insert>
<insert id="addFromZTSource">
insert into source(id, scenic_id, device_id, url, `type`, face_sample_id, pos_json, create_time)
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{type}, #{faceSampleId}, #{posJson}, #{createTime})
insert into source(id, scenic_id, device_id, url, thumb_url, `type`, face_sample_id, pos_json, create_time)
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{thumbUrl}, #{type}, #{faceSampleId}, #{posJson}, #{createTime})
</insert>
<insert id="addRelation">
replace member_source(scenic_id, face_id, member_id, source_id, is_buy, type, order_id<if test="isFree">, is_free</if>)
@@ -130,6 +130,7 @@
<if test="deviceId!= null">device_id = #{deviceId}, </if>
<if test="url!= null">url = #{url}, </if>
<if test="videoUrl!= null">video_url = #{videoUrl}, </if>
<if test="thumbUrl!= null">thumb_url = #{thumbUrl}, </if>
<if test="isBuy!=null">is_buy = #{isBuy}, </if>
<if test="type!=null">`type` = #{type}, </if>
<if test="faceSampleId!= null">face_sample_id = #{faceSampleId}, </if>
@@ -180,7 +181,6 @@
<where>
<if test="scenicId!= null">and so.scenic_id = #{scenicId} </if>
<if test="deviceId!= null">and device_id = #{deviceId} </if>
<if test="url!= null">and url = #{url} </if>
<if test="isBuy!=null">
and is_buy = #{isBuy}
</if>