|
@@ -6,14 +6,17 @@ import cn.efunbox.audio.repository.hag.HagAlbumRepository;
|
|
import cn.efunbox.audio.repository.hag.HagContentRepository;
|
|
import cn.efunbox.audio.repository.hag.HagContentRepository;
|
|
import cn.efunbox.audio.service.hag.HagContentService;
|
|
import cn.efunbox.audio.service.hag.HagContentService;
|
|
import cn.efunbox.audio.utils.DateUtil;
|
|
import cn.efunbox.audio.utils.DateUtil;
|
|
|
|
+import cn.efunbox.audio.utils.MD5;
|
|
import cn.efunbox.audio.vo.hag.*;
|
|
import cn.efunbox.audio.vo.hag.*;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -24,11 +27,18 @@ import java.util.*;
|
|
@Service
|
|
@Service
|
|
public class HagContentServiceImpl implements HagContentService {
|
|
public class HagContentServiceImpl implements HagContentService {
|
|
|
|
|
|
|
|
+ @Value("${hag.oss.audio.prefix}")
|
|
|
|
+ private String hagAudioPrefix;
|
|
|
|
+
|
|
|
|
+ @Value("${hag.cdn.secret.sign.key}")
|
|
|
|
+ private String cdnSecret;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private HagContentRepository hagContentRepository;
|
|
private HagContentRepository hagContentRepository;
|
|
@Autowired
|
|
@Autowired
|
|
private HagAlbumRepository hagAlbumRepository;
|
|
private HagAlbumRepository hagAlbumRepository;
|
|
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HagBaseResp list(HagContentReq hagContentReq) {
|
|
public HagBaseResp list(HagContentReq hagContentReq) {
|
|
|
|
|
|
@@ -167,7 +177,7 @@ public class HagContentServiceImpl implements HagContentService {
|
|
command.setNamespace("AudioPlayer");
|
|
command.setNamespace("AudioPlayer");
|
|
command.setName("Play");
|
|
command.setName("Play");
|
|
AudioUrl audioUrl = new AudioUrl();
|
|
AudioUrl audioUrl = new AudioUrl();
|
|
- audioUrl.setUrl(url);
|
|
|
|
|
|
+ audioUrl.setUrl(hagAudioPrefix + md5PlayUrl(cdnSecret, url));
|
|
Map<String,List<AudioUrl>> map = new HashMap<>();
|
|
Map<String,List<AudioUrl>> map = new HashMap<>();
|
|
map.put("audioItemList",Arrays.asList(audioUrl));
|
|
map.put("audioItemList",Arrays.asList(audioUrl));
|
|
command.setBody(map);
|
|
command.setBody(map);
|
|
@@ -175,4 +185,14 @@ public class HagContentServiceImpl implements HagContentService {
|
|
hagSkillResp.setReply(reply);
|
|
hagSkillResp.setReply(reply);
|
|
return hagSkillResp;
|
|
return hagSkillResp;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private String md5PlayUrl(String key, String url){
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMddHHmm");
|
|
|
|
+ long endTime = System.currentTimeMillis() + (3 * 60 * 1000L);
|
|
|
|
+ Date date = new Date(endTime);
|
|
|
|
+ String time = sdf.format(date);
|
|
|
|
+ String md5Url = MD5.MD5Encode(key + time + url);
|
|
|
|
+ return "/" + time + "/" + md5Url + url;
|
|
|
|
+ }
|
|
}
|
|
}
|