com.blade.mvc.annotation.PathParam Java Examples

The following examples show how to use com.blade.mvc.annotation.PathParam. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CategoryController.java    From tale with MIT License 6 votes vote down vote up
/**
 * 某个分类详情页分页
 */
@GetRoute(value = {"category/:keyword/:page", "category/:keyword/:page.html"})
public String categories(Request request, @PathParam String keyword,
                         @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    Metas metaDto = metasService.getMeta(Types.CATEGORY, keyword);
    if (null == metaDto) {
        return this.render_404();
    }

    Page<Contents> contentsPage = contentsService.getArticles(metaDto.getMid(), page, limit);
    request.attribute("articles", contentsPage);
    request.attribute("meta", metaDto);
    request.attribute("type", "分类");
    request.attribute("keyword", keyword);
    request.attribute("is_category", true);
    request.attribute("page_prefix", "/category/" + keyword);

    return this.render("page-category");
}
 
Example #2
Source File: CategoryController.java    From tale with MIT License 6 votes vote down vote up
/**
 * 标签下文章分页
 */
@GetRoute(value = {"tag/:name/:page", "tag/:name/:page.html"})
public String tags(Request request, @PathParam String name, @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    Metas metaDto = metasService.getMeta(Types.TAG, name);
    if (null == metaDto) {
        return this.render_404();
    }

    Page<Contents> contentsPage = contentsService.getArticles(metaDto.getMid(), page, limit);
    request.attribute("articles", contentsPage);
    request.attribute("meta", metaDto);
    request.attribute("type", "标签");
    request.attribute("keyword", name);
    request.attribute("is_tag", true);
    request.attribute("page_prefix", "/tag/" + name);

    return this.render("page-category");
}
 
Example #3
Source File: IndexController.java    From tale with MIT License 6 votes vote down vote up
/**
 * 自定义页面
 */
@CsrfToken(newToken = true)
@GetRoute(value = {"/:cid", "/:cid.html"})
public String page(@PathParam String cid, Request request) {
    Optional<Contents> contentsOptional = contentsService.getContents(cid);
    if (!contentsOptional.isPresent()) {
        return this.render_404();
    }
    Contents contents = contentsOptional.get();
    if (contents.getAllowComment()) {
        int cp = request.queryInt("cp", 1);
        request.attribute("cp", cp);
    }
    request.attribute("article", contents);
    Contents temp = new Contents();
    temp.setHits(contents.getHits() + 1);
    temp.update(contents.getCid());
    if (Types.ARTICLE.equals(contents.getType())) {
        return this.render("post");
    }
    if (Types.PAGE.equals(contents.getType())) {
        return this.render("page");
    }
    return this.render_404();
}
 
Example #4
Source File: IndexController.java    From tale with MIT License 6 votes vote down vote up
/**
 * 文章页
 */
@CsrfToken(newToken = true)
@GetRoute(value = {"article/:cid", "article/:cid.html"})
public String post(Request request, @PathParam String cid) {
    Optional<Contents> contentsOptional = contentsService.getContents(cid);
    if (!contentsOptional.isPresent()) {
        return this.render_404();
    }
    Contents contents = contentsOptional.get();
    if (Types.DRAFT.equals(contents.getStatus())) {
        return this.render_404();
    }
    request.attribute("article", contents);
    request.attribute("is_post", true);
    if (contents.getAllowComment()) {
        int cp = request.queryInt("cp", 1);
        request.attribute("cp", cp);
    }
    Contents temp = new Contents();
    temp.setHits(contents.getHits() + 1);
    temp.update(contents.getCid());
    return this.render("post");
}
 
Example #5
Source File: IndexController.java    From tale with MIT License 5 votes vote down vote up
/**
 * 首页分页
 *
 * @param request
 * @param page
 * @param limit
 * @return
 */
@GetRoute(value = {"page/:page", "page/:page.html"})
public String index(Request request, @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    if (page > 1) {
        this.title(request, "第" + page + "页");
    }
    request.attribute("page_num", page);
    request.attribute("limit", limit);
    request.attribute("is_home", true);
    request.attribute("page_prefix", "/page");
    return this.render("index");
}
 
Example #6
Source File: IndexController.java    From tale with MIT License 5 votes vote down vote up
@GetRoute(value = {"search/:keyword/:page", "search/:keyword/:page.html"})
public String search(Request request, @PathParam String keyword, @PathParam int page, @Param(defaultValue = "12") int limit) {

    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;

    Page<Contents> articles = new Contents().where("type", Types.ARTICLE).and("status", Types.PUBLISH)
            .like("title", "%" + keyword + "%").page(page, limit, "created desc");

    request.attribute("articles", articles);

    request.attribute("type", "搜索");
    request.attribute("keyword", keyword);
    request.attribute("page_prefix", "/search/" + keyword);
    return this.render("page-category");
}
 
Example #7
Source File: CategoryController.java    From tale with MIT License 4 votes vote down vote up
/**
 * 某个分类详情页
 */
@GetRoute(value = {"category/:keyword", "category/:keyword.html"})
public String categories(Request request, @PathParam String keyword, @Param(defaultValue = "12") int limit) {
    return this.categories(request, keyword, 1, limit);
}
 
Example #8
Source File: ParameterInjectionExampleController.java    From tutorials with MIT License 4 votes vote down vote up
@GetRoute("/params/path/:uid")
public void restfulParam(@PathParam Integer uid, Response response) {
    log.info("uid: " + uid);
    response.text(String.valueOf(uid));
}
 
Example #9
Source File: CategoryController.java    From tale with MIT License 2 votes vote down vote up
/**
 * 标签详情页
 *
 * @param name 标签名
 */
@GetRoute(value = {"tag/:name", "tag/:name.html"})
public String tagPage(Request request, @PathParam String name, @Param(defaultValue = "12") int limit) {
    return this.tags(request, name, 1, limit);
}
 
Example #10
Source File: IndexController.java    From tale with MIT License 2 votes vote down vote up
/**
 * 搜索页
 *
 * @param keyword
 * @return
 */
@GetRoute(value = {"search/:keyword", "search/:keyword.html"})
public String search(Request request, @PathParam String keyword, @Param(defaultValue = "12") int limit) {
    return this.search(request, keyword, 1, limit);
}
 
Example #11
Source File: IndexController.java    From blade with Apache License 2.0 2 votes vote down vote up
public void findUser(@PathParam Long uid) {

    }