|
@@ -20,6 +20,7 @@ import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -90,28 +91,7 @@ public class ResourceController {
|
|
|
|
|
|
//有声读物 转 资源
|
|
//有声读物 转 资源
|
|
audioImgList.forEach(ai -> {
|
|
audioImgList.forEach(ai -> {
|
|
- String audioId = ai.getAudioId();
|
|
|
|
- Resource audio = resourceService.get(audioId);
|
|
|
|
- resourceService.initResourceUrl(audio);
|
|
|
|
- String imgId = ai.getImgId();
|
|
|
|
- Resource img = resourceService.get(imgId);
|
|
|
|
- resourceService.initResourceUrl(img);
|
|
|
|
-
|
|
|
|
- Resource resource = new Resource();
|
|
|
|
- //有声读物info
|
|
|
|
- resource.setType(ai.getType());
|
|
|
|
- resource.setId(ai.getId());
|
|
|
|
- resource.setCode(ai.getCode());
|
|
|
|
- resource.setName(ai.getName());
|
|
|
|
- resource.setStatus(ai.getStatus());
|
|
|
|
- resource.setGmtCreated(ai.getGmtCreated());
|
|
|
|
- resource.setGmtModified(ai.getGmtModified());
|
|
|
|
-
|
|
|
|
- //图片info
|
|
|
|
- resource.setImg(img);
|
|
|
|
- //音频info
|
|
|
|
- resource.setAudio(audio);
|
|
|
|
-
|
|
|
|
|
|
+ Resource resource = audioImgToResource(ai);
|
|
resourceList.add(resource);
|
|
resourceList.add(resource);
|
|
});
|
|
});
|
|
page.setList(resourceList);
|
|
page.setList(resourceList);
|
|
@@ -129,6 +109,8 @@ public class ResourceController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
public APIResult<Resource> create(@RequestBody Resource resource) {
|
|
public APIResult<Resource> create(@RequestBody Resource resource) {
|
|
|
|
|
|
@@ -233,6 +215,53 @@ public class ResourceController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @RequestMapping(value = "/audioImg/batch", method = RequestMethod.GET)
|
|
|
|
+ public Map<String, Resource> getAudioImgBatch(@RequestParam("ids") List<String> ids) {
|
|
|
|
+ Map<String, Resource> audioImgMap= new HashMap<>();
|
|
|
|
+ List<AudioImg> audioImgs = audioImgService.findMixByIds(ids);
|
|
|
|
+ if(CollectionUtils.isEmpty(audioImgs)){
|
|
|
|
+ return audioImgMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ audioImgs.forEach(ai -> {
|
|
|
|
+ Resource resource = audioImgToResource(ai);
|
|
|
|
+ audioImgMap.put(ai.getId(),resource);
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return audioImgMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 有声读物 转 资源
|
|
|
|
+ * @param ai
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Resource audioImgToResource(AudioImg ai) {
|
|
|
|
+ String audioId = ai.getAudioId();
|
|
|
|
+ Resource audio = resourceService.get(audioId);
|
|
|
|
+ resourceService.initResourceUrl(audio);
|
|
|
|
+ String imgId = ai.getImgId();
|
|
|
|
+ Resource img = resourceService.get(imgId);
|
|
|
|
+ resourceService.initResourceUrl(img);
|
|
|
|
+
|
|
|
|
+ Resource resource = new Resource();
|
|
|
|
+ //有声读物info
|
|
|
|
+ resource.setType(ai.getType());
|
|
|
|
+ resource.setId(ai.getId());
|
|
|
|
+ resource.setCode(ai.getCode());
|
|
|
|
+ resource.setName(ai.getName());
|
|
|
|
+ resource.setStatus(ai.getStatus());
|
|
|
|
+ resource.setGmtCreated(ai.getGmtCreated());
|
|
|
|
+ resource.setGmtModified(ai.getGmtModified());
|
|
|
|
+
|
|
|
|
+ //图片info
|
|
|
|
+ resource.setImg(img);
|
|
|
|
+ //音频info
|
|
|
|
+ resource.setAudio(audio);
|
|
|
|
+ return resource;
|
|
|
|
+ }
|
|
|
|
+
|
|
private Resource toAudioResource(AudioImgDTO dto) {
|
|
private Resource toAudioResource(AudioImgDTO dto) {
|
|
Resource audio = new Resource();
|
|
Resource audio = new Resource();
|
|
audio.setCode(dto.getCode()+"_"+ResourceType.AUDIO+DateUtil.getTimeStamp());
|
|
audio.setCode(dto.getCode()+"_"+ResourceType.AUDIO+DateUtil.getTimeStamp());
|