Search in sources :

Example 1 with BlogSortRule

use of com.duan.blogos.common.BlogSortRule in project BlogSystem by DuanJiaNing.

the class BlogController method list.

/**
 * 检索指定博主的博文列表
 */
@RequestMapping(method = RequestMethod.GET)
public ResultBean<List<BlogListItemDTO>> list(HttpServletRequest request, @RequestParam("bloggerId") Integer bloggerId, @RequestParam(value = "cids", required = false) String categoryIds, @RequestParam(value = "lids", required = false) String labelIds, @RequestParam(value = "kword", required = false) String keyWord, @RequestParam(value = "offset", required = false) Integer offset, @RequestParam(value = "rows", required = false) Integer rows, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "order", required = false) String order) {
    handleAccountCheck(request, bloggerId);
    // 检查数据合法性
    String sor = StringUtils.isEmpty_(sort) ? Rule.VIEW_COUNT.name() : sort.toUpperCase();
    String ord = StringUtils.isEmpty_(order) ? Order.DESC.name() : order.toUpperCase();
    handleSortRuleCheck(request, sor, ord);
    String ch = websiteProperties.getUrlConditionSplitCharacter();
    int[] cids = StringUtils.intStringDistinctToArray(categoryIds, ch);
    int[] lids = StringUtils.intStringDistinctToArray(labelIds, ch);
    // 检查博文类别和标签
    handleCategoryAndLabelCheck(request, bloggerId, cids, lids);
    // 执行数据查询
    BlogSortRule rule = new BlogSortRule(Rule.valueOf(sor), Order.valueOf(ord));
    int os = offset == null || offset < 0 ? 0 : offset;
    int rs = rows == null || rows < 0 ? audienceProperties.getRequestBloggerBlogListCount() : rows;
    ResultBean<List<BlogListItemDTO>> listResultBean = retrievalService.listFilterAll(cids, lids, keyWord, bloggerId, os, rs, rule, BlogStatusEnum.PUBLIC);
    if (listResultBean == null)
        handlerEmptyResult(request);
    return listResultBean;
}
Also used : List(java.util.List) BlogSortRule(com.duan.blogos.common.BlogSortRule)

Example 2 with BlogSortRule

use of com.duan.blogos.common.BlogSortRule in project BlogSystem by DuanJiaNing.

the class BloggerBlogController method list.

/**
 * 检索博文
 */
@RequestMapping(method = RequestMethod.GET)
public ResultBean<List<BlogListItemDTO>> list(HttpServletRequest request, @PathVariable Integer bloggerId, @RequestParam(value = "cids", required = false) String categoryIds, @RequestParam(value = "lids", required = false) String labelIds, @RequestParam(value = "kword", required = false) String keyWord, @RequestParam(value = "offset", required = false) Integer offset, @RequestParam(value = "rows", required = false) Integer rows, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "order", required = false) String order, @RequestParam(value = "status", required = false) Integer status) {
    handleBloggerSignInCheck(request, bloggerId);
    // 检查排序规则
    String sor = sort == null ? Rule.VIEW_COUNT.name() : sort.toUpperCase();
    String ord = order == null ? Order.DESC.name() : order.toUpperCase();
    handleSortRuleCheck(request, sor, ord);
    String sp = websiteProperties.getUrlConditionSplitCharacter();
    int[] cids = StringUtils.intStringDistinctToArray(categoryIds, sp);
    int[] lids = StringUtils.intStringDistinctToArray(labelIds, sp);
    // 检查博文类别和标签
    handleCategoryAndLabelCheck(request, bloggerId, cids, lids);
    BlogStatusEnum stat = null;
    if (status != null)
        stat = BlogStatusEnum.valueOf(status);
    // status传参错误
    if (stat == null)
        stat = BlogStatusEnum.PUBLIC;
    // 执行数据查询
    BlogSortRule rule = new BlogSortRule(Rule.valueOf(sor), Order.valueOf(ord));
    int os = offset == null || offset < 0 ? 0 : offset;
    int rs = rows == null || rows < 0 ? bloggerProperties.getRequestBlogListCount() : rows;
    ResultBean<List<BlogListItemDTO>> listResultBean = bloggerBlogService.listFilterAll(cids, lids, keyWord, bloggerId, os, rs, rule, stat);
    if (listResultBean == null)
        handlerEmptyResult(request);
    return listResultBean;
}
Also used : BlogStatusEnum(com.duan.blogos.enums.BlogStatusEnum) List(java.util.List) BlogSortRule(com.duan.blogos.common.BlogSortRule)

Aggregations

BlogSortRule (com.duan.blogos.common.BlogSortRule)2 List (java.util.List)2 BlogStatusEnum (com.duan.blogos.enums.BlogStatusEnum)1