use of com.topcom.cms.domain.User 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.domain.User 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.domain.User in project topcom-cloud by 545314690.
the class UserController method updateState.
/**
* 改变用户状态
*/
@RequestMapping(value = { "/updateState/{id}" }, method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public boolean updateState(@PathVariable Long id, @RequestParam User.State state) throws BusinessException {
User user = userManager.findById(id);
if (user == null) {
throw new BusinessException("用户不存在");
}
int i = userManager.updateState(id, state);
return i > 0;
}
use of com.topcom.cms.domain.User 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());
}
}
}
use of com.topcom.cms.domain.User in project topcom-cloud by 545314690.
the class LoginInterceptor method logined.
/**
* 判断用户是否已登录
*
* @param request
* @return
*/
private boolean logined(HttpServletRequest request) throws AuthenticationException {
boolean result = false;
User loginUser = SubjectUtil.getCurrentUser(request);
if (null != loginUser) {
result = true;
}
return result;
}
Aggregations