Search in sources :

Example 1 with PostsPageQueryParam

use of com.codingmore.dto.PostsPageQueryParam in project coding-more by itwanger.

the class IndexPageRequestStrategy method handleRequest.

@Override
public String handleRequest(WebRequestParam webRequestParam) {
    List<Site> siteList = siteService.list();
    // 处理站点配置
    if (siteList.size() > 0) {
        Site site = siteList.get(0);
        SiteVo siteVo = new SiteVo();
        BeanUtils.copyProperties(site, siteVo);
        webRequestParam.getRequest().setAttribute(SITE_CONFIG, siteVo);
    }
    PostsPageQueryParam pageQueryParam = new PostsPageQueryParam();
    pageQueryParam.setPage(webRequestParam.getPage());
    pageQueryParam.setAsc(webRequestParam.isAsc());
    pageQueryParam.setOrderBy(webRequestParam.getOrderBy());
    /* pageQueryParam.setOrderBy("post_date"); */
    pageQueryParam.setPageSize(webRequestParam.getPageSize());
    pageQueryParam.setPostStatus(PostStatus.PUBLISHED.toString());
    pageQueryParam.setTermTaxonomyId(webRequestParam.getChannelId());
    // IPage<PostsVo> pageVo = postsService.findByPageWithTag(pageQueryParam);
    List<PostsVo> pageVoList = postsService.findByPageWithTagPaged(pageQueryParam);
    // 设置浏览量
    pageVoList.forEach(postsVo -> {
        postsVo.setLikeCount(Long.parseLong(String.valueOf(postsService.getLikeCount(postsVo.getPostsId()))));
    });
    webRequestParam.getRequest().setAttribute(POSTS_ITEMS, pageVoList);
    // webRequestParam.getRequest().setAttribute(POSTS_TOTAL,pageVo.getTotal());
    return INDEX_PAGE;
}
Also used : Site(com.codingmore.model.Site) SiteVo(com.codingmore.vo.SiteVo) PostsPageQueryParam(com.codingmore.dto.PostsPageQueryParam) PostsVo(com.codingmore.vo.PostsVo)

Aggregations

PostsPageQueryParam (com.codingmore.dto.PostsPageQueryParam)1 Site (com.codingmore.model.Site)1 PostsVo (com.codingmore.vo.PostsVo)1 SiteVo (com.codingmore.vo.SiteVo)1