Ver código fonte

分页功能返回总数

yaobo 7 anos atrás
pai
commit
6376f845da
25 arquivos alterados com 227 adições e 144 exclusões
  1. 13 11
      src/main/java/cn/efunbox/audio/controller/AdminController.java
  2. 25 10
      src/main/java/cn/efunbox/audio/controller/AudioController.java
  3. 17 3
      src/main/java/cn/efunbox/audio/controller/ChannelController.java
  4. 23 10
      src/main/java/cn/efunbox/audio/controller/DeviceController.java
  5. 17 8
      src/main/java/cn/efunbox/audio/controller/GroupingController.java
  6. 20 5
      src/main/java/cn/efunbox/audio/controller/RecordController.java
  7. 20 4
      src/main/java/cn/efunbox/audio/controller/RightsController.java
  8. 4 7
      src/main/java/cn/efunbox/audio/impl/AdminServiceImpl.java
  9. 9 10
      src/main/java/cn/efunbox/audio/impl/AudioServiceImpl.java
  10. 6 7
      src/main/java/cn/efunbox/audio/impl/ChannelServiceImpl.java
  11. 9 12
      src/main/java/cn/efunbox/audio/impl/DeviceServiceImpl.java
  12. 6 7
      src/main/java/cn/efunbox/audio/impl/GroupingServiceImpl.java
  13. 15 16
      src/main/java/cn/efunbox/audio/impl/RecordServiceImpl.java
  14. 11 12
      src/main/java/cn/efunbox/audio/impl/RightsServiceImpl.java
  15. 1 1
      src/main/java/cn/efunbox/audio/repository/AudioRepo.java
  16. 3 2
      src/main/java/cn/efunbox/audio/repository/DeviceRepo.java
  17. 4 3
      src/main/java/cn/efunbox/audio/repository/RecordRepo.java
  18. 3 2
      src/main/java/cn/efunbox/audio/repository/RightsRepo.java
  19. 2 1
      src/main/java/cn/efunbox/audio/service/AdminService.java
  20. 3 2
      src/main/java/cn/efunbox/audio/service/AudioService.java
  21. 2 1
      src/main/java/cn/efunbox/audio/service/ChannelService.java
  22. 3 2
      src/main/java/cn/efunbox/audio/service/DeviceService.java
  23. 2 1
      src/main/java/cn/efunbox/audio/service/GroupingService.java
  24. 5 4
      src/main/java/cn/efunbox/audio/service/RecordService.java
  25. 4 3
      src/main/java/cn/efunbox/audio/service/RightsService.java

+ 13 - 11
src/main/java/cn/efunbox/audio/controller/AdminController.java

@@ -10,6 +10,7 @@ import cn.efunbox.audio.utils.HttpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Page;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -20,9 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.sql.Timestamp;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -117,15 +116,18 @@ public class AdminController {
         if(page==null || page.length()<1)
             page = "0";
         if(size==null || size.length()<1)
-            size = "0";
-        List<Admin> adminList = adminService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
-
-        for(int i=0; i<adminList.size(); i++){
-            adminList.get(i).setSalt("");
-            adminList.get(i).setPwd("");
-            adminList.get(i).setToken("");
+            size = "50";
+        Page<Admin> adminList = adminService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
+        for(int i=0; i<adminList.getContent().size(); i++){
+            adminList.getContent().get(i).setSalt("");
+            adminList.getContent().get(i).setPwd("");
+            adminList.getContent().get(i).setToken("");
         }
-        HttpUtil.responseOkData(request, response, adminList);
+        Map<String,Object> map = new HashMap<>();
+        map.put("data", adminList.getContent());
+        map.put("size", adminList.getNumberOfElements());
+        map.put("total", adminList.getTotalElements());
+        HttpUtil.responseOkData(request, response, map);
         return;
     }
 

+ 25 - 10
src/main/java/cn/efunbox/audio/controller/AudioController.java

@@ -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;

+ 17 - 3
src/main/java/cn/efunbox/audio/controller/ChannelController.java

@@ -8,6 +8,7 @@ import cn.efunbox.audio.utils.Common;
 import cn.efunbox.audio.utils.HttpUtil;
 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;
@@ -17,7 +18,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.sql.Timestamp;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by yao on 17-9-26.
@@ -41,6 +44,7 @@ public class ChannelController {
             page = "0";
         if(size==null || size.length()<1)
             size = "0";
+        Map<String,Object> map = new HashMap<>();
         List<Channel> list = null;
         if(idChannel!=null && idChannel.length()>0)
             list = channelService.SearchById(Long.valueOf(idChannel));
@@ -48,10 +52,20 @@ public class ChannelController {
             list = channelService.SearchByName(name);
         else if(idFather!=null && idFather.length()>0)
             list = channelService.SearchByIdFather(Long.valueOf(idFather));
-        else
-            list = channelService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
+        else{
+            Page<Channel> pageRes = channelService.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;
     }
 

+ 23 - 10
src/main/java/cn/efunbox/audio/controller/DeviceController.java

@@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -228,23 +229,35 @@ public class DeviceController {
             page = "0";
         if(size==null || size.length()<1)
             size = "0";
-        List<Device> list = new ArrayList<>();
-        if((idDevice==null || idDevice.length()==0) && (idChannel==null || idChannel.length()==0))
-            list = deviceService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
-        else{
+        Map<String,Object> map = new HashMap<>();
+
+        if((idDevice==null || idDevice.length()==0) && (idChannel==null || idChannel.length()==0)){
+            Page<Device> pageRes = deviceService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
+            for(int i=0; i<pageRes.getNumberOfElements(); i++){
+                pageRes.getContent().get(i).setTokenNew("");
+                pageRes.getContent().get(i).setTokenOld("");
+            }
+            map.put("data", pageRes.getContent());
+            map.put("size", pageRes.getNumberOfElements());
+            map.put("total", pageRes.getTotalElements());
+        }else{
             if(idDevice==null || idDevice.length()==0)
                 idDevice = "0";
             if(idChannel==null || idChannel.length()==0)
                 idChannel = "0";
-            list = deviceService.Search(Long.valueOf(idChannel), Long.valueOf(idDevice), Integer.valueOf(page), Integer.valueOf(size));
+            Page<Device> pageRes = deviceService.Search(Long.valueOf(idChannel), Long.valueOf(idDevice), Integer.valueOf(page), Integer.valueOf(size));
+            for(int i=0; i<pageRes.getNumberOfElements(); i++){
+                System.out.println("i:"+i);
+                pageRes.getContent().get(i).setTokenNew("");
+                pageRes.getContent().get(i).setTokenOld("");
+            }
+            map.put("data", pageRes.getContent());
+            map.put("size", pageRes.getNumberOfElements());
+            map.put("total", pageRes.getTotalElements());
         }
 
-        for(int i=0; i<list.size(); i++){
-            list.get(i).setTokenNew("");
-            list.get(i).setTokenOld("");
-        }
 
-        HttpUtil.responseOkData(request, response, list);
+        HttpUtil.responseOkData(request, response, map);
         return;
     }
 

+ 17 - 8
src/main/java/cn/efunbox/audio/controller/GroupingController.java

@@ -9,6 +9,7 @@ import cn.efunbox.audio.utils.Common;
 import cn.efunbox.audio.utils.HttpUtil;
 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;
@@ -18,7 +19,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.sql.Timestamp;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by yao on 17-9-26.
@@ -46,6 +49,7 @@ public class GroupingController {
 //            HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
 //            return;
 //        }
+        Map<String,Object> map = new HashMap<>();
         List<Grouping> list = null;
         if(idGroup!=null && idGroup.length()>0)
             list = groupingService.SearchById(Long.valueOf(idGroup));
@@ -53,15 +57,20 @@ public class GroupingController {
             list = groupingService.SearchByName(name);
         else if(idFather!=null && idFather.length()>0)
             list = groupingService.SearchByIdFather(Long.valueOf(idFather));
-        else
-            list = groupingService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
-//
-//        if(list==null || list.size()<1){
-//            HttpUtil.responseApiCode(request, response, ApiCode.NOT_FOUND);
-//            return;
-//        }
+        else{
+            Page<Grouping> pageRes = groupingService.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;
     }
 

+ 20 - 5
src/main/java/cn/efunbox/audio/controller/RecordController.java

@@ -6,13 +6,16 @@ import cn.efunbox.audio.utils.ApiCode;
 import cn.efunbox.audio.utils.HttpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 音频点播记录
@@ -42,24 +45,36 @@ public class RecordController {
 //            HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
 //            return;
 //        }
+        Map<String,Object> map = new HashMap<>();
+        Page<Record> pageRes = null;
         List<Record> list = null;
         if(idRecord!=null && idRecord.length()>0)
             list = recordService.SearchById(Long.valueOf(idRecord));
         else if(idChannel!=null && idChannel.length()>0)
-            list = recordService.SearchByIdChannel(Long.valueOf(idChannel), Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = recordService.SearchByIdChannel(Long.valueOf(idChannel), Integer.valueOf(page), Integer.valueOf(size));
         else if(idDevice!=null && idDevice.length()>0)
-            list = recordService.SearchByIdDevice(Long.valueOf(idDevice), Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = recordService.SearchByIdDevice(Long.valueOf(idDevice), Integer.valueOf(page), Integer.valueOf(size));
         else if(idAudio!=null && idAudio.length()>0)
-            list = recordService.SearchByIdAudio(Long.valueOf(idAudio), Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = recordService.SearchByIdAudio(Long.valueOf(idAudio), Integer.valueOf(page), Integer.valueOf(size));
         else
-            list = recordService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = recordService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
 
 //        if(list==null || list.size()<1){
 //            HttpUtil.responseApiCode(request, response, ApiCode.NOT_FOUND);
 //            return;
 //        }
 
-        HttpUtil.responseOkData(request, response, list);
+        if(list!=null){
+            map.put("data", list);
+            map.put("size", list.size());
+            map.put("total", list.size());
+        }else if(pageRes!=null){
+            map.put("data", pageRes.getContent());
+            map.put("size", pageRes.getNumberOfElements());
+            map.put("total", pageRes.getTotalElements());
+        }
+
+        HttpUtil.responseOkData(request, response, map);
         return;
     }
 

+ 20 - 4
src/main/java/cn/efunbox/audio/controller/RightsController.java

@@ -3,6 +3,7 @@ package cn.efunbox.audio.controller;
 import cn.efunbox.audio.consts.Status;
 import cn.efunbox.audio.entity.Channel;
 import cn.efunbox.audio.entity.Grouping;
+import cn.efunbox.audio.entity.Record;
 import cn.efunbox.audio.entity.Rights;
 import cn.efunbox.audio.service.ChannelService;
 import cn.efunbox.audio.service.GroupingService;
@@ -12,6 +13,7 @@ import cn.efunbox.audio.utils.Common;
 import cn.efunbox.audio.utils.HttpUtil;
 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;
@@ -21,7 +23,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.sql.Timestamp;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by yao on 17-9-26.
@@ -55,24 +59,36 @@ public class RightsController {
 //            HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
 //            return;
 //        }
+        Map<String,Object> map = new HashMap<>();
         List<Rights> list = null;
+        Page<Rights> pageRes = null;
         if(idRights!=null && idRights.length()>0)
             list = rightsService.SearchById(Long.valueOf(idRights));
         else if(idChannel!=null && idChannel.length()>0 && idGroup!=null && idGroup.length()>0)
             list = rightsService.SearchByIdChannelAndIdGroup(Long.valueOf(idChannel), Long.valueOf(idGroup));
         else if(idChannel!=null && idChannel.length()>0)
-            list = rightsService.SearchByIdChannel(Long.valueOf(idChannel), Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = rightsService.SearchByIdChannel(Long.valueOf(idChannel), Integer.valueOf(page), Integer.valueOf(size));
         else if(idGroup!=null && idGroup.length()>0)
-            list = rightsService.SearchByIdGroup(Long.valueOf(idGroup), Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = rightsService.SearchByIdGroup(Long.valueOf(idGroup), Integer.valueOf(page), Integer.valueOf(size));
         else
-            list = rightsService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
+            pageRes = rightsService.SearchAll(Integer.valueOf(page), Integer.valueOf(size));
 
 //        if(list==null || list.size()<1){
 //            HttpUtil.responseApiCode(request, response, ApiCode.NOT_FOUND);
 //            return;
 //        }
 
-        HttpUtil.responseOkData(request, response, list);
+        if(list!=null){
+            map.put("data", list);
+            map.put("size", list.size());
+            map.put("total", list.size());
+        }else if(pageRes!=null){
+            map.put("data", pageRes.getContent());
+            map.put("size", pageRes.getNumberOfElements());
+            map.put("total", pageRes.getTotalElements());
+        }
+
+        HttpUtil.responseOkData(request, response, map);
         return;
     }
 

+ 4 - 7
src/main/java/cn/efunbox/audio/impl/AdminServiceImpl.java

@@ -8,6 +8,7 @@ import cn.efunbox.audio.repository.ChannelRepo;
 import cn.efunbox.audio.service.AdminService;
 import cn.efunbox.audio.service.ChannelService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -31,13 +32,9 @@ public class AdminServiceImpl implements AdminService {
     }
 
     @Override
-    public List<Admin> SearchAll(int page, int size){
-        List<Admin> list = new ArrayList<>();
-        if(size > 1){
-            Pageable pageable = new PageRequest(page, size);
-            list = adminRepo.findAll(pageable).getContent();
-        }else
-            list = adminRepo.findAll();
+    public Page<Admin> SearchAll(int page, int size){
+        Pageable pageable = new PageRequest(page, size);
+        Page<Admin> list = adminRepo.findAll(pageable);
         return list;
     }
 

+ 9 - 10
src/main/java/cn/efunbox/audio/impl/AudioServiceImpl.java

@@ -7,6 +7,7 @@ import cn.efunbox.audio.repository.DeviceRepo;
 import cn.efunbox.audio.service.AudioService;
 import cn.efunbox.audio.service.DeviceService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -32,22 +33,20 @@ public class AudioServiceImpl implements AudioService {
     }
 
     @Override
-    public List<Audio> SearchAll(int page, int size){
-        List<Audio> list = new ArrayList<>();
-        if(size > 0){
-            Pageable pageable = new PageRequest(page, size);
-            list = audioRepo.findAll(pageable).getContent();
-        }else
-            list = audioRepo.findAll();
+    public Page<Audio> SearchAll(int page, int size){
+        if(size<=0)
+            size = 50;
+        Pageable pageable = new PageRequest(page, size);
+        Page<Audio> list = audioRepo.findAll(pageable);
         return list;
     }
 
     @Override
-    public List<Audio> SearchByIdGroup(Long idGroup, int page, int size){
+    public Page<Audio> SearchByIdGroup(Long idGroup, int page, int size){
         if(size<=0)
-            size = 100;
+            size = 50;
         Pageable pageable = new PageRequest(page, size);
-        List<Audio> list = audioRepo.findByIdGroup(idGroup, pageable);
+        Page<Audio> list = audioRepo.findByIdGroup(idGroup, pageable);
         return list;
     }
 

+ 6 - 7
src/main/java/cn/efunbox/audio/impl/ChannelServiceImpl.java

@@ -7,6 +7,7 @@ import cn.efunbox.audio.repository.ChannelRepo;
 import cn.efunbox.audio.service.AudioService;
 import cn.efunbox.audio.service.ChannelService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -30,13 +31,11 @@ public class ChannelServiceImpl implements ChannelService {
     }
 
     @Override
-    public List<Channel> SearchAll(int page, int size){
-        List<Channel> list = new ArrayList<>();
-        if(size > 0){
-            Pageable pageable = new PageRequest(page, size);
-            list = channelRepo.findAll(pageable).getContent();
-        }else
-            list = channelRepo.findAll();
+    public Page<Channel> SearchAll(int page, int size){
+        if(size<=0)
+            size = 50;
+        Pageable pageable = new PageRequest(page, size);
+        Page<Channel> list = channelRepo.findAll(pageable);
         return list;
     }
 

+ 9 - 12
src/main/java/cn/efunbox/audio/impl/DeviceServiceImpl.java

@@ -6,6 +6,7 @@ import cn.efunbox.audio.entity.Device;
 import cn.efunbox.audio.repository.DeviceRepo;
 import cn.efunbox.audio.service.DeviceService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -79,28 +80,24 @@ public class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public List<Device> Search(Long idChannel, Long idDevice, int page, int size){
+    public Page<Device> Search(Long idChannel, Long idDevice, int page, int size){
         if(size<=0)
-            size = 100;
+            size = 50;
         Pageable pageable = new PageRequest(page, size);
-        List<Device> list = new ArrayList<>();
+        Page<Device> list = null;
         if(idChannel>0)
             list = deviceRepo.findByIdChannel(idChannel, pageable);
         else if(idDevice>0)
-            list = deviceRepo.findByIdDevice(idDevice);
+            list = deviceRepo.findByIdDevice(idDevice, pageable);
         else
-            list = deviceRepo.findAll(pageable).getContent();
+            list = deviceRepo.findAll(pageable);
         return list;
     }
 
     @Override
-    public List<Device> SearchAll(int page, int size){
-        List<Device> list = new ArrayList<>();
-        if(size > 1){
-            Pageable pageable = new PageRequest(page, size);
-            list = deviceRepo.findAll(pageable).getContent();
-        }else
-            list = deviceRepo.findAll();
+    public Page<Device> SearchAll(int page, int size){
+        Pageable pageable = new PageRequest(page, size);
+        Page<Device> list = deviceRepo.findAll(pageable);
         return list;
     }
 

+ 6 - 7
src/main/java/cn/efunbox/audio/impl/GroupingServiceImpl.java

@@ -7,6 +7,7 @@ import cn.efunbox.audio.repository.GroupingRepo;
 import cn.efunbox.audio.service.ChannelService;
 import cn.efunbox.audio.service.GroupingService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -30,13 +31,11 @@ public class GroupingServiceImpl implements GroupingService {
     }
 
     @Override
-    public List<Grouping> SearchAll(int page, int size){
-        List<Grouping> list = new ArrayList<>();
-        if(size > 0){
-            Pageable pageable = new PageRequest(page, size);
-            list = groupingRepo.findAll(pageable).getContent();
-        }else
-            list = groupingRepo.findAll();
+    public Page<Grouping> SearchAll(int page, int size){
+        if(size<=0)
+            size = 50;
+        Pageable pageable = new PageRequest(page, size);
+        Page<Grouping> list = groupingRepo.findAll(pageable);
         return list;
     }
 

+ 15 - 16
src/main/java/cn/efunbox/audio/impl/RecordServiceImpl.java

@@ -8,6 +8,7 @@ import cn.efunbox.audio.repository.RecordRepo;
 import cn.efunbox.audio.service.AudioService;
 import cn.efunbox.audio.service.RecordService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -25,13 +26,11 @@ public class RecordServiceImpl implements RecordService {
     RecordRepo recordRepo;
 
     @Override
-    public List<Record> SearchAll(int page, int size){
-        List<Record> list = new ArrayList<>();
-        if(size > 0){
-            Pageable pageable = new PageRequest(page, size);
-            list = recordRepo.findAll(pageable).getContent();
-        }else
-            list = recordRepo.findAll();
+    public Page<Record> SearchAll(int page, int size){
+        if(size<=0)
+            size = 50;
+        Pageable pageable = new PageRequest(page, size);
+        Page<Record> list = recordRepo.findAll(pageable);
         return list;
     }
 
@@ -42,29 +41,29 @@ public class RecordServiceImpl implements RecordService {
     }
 
     @Override
-    public List<Record> SearchByIdChannel(Long id, int page, int size){
+    public Page<Record> SearchByIdChannel(Long id, int page, int size){
         if(size<=0)
-            size = 100;
+            size = 50;
         Pageable pageable = new PageRequest(page, size);
-        List<Record> list = recordRepo.findByIdChannel(id, pageable);
+        Page<Record> list = recordRepo.findByIdChannel(id, pageable);
         return list;
     }
 
     @Override
-    public List<Record> SearchByIdDevice(Long id, int page, int size){
+    public Page<Record> SearchByIdDevice(Long id, int page, int size){
         if(size<=0)
-            size = 100;
+            size = 50;
         Pageable pageable = new PageRequest(page, size);
-        List<Record> list = recordRepo.findByIdDevice(id, pageable);
+        Page<Record> list = recordRepo.findByIdDevice(id, pageable);
         return list;
     }
 
     @Override
-    public List<Record> SearchByIdAudio(Long id, int page, int size){
+    public Page<Record> SearchByIdAudio(Long id, int page, int size){
         if(size<=0)
-            size = 100;
+            size = 50;
         Pageable pageable = new PageRequest(page, size);
-        List<Record> list = recordRepo.findByIdAudio(id, pageable);
+        Page<Record> list = recordRepo.findByIdAudio(id, pageable);
         return list;
     }
 

+ 11 - 12
src/main/java/cn/efunbox/audio/impl/RightsServiceImpl.java

@@ -8,6 +8,7 @@ import cn.efunbox.audio.repository.RightsRepo;
 import cn.efunbox.audio.service.ChannelService;
 import cn.efunbox.audio.service.RightsService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -31,13 +32,11 @@ public class RightsServiceImpl implements RightsService {
     }
 
     @Override
-    public List<Rights> SearchAll(int page, int size){
-        List<Rights> list = new ArrayList<>();
-        if(size > 0){
-            Pageable pageable = new PageRequest(page, size);
-            list = rightsRepo.findAll(pageable).getContent();
-        }else
-            list = rightsRepo.findAll();
+    public Page<Rights> SearchAll(int page, int size){
+        if(size<=0)
+            size = 50;
+        Pageable pageable = new PageRequest(page, size);
+        Page<Rights> list = rightsRepo.findAll(pageable);
         return list;
     }
 
@@ -48,20 +47,20 @@ public class RightsServiceImpl implements RightsService {
     }
 
     @Override
-    public List<Rights> SearchByIdChannel(Long id, int page, int size){
+    public Page<Rights> SearchByIdChannel(Long id, int page, int size){
         if(size<=0)
-            size = 100;
+            size = 50;
         Pageable pageable = new PageRequest(page, size);
-        List<Rights> list = rightsRepo.findByIdChannel(id, pageable);
+        Page<Rights> list = rightsRepo.findByIdChannel(id, pageable);
         return list;
     }
 
     @Override
-    public List<Rights> SearchByIdGroup(Long id, int page, int size){
+    public Page<Rights> SearchByIdGroup(Long id, int page, int size){
         if(size<=0)
             size = 100;
         Pageable pageable = new PageRequest(page, size);
-        List<Rights> list = rightsRepo.findByIdGroup(id, pageable);
+        Page<Rights> list = rightsRepo.findByIdGroup(id, pageable);
         return list;
     }
 

+ 1 - 1
src/main/java/cn/efunbox/audio/repository/AudioRepo.java

@@ -28,7 +28,7 @@ public interface AudioRepo extends JpaRepository<Audio, Long> {
 
     List<Audio> findByNameContaining(String name);
 
-    List<Audio> findByIdGroup(Long idGroup, Pageable pageable);
+    Page<Audio> findByIdGroup(Long idGroup, Pageable pageable);
 
     List<Audio> findByAlbum( String Album);
 

+ 3 - 2
src/main/java/cn/efunbox/audio/repository/DeviceRepo.java

@@ -1,6 +1,7 @@
 package cn.efunbox.audio.repository;
 
 import cn.efunbox.audio.entity.Device;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
@@ -16,8 +17,8 @@ import java.util.List;
 public interface DeviceRepo extends JpaRepository<Device, Long> {
 
     Device findById(Long id);
-    List<Device> findByIdDevice(Long idDevice);
-    List<Device> findByIdChannel(Long idChannel, Pageable pageable);
+    Page<Device> findByIdDevice(Long idDevice, Pageable pageable);
+    Page<Device> findByIdChannel(Long idChannel, Pageable pageable);
 
     @Query("from Device d where d.idDevice=:idDevice")
     List<Device> findByDevice(@Param("idDevice")String idDevice);

+ 4 - 3
src/main/java/cn/efunbox/audio/repository/RecordRepo.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.repository;
 
 import cn.efunbox.audio.entity.Audio;
 import cn.efunbox.audio.entity.Record;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
@@ -18,10 +19,10 @@ public interface RecordRepo extends JpaRepository<Record, Long> {
 
     List<Record> findById(Long id);
 
-    List<Record> findByIdChannel(Long id, Pageable pageable);
+    Page<Record> findByIdChannel(Long id, Pageable pageable);
 
-    List<Record> findByIdDevice(Long id, Pageable pageable);
+    Page<Record> findByIdDevice(Long id, Pageable pageable);
 
-    List<Record> findByIdAudio(Long id, Pageable pageable);
+    Page<Record> findByIdAudio(Long id, Pageable pageable);
 
 }

+ 3 - 2
src/main/java/cn/efunbox/audio/repository/RightsRepo.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.repository;
 
 import cn.efunbox.audio.entity.Channel;
 import cn.efunbox.audio.entity.Rights;
+import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
@@ -15,8 +16,8 @@ import java.util.List;
 public interface RightsRepo extends JpaRepository<Rights, Long> {
 
     public List<Rights> findById(Long id);
-    public List<Rights> findByIdChannel(Long idChannel, Pageable pageable);
-    public List<Rights> findByIdGroup(Long idGroup, Pageable pageable);
+    public Page<Rights> findByIdChannel(Long idChannel, Pageable pageable);
+    public Page<Rights> findByIdGroup(Long idGroup, Pageable pageable);
     public List<Rights> findByIdChannelAndIdGroup(Long idChannel, Long idGroup);
     public List<Rights> findByNameChannel(String nameChannel);
     public List<Rights> findByNameGroup(String nameGroup);

+ 2 - 1
src/main/java/cn/efunbox/audio/service/AdminService.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Admin;
 import cn.efunbox.audio.entity.Channel;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -12,7 +13,7 @@ public interface AdminService {
 
     public Admin GetOne(Long id);
 
-    public List<Admin> SearchAll(int page, int size);
+    public Page<Admin> SearchAll(int page, int size);
 
     public List<Admin> SearchById(Long id);
 

+ 3 - 2
src/main/java/cn/efunbox/audio/service/AudioService.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Audio;
 import cn.efunbox.audio.entity.Device;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -12,9 +13,9 @@ public interface AudioService {
 
     public Audio GetOne(Long id);
 
-    public List<Audio> SearchAll(int page, int size);
+    public Page<Audio> SearchAll(int page, int size);
 
-    public List<Audio> SearchByIdGroup(Long idGroup, int page, int size);
+    public Page<Audio> SearchByIdGroup(Long idGroup, int page, int size);
 
     public List<Audio> SearchByName(String name);
 

+ 2 - 1
src/main/java/cn/efunbox/audio/service/ChannelService.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Audio;
 import cn.efunbox.audio.entity.Channel;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -12,7 +13,7 @@ public interface ChannelService {
 
     public Channel GetOne(Long id);
 
-    public List<Channel> SearchAll(int page, int size);
+    public Page<Channel> SearchAll(int page, int size);
 
     public List<Channel> SearchById(Long id);
 

+ 3 - 2
src/main/java/cn/efunbox/audio/service/DeviceService.java

@@ -1,6 +1,7 @@
 package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Device;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -17,9 +18,9 @@ public interface DeviceService {
 
     public Device GetOne(Long id);
 
-    public List<Device> Search(Long idChannel, Long idDevice, int page, int size);
+    public Page<Device> Search(Long idChannel, Long idDevice, int page, int size);
 
-    public List<Device> SearchAll(int page, int size);
+    public Page<Device> SearchAll(int page, int size);
 
     public Device Update(Device device);
 

+ 2 - 1
src/main/java/cn/efunbox/audio/service/GroupingService.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Channel;
 import cn.efunbox.audio.entity.Grouping;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -12,7 +13,7 @@ public interface GroupingService {
 
     public Grouping GetOne(Long id);
 
-    public List<Grouping> SearchAll(int page, int size);
+    public Page<Grouping> SearchAll(int page, int size);
 
     public List<Grouping> SearchById(Long id);
 

+ 5 - 4
src/main/java/cn/efunbox/audio/service/RecordService.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Audio;
 import cn.efunbox.audio.entity.Record;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -10,15 +11,15 @@ import java.util.List;
  */
 public interface RecordService {
 
-    public List<Record> SearchAll(int page, int size);
+    public Page<Record> SearchAll(int page, int size);
 
     public List<Record> SearchById(Long id);
 
-    public List<Record> SearchByIdChannel(Long id, int page, int size);
+    public Page<Record> SearchByIdChannel(Long id, int page, int size);
 
-    public List<Record> SearchByIdDevice(Long id, int page, int size);
+    public Page<Record> SearchByIdDevice(Long id, int page, int size);
 
-    public List<Record> SearchByIdAudio(Long id, int page, int size);
+    public Page<Record> SearchByIdAudio(Long id, int page, int size);
 
     public Record Insert(Record record);
 

+ 4 - 3
src/main/java/cn/efunbox/audio/service/RightsService.java

@@ -2,6 +2,7 @@ package cn.efunbox.audio.service;
 
 import cn.efunbox.audio.entity.Channel;
 import cn.efunbox.audio.entity.Rights;
+import org.springframework.data.domain.Page;
 
 import java.util.List;
 
@@ -12,13 +13,13 @@ public interface RightsService {
 
     public Rights GetOne(Long id);
 
-    public List<Rights> SearchAll(int page, int size);
+    public Page<Rights> SearchAll(int page, int size);
 
     public List<Rights> SearchById(Long id);
 
-    public List<Rights> SearchByIdChannel(Long id, int page, int size);
+    public Page<Rights> SearchByIdChannel(Long id, int page, int size);
 
-    public List<Rights> SearchByIdGroup(Long id, int page, int size);
+    public Page<Rights> SearchByIdGroup(Long id, int page, int size);
 
     public List<Rights> SearchByIdChannelAndIdGroup(Long idChannel, Long idGroup);