Search in sources :

Example 1 with Group

use of com.topcom.cms.domain.Group in project topcom-cloud by 545314690.

the class GroupManagerImpl method findGroupById.

@Override
@Cacheable(value = "groupCache", key = "#id + 'getGroupListById'")
public // 将缓存保存进groupCache,并使用参数中的id加上一个字符串(这里使用方法名称)作为缓存的key
Group findGroupById(Long id) {
    Group g = groupDao.findTreeGroupById(id);
    findAllChildren(g);
    return g;
}
Also used : Group(com.topcom.cms.domain.Group) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with Group

use of com.topcom.cms.domain.Group in project topcom-cloud by 545314690.

the class SearchWordController method findByType.

/**
 * 热词查询 查询排名前 limit 的word
 * @return
 */
@RequestMapping(method = RequestMethod.GET, value = "/findByType", produces = "application/json")
@ResponseBody
public List<SearchWord> findByType(@CurrentUser User user, @ApiParam("limit") @RequestParam(required = true) Integer limit, @ApiParam("type") @RequestParam(required = true) Integer type) {
    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.findByTypeAndGroupIdIn(page, type, 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 3 with Group

use of com.topcom.cms.domain.Group in project topcom-cloud by 545314690.

the class GroupManagerImpl method findAllChildren.

private void findAllChildren(Group g) {
    List<Group> list = groupDao.findChildrenByParentId(g.getId());
    if (list != null && list.size() != 0) {
        g.setChildren(list);
        g.setLeaf(false);
    }
    for (Group group : list) {
        findAllChildren(group);
    }
}
Also used : Group(com.topcom.cms.domain.Group)

Example 4 with Group

use of com.topcom.cms.domain.Group in project topcom-cloud by 545314690.

the class SearchWordController method addClickCount.

/**
 * 增加点击次数 对于单个搜索词 可以支持累加
 * @return
 */
@RequestMapping(method = RequestMethod.GET, value = "/add", produces = "application/json")
@ResponseBody
public SearchWord addClickCount(@CurrentUser User user, @ApiParam("Word") @RequestParam(required = true) String word, @ApiParam("type") @RequestParam(required = true) Integer type) {
    User user1 = this.userManager.findById(user.getId());
    Set<Group> groups = user1.getGroups();
    return searchWordManager.addClickCount(groups, word, type);
}
Also used : Group(com.topcom.cms.domain.Group) CurrentUser(com.topcom.cms.web.bind.annotation.CurrentUser) User(com.topcom.cms.domain.User) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with Group

use of com.topcom.cms.domain.Group 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)

Aggregations

Group (com.topcom.cms.domain.Group)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 User (com.topcom.cms.domain.User)3 CurrentUser (com.topcom.cms.web.bind.annotation.CurrentUser)3 UserStyle (com.topcom.cms.yuqing.domain.UserStyle)3 ApiOperation (io.swagger.annotations.ApiOperation)3 SearchWord (com.topcom.cms.domain.SearchWord)2 PageRequest (org.springframework.data.domain.PageRequest)2 Pageable (org.springframework.data.domain.Pageable)2 Sort (org.springframework.data.domain.Sort)2 AggPageImpl (com.topcom.cms.es.vo.AggPageImpl)1 GroupStyle (com.topcom.cms.yuqing.vo.request.GroupStyle)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 Page (org.springframework.data.domain.Page)1