fix(media): 补齐分集转码绑定与产物回填
This commit is contained in:
1 parent
6bdd245a83
commit
7d563f2cd6
18 files changed
+812
-25
No files matched your search
+32
-1
@@ -15,6 +15,8 @@ import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.content.enums.ContentStatus;
|
||||
import com.fruitshorts.content.vo.EpisodeRespVO;
|
||||
import com.fruitshorts.content.vo.EpisodeSaveReqVO;
|
||||
import com.fruitshorts.media.service.EpisodeTranscodeBindingService;
|
||||
import com.fruitshorts.media.service.EpisodeTranscodeCompletionPort;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,7 +31,7 @@ import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EpisodeService {
|
||||
public class EpisodeService implements EpisodeTranscodeCompletionPort {
|
||||
|
||||
private static final int DEFAULT_PAGE_INDEX = 1;
|
||||
private static final int DEFAULT_PAGE_SIZE = 100;
|
||||
@@ -37,6 +39,7 @@ public class EpisodeService {
|
||||
|
||||
private final DramaEpisodeMapper dramaEpisodeMapper;
|
||||
private final DramaService dramaService;
|
||||
private final EpisodeTranscodeBindingService transcodeBindingService;
|
||||
|
||||
/** 后台:按短剧分页查询分集,status 在 SQL 层过滤;排序稳定(sort、ep_no)。 */
|
||||
public PageResult<EpisodeRespVO> pageByDrama(Long dramaId, String status,
|
||||
@@ -135,6 +138,7 @@ public class EpisodeService {
|
||||
episode.setLikeCount(nonNegativeOrZero(req.getLikeCount()));
|
||||
episode.setVideoAssetId(0L);
|
||||
dramaEpisodeMapper.insert(episode);
|
||||
bindTranscodeTask(episode);
|
||||
dramaService.syncTotalEpisodes(req.getDramaId());
|
||||
return episode.getId();
|
||||
}
|
||||
@@ -152,6 +156,7 @@ public class EpisodeService {
|
||||
episode.setStatus(req.getStatus());
|
||||
}
|
||||
dramaEpisodeMapper.updateById(episode);
|
||||
bindTranscodeTask(episode);
|
||||
if (!req.getDramaId().equals(episode.getDramaId())) {
|
||||
dramaService.syncTotalEpisodes(req.getDramaId());
|
||||
}
|
||||
@@ -252,6 +257,32 @@ public class EpisodeService {
|
||||
episode.setSort(req.getSort() == null ? (req.getNumber() == null ? 0 : req.getNumber()) : req.getSort());
|
||||
}
|
||||
|
||||
private void bindTranscodeTask(DramaEpisode episode) {
|
||||
Long assetId = transcodeBindingService.bind(
|
||||
episode.getId(), episode.getDramaId(), episode.getVideoUrl());
|
||||
if (assetId != null && assetId > 0
|
||||
&& !Objects.equals(assetId, episode.getVideoAssetId())) {
|
||||
episode.setVideoAssetId(assetId);
|
||||
dramaEpisodeMapper.updateById(episode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void markEpisodeReady(Long episodeId, String hlsUrl, Integer durationSec) {
|
||||
if (episodeId == null || episodeId <= 0 || !StringUtils.hasText(hlsUrl)) {
|
||||
return;
|
||||
}
|
||||
var update = Wrappers.<DramaEpisode>lambdaUpdate()
|
||||
.eq(DramaEpisode::getId, episodeId)
|
||||
.set(DramaEpisode::getHlsUrl, hlsUrl)
|
||||
.set(DramaEpisode::getTranscodeStatus, "success");
|
||||
if (durationSec != null && durationSec > 0) {
|
||||
update.set(DramaEpisode::getDurationSec, durationSec);
|
||||
}
|
||||
dramaEpisodeMapper.update(null, update);
|
||||
}
|
||||
|
||||
private EpisodeRespVO toResp(DramaEpisode episode) {
|
||||
EpisodeRespVO vo = new EpisodeRespVO();
|
||||
vo.setId(episode.getId());
|
||||
|
||||
Reference in new issue
Block a user