use of com.topcom.cms.web.bind.annotation.CurrentUser in project topcom-cloud by 545314690.
the class SearchWordController method findByWord.
@RequestMapping(method = RequestMethod.GET, value = "/findByWord", produces = "application/json")
@ResponseBody
public List<SearchWord> findByWord(@CurrentUser User user, @ApiParam("limit") @RequestParam(required = true) Integer limit, @ApiParam("word") @RequestParam(required = true) String word) {
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "wordCount"));
Pageable page = new PageRequest(0, limit, sort);
User user1 = this.userManager.findById(user.getId());
Set<Group> groups = user1.getGroups();
String groupId = SearchWord.groupIdBySet(groups);
List<String> groupIdList = new ArrayList<>();
groupIdList.add(groupId);
if (groupId.indexOf(",") != -1) {
String[] split = groupId.split(",");
for (String s : split) {
groupIdList.add(s);
}
}
Page<SearchWord> searchWords = this.searchWordManager.findByWordAndGroupIdIn(page, word, groupIdList);
return filterNull(searchWords);
}
use of com.topcom.cms.web.bind.annotation.CurrentUser in project topcom-cloud by 545314690.
the class UserController method resource.
/**
* 返回登录用户的resource
*/
@ApiOperation("获取resource")
@RequestMapping(value = { "resource" }, method = { RequestMethod.GET })
@ResponseBody
public Set<Resource> resource(@CurrentUser User user) {
// 缓存user懒加载,没有resource,需要在数据库查询
User user1 = this.manager.findById(user.getId());
// user.getPermissionNames();
Set<Resource> resourceSet = user1.getResource();
if (resourceSet == null || resourceSet.size() == 0) {
return null;
}
for (Resource resource : resourceSet) {
resource.sortByChildId();
}
return resourceSet;
}
use of com.topcom.cms.web.bind.annotation.CurrentUser 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