|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.yohoufo.dal.order.QiniuLiveRecordMapper;
|
|
|
import com.yohoufo.dal.order.model.QiniuLiveRecord;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by li.ma on 2018/12/14.
|
|
|
*/
|
|
|
@Service
|
|
|
public class QiniuLiveRecordService {
|
|
|
public static final String LIVE_VEDIO_DOMAIN = "http://flv01.static.yhbimg.com/";
|
|
|
|
|
|
public static final String LIVE_VIDEO_DOMAIN = "http://flv01.static.yhbimg.com/";
|
|
|
|
|
|
@Autowired
|
|
|
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
|
|
|
|
|
|
|
|
|
|
|
|
private static String makeLiveVideoUrl(String filename) {
|
|
|
if (StringUtils.isBlank(filename)) {
|
|
|
return null;
|
|
|
}
|
|
|
return LIVE_VIDEO_DOMAIN + filename;
|
|
|
}
|
|
|
|
|
|
|
|
|
public void updateStatusByPersistId(String persistId, Integer code) {
|
|
|
if (Integer.valueOf(0).equals(code)) {
|
|
|
qiniuLiveRecordMapper.updateStatusByPersistId(persistId, 1); // 更新直播记录状态为已转码成功
|
...
|
...
|
@@ -33,8 +50,27 @@ public class QiniuLiveRecordService { |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
qiniuLiveRecords.setVedioFileUrl(LIVE_VEDIO_DOMAIN + qiniuLiveRecords.getVedioFileUrl());
|
|
|
qiniuLiveRecords.setVedioFileUrl(makeLiveVideoUrl(qiniuLiveRecords.getVedioFileUrl()));
|
|
|
|
|
|
return qiniuLiveRecords;
|
|
|
}
|
|
|
|
|
|
public Map<Long, String> getAppraiseVideoUrl(List<Long> orderCodes) {
|
|
|
if (CollectionUtils.isEmpty(orderCodes)) {
|
|
|
return Maps.newHashMap();
|
|
|
}
|
|
|
return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream()
|
|
|
.collect(Collectors.toMap(QiniuLiveRecord::getOrderCode,
|
|
|
e -> QiniuLiveRecordService.makeLiveVideoUrl(e.getVedioFileUrl()),
|
|
|
(o, n) -> o));
|
|
|
}
|
|
|
|
|
|
public String getAppraiseVideoUrl(Long orderCode) {
|
|
|
return Optional.ofNullable(orderCode)
|
|
|
.map(qiniuLiveRecordMapper::selectByOrderCode)
|
|
|
.map(QiniuLiveRecord::getVedioFileUrl)
|
|
|
.map(QiniuLiveRecordService::makeLiveVideoUrl)
|
|
|
.orElse(null);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|