use of com.topcom.cms.domain.Resource in project topcom-cloud by 545314690.
the class ViewLogController method topByUser.
@ApiOperation("访问量前limit名的资源")
@RequestMapping(value = { "/topByUser" }, method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<ViewLogDto> topByUser(@CurrentUser User user, @RequestParam(required = false) Integer limit) {
if (limit == null || limit == 0) {
limit = 20;
}
// 缓存user懒加载,没有resource,需要在数据库查询
User user1 = this.userManager.findById(user.getId());
// user.getPermissionNames();
Set<Resource> resourceSet = user1.getResource();
if (resourceSet == null) {
return null;
} else {
ViewLogRequest request = new ViewLogRequest();
request.setLimit(limit);
List<Long> resourceIds = new ArrayList<>();
for (Resource r : resourceSet) {
resourceIds.add(r.getId());
}
request.setResourceIds(resourceIds);
List<ViewLogDto> viewLogDtoList = this.viewLogManager.searchHotPage(request);
if (viewLogDtoList.size() < limit) {
return viewLogDtoList;
} else {
return viewLogDtoList.subList(0, request.getLimit());
}
}
}
Aggregations