Search in sources :

Example 16 with User

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);
}
Also used : Group(com.topcom.cms.domain.Group) CurrentUser(com.topcom.cms.web.bind.annotation.CurrentUser) User(com.topcom.cms.domain.User) SearchWord(com.topcom.cms.domain.SearchWord) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 17 with User

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;
}
Also used : CurrentUser(com.topcom.cms.web.bind.annotation.CurrentUser) User(com.topcom.cms.domain.User) PublicResource(com.topcom.cms.perm.annotation.PublicResource) Resource(com.topcom.cms.domain.Resource) ApiOperation(io.swagger.annotations.ApiOperation)

Example 18 with User

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;
}
Also used : BusinessException(com.topcom.cms.exception.BusinessException) CurrentUser(com.topcom.cms.web.bind.annotation.CurrentUser) User(com.topcom.cms.domain.User)

Example 19 with User

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());
        }
    }
}
Also used : CurrentUser(com.topcom.cms.web.bind.annotation.CurrentUser) User(com.topcom.cms.domain.User) ViewLogDto(com.topcom.cms.vo.ViewLogDto) Resource(com.topcom.cms.domain.Resource) ArrayList(java.util.ArrayList) ViewLogRequest(com.topcom.cms.vo.ViewLogRequest) ApiOperation(io.swagger.annotations.ApiOperation)

Example 20 with User

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;
}
Also used : User(com.topcom.cms.domain.User)

Aggregations

User (com.topcom.cms.domain.User)24 CurrentUser (com.topcom.cms.web.bind.annotation.CurrentUser)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 PageRequest (org.springframework.data.domain.PageRequest)4 Pageable (org.springframework.data.domain.Pageable)4 Group (com.topcom.cms.domain.Group)3 Resource (com.topcom.cms.domain.Resource)3 ApiOperation (io.swagger.annotations.ApiOperation)3 JSONObject (net.sf.json.JSONObject)3 WeChat (com.topcom.cms.data.domain.WeChat)2 BusinessException (com.topcom.cms.exception.BusinessException)2 AuthenticationException (com.topcom.cms.perm.exception.AuthenticationException)2 UsernamePasswordToken (com.topcom.cms.perm.token.UsernamePasswordToken)2 UserManager (com.topcom.cms.service.UserManager)2 com.topcom.cms.yuqing.domain (com.topcom.cms.yuqing.domain)2 CustomSubjectManager (com.topcom.cms.yuqing.service.CustomSubjectManager)2 SubscriptionFollowerManager (com.topcom.cms.yuqing.service.SubscriptionFollowerManager)2 WarningLogManager (com.topcom.cms.yuqing.service.WarningLogManager)2 WarningManager (com.topcom.cms.yuqing.service.WarningManager)2