|
@@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
@@ -61,19 +62,33 @@ public class AudioController {
|
|
|
page = "0";
|
|
|
if(size==null || size.length()<1)
|
|
|
size = "0";
|
|
|
- List<Audio> list = new ArrayList<>();
|
|
|
- if(idGroup!=null && idGroup.length()>0)
|
|
|
- list = audioService.SearchByIdGroup(Long.valueOf(idGroup), Integer.valueOf(page), Integer.valueOf(size));
|
|
|
- else if(name!=null && name.length()>0 && album!=null && album.length()>0)
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ List<Audio> list = null;
|
|
|
+ if(idGroup!=null && idGroup.length()>0){
|
|
|
+ Page<Audio> pageRes = audioService.SearchByIdGroup(Long.valueOf(idGroup), Integer.valueOf(page), Integer.valueOf(size));
|
|
|
+ map.put("data", pageRes.getContent());
|
|
|
+ map.put("size", pageRes.getNumberOfElements());
|
|
|
+ map.put("total", pageRes.getTotalElements());
|
|
|
+ }else if(name!=null && name.length()>0 && album!=null && album.length()>0){
|
|
|
list = audioService.SearchByNameAlbum(name, album);
|
|
|
- else if(name!=null && name.length()>0)
|
|
|
+ }else if(name!=null && name.length()>0){
|
|
|
list = audioService.SearchByName(name);
|
|
|
- else if(album!=null && album.length()>0)
|
|
|
+ }else if(album!=null && album.length()>0){
|
|
|
list = audioService.SearchByAlbum(album);
|
|
|
- else
|
|
|
- list = audioService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
|
|
|
+ }else{
|
|
|
+ Page<Audio> pageRes = audioService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
|
|
|
+ map.put("data", pageRes.getContent());
|
|
|
+ map.put("size", pageRes.getNumberOfElements());
|
|
|
+ map.put("total", pageRes.getTotalElements());
|
|
|
+ }
|
|
|
+ if(list!=null){
|
|
|
+ map.put("data", list);
|
|
|
+ map.put("size", list.size());
|
|
|
+ map.put("total", list.size());
|
|
|
+ }
|
|
|
|
|
|
- HttpUtil.responseOkData(request, response, list);
|
|
|
+ HttpUtil.responseOkData(request, response, map);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -113,7 +128,7 @@ public class AudioController {
|
|
|
}
|
|
|
|
|
|
Long idChannel = device.getIdChannel();
|
|
|
- List<Rights> rightsList = rightsService.SearchByIdChannel(idChannel, 0, 0);
|
|
|
+ List<Rights> rightsList = rightsService.SearchByIdChannel(idChannel, 0, 0).getContent();
|
|
|
if(rightsList==null || rightsList.size()<1){
|
|
|
HttpUtil.responseApiCode(request, response, ApiCode.ACCESS_DENIED);
|
|
|
return;
|