获取专辑图接口新增type参数,为album时表示fileName参数为专辑名而非文件名
This commit is contained in:
parent
e7c269e6ba
commit
cfb36dd830
@ -107,8 +107,8 @@ public class MusicController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String findFile(@RequestBody JSONObject body) {
|
public String findFile(@RequestBody JSONObject body) {
|
||||||
String path = body.getString("path");
|
String path = body.getString("path");
|
||||||
if(!path.startsWith(defaultMusicPath)){
|
if (!path.startsWith(defaultMusicPath)) {
|
||||||
path=Tools.base64ToString(path);
|
path = Tools.base64ToString(path);
|
||||||
}
|
}
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
if (StringUtils.isEmpty(path)) {
|
if (StringUtils.isEmpty(path)) {
|
||||||
@ -133,22 +133,37 @@ public class MusicController {
|
|||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
@RequestMapping(value = "web/image.do",produces = MediaType.IMAGE_JPEG_VALUE)
|
|
||||||
|
@RequestMapping(value = "web/image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public byte[] getImage(String fileName){
|
public byte[] getImage(String fileName, String type) {
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("fileName",fileName);
|
json.put("fileName", fileName);
|
||||||
|
if (StringUtils.isEmpty(type)) {
|
||||||
|
json.put("type", "file");
|
||||||
|
} else {
|
||||||
|
json.put("type", type);
|
||||||
|
}
|
||||||
return getImage(json);
|
return getImage(json);
|
||||||
}
|
}
|
||||||
@RequestMapping(value = "image.do",produces = MediaType.IMAGE_JPEG_VALUE)
|
|
||||||
|
@RequestMapping(value = "image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public byte[] getImage(@RequestBody JSONObject body) {
|
public byte[] getImage(@RequestBody JSONObject body) {
|
||||||
String fileName = body.getString("fileName");
|
String fileName = body.getString("fileName");
|
||||||
if(!fileName.startsWith(defaultMusicPath)){
|
if (!fileName.startsWith(defaultMusicPath)) {
|
||||||
fileName=Tools.base64ToString(fileName);
|
fileName = Tools.base64ToString(fileName);
|
||||||
}
|
}
|
||||||
File file=new File(fileName);
|
List<MusicData> list = null;
|
||||||
if(file.exists()){
|
if (body.getString("type").equals("album")) {
|
||||||
|
list = musicTools.selectAlbum(fileName);
|
||||||
|
}
|
||||||
|
File file;
|
||||||
|
if (list != null && !list.isEmpty()) {
|
||||||
|
fileName = list.get(0).getFile();
|
||||||
|
}
|
||||||
|
file = new File(fileName);
|
||||||
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
return musicTools.readImage(file.getAbsolutePath());
|
return musicTools.readImage(file.getAbsolutePath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -179,11 +194,11 @@ public class MusicController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("play.do")
|
@RequestMapping("play.do")
|
||||||
public ResponseEntity<FileSystemResource> play(String filePath,String random) {
|
public ResponseEntity<FileSystemResource> play(String filePath, String random) {
|
||||||
String _filePath;
|
String _filePath;
|
||||||
boolean _random;
|
boolean _random;
|
||||||
_random= !StringUtils.isEmpty(random) && random.equals("true");
|
_random = !StringUtils.isEmpty(random) && random.equals("true");
|
||||||
_filePath=Tools.base64ToString(filePath);
|
_filePath = Tools.base64ToString(filePath);
|
||||||
if (_random) {
|
if (_random) {
|
||||||
List<MusicData> list = musicTools.getMusicList();
|
List<MusicData> list = musicTools.getMusicList();
|
||||||
MusicData data = list.get(Tools.randomCommon(0, list.size() - 1, 1)[0]);
|
MusicData data = list.get(Tools.randomCommon(0, list.size() - 1, 1)[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user