之前代码:
@GetMapping("checkContentList")
@ResponseBodyMessage
@ApiOperation(value = "获取列表信息")
public List<StRiskDigcheckContent> getList(@ApiParam(name = "filter", value = "过滤条件") @RequestParam(required = false) String filter,
@ApiParam(name = "sort", value = "排序") @RequestParam(required = false) String sort) {
List<StRiskDigcheck> listData = service.list(sort, filter);
if(listData.size()>0){
List<StRiskDigcheckContent> digchecks = listData.get(0).getDigchecks();
Collections.sort(digchecks,(s1,s2)->s1.getContentCode().compareTo(s2.getContentCode()));
return digchecks;
}else{
//这里换种方式 return Collections.EMPTY_LIST
**return null;**
}
}
Collections 类提供了空集合常量对象,如Collections.EMPTY_LIST ,Collections.EMPTY_SET, Collections.EMPTY_MAP ,大家可以把return null 换成 return Collections.EMPTY_LIST,更优雅