调整 音频合成
This commit is contained in:
@@ -3,10 +3,14 @@ package com.rj.service.impl;
|
||||
import com.rj.entity.TtsRequestLog;
|
||||
import com.rj.mapper.TtsRequestLogMapper;
|
||||
import com.rj.service.ITtsRequestLogService;
|
||||
import com.rj.utils.MinIOUrlGenerator;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* TTS请求日志服务实现类
|
||||
*
|
||||
@@ -20,6 +24,9 @@ public class TtsRequestLogServiceImpl implements ITtsRequestLogService {
|
||||
@Autowired
|
||||
private TtsRequestLogMapper ttsRequestLogMapper;
|
||||
|
||||
@Autowired
|
||||
private MinIOUrlGenerator urlGenerator;
|
||||
|
||||
@Override
|
||||
public boolean saveTtsRequestLog(TtsRequestLog requestLog) {
|
||||
try {
|
||||
@@ -41,4 +48,48 @@ public class TtsRequestLogServiceImpl implements ITtsRequestLogService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setShortUrlByAudioName(MinIOUrlGenerator.UrlInfo urlInfo ) {
|
||||
try {
|
||||
if (urlInfo == null || urlInfo.getFileName().trim().isEmpty()) {
|
||||
log.error("音频名称不能为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据音频名称查询日志记录
|
||||
LambdaQueryWrapper<TtsRequestLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TtsRequestLog::getAudioName, urlInfo.getFileName());
|
||||
TtsRequestLog requestLog = ttsRequestLogMapper.selectOne(queryWrapper);
|
||||
|
||||
if (requestLog == null) {
|
||||
log.error("未找到音频名称为 {} 的日志记录", urlInfo.getFileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更新日志记录的短链接信息
|
||||
requestLog.setShortUrl(urlInfo.getUrl());
|
||||
requestLog.setShortUrlExpireTime(urlInfo.getExpiresAt());
|
||||
requestLog.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
int result = ttsRequestLogMapper.updateById(requestLog);
|
||||
if (result > 0) {
|
||||
log.info("成功为音频 {} 设置短链接: {}, 过期时间: {}",
|
||||
urlInfo.getFileName(), urlInfo.getUrl(), urlInfo.getFormattedExpiresAt());
|
||||
return true;
|
||||
} else {
|
||||
log.error("更新音频 {} 的短链接失败", urlInfo.getFileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("根据音频名称设置短链接失败: 音频名称={}, 错误={}", urlInfo.getFileName(), e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setShortUrlByAudioName(String audioName) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user