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