Java Code Examples for com.blade.mvc.http.HttpMethod#GET

The following examples show how to use com.blade.mvc.http.HttpMethod#GET . 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: IndexController.java    From tale with MIT License 6 votes vote down vote up
/**
 * 仪表盘
 */
@Route(value = {"/", "index"}, method = HttpMethod.GET)
public String index(Request request) {
    List<Comments> comments   = siteService.recentComments(5);
    List<Contents> contents   = siteService.getContens(Types.RECENT_ARTICLE, 5);
    Statistics     statistics = siteService.getStatistics();
    // 取最新的20条日志
    Page<Logs> logsPage = new Logs().page(1, 20, "id desc");
    List<Logs> logs     = logsPage.getRows();

    request.attribute("comments", comments);
    request.attribute("articles", contents);
    request.attribute("statistics", statistics);
    request.attribute("logs", logs);
    return "admin/index";
}
 
Example 2
Source File: IndexController.java    From tale with MIT License 6 votes vote down vote up
/**
 * 重启系统
 *
 * @param sleep
 * @return
 */
@Route(value = "reload", method = HttpMethod.GET)
public void reload(@Param(defaultValue = "0") int sleep, Request request) {
    if (sleep < 0 || sleep > 999) {
        sleep = 10;
    }
    try {
        // sh tale.sh reload 10
        String webHome = new File(AttachController.CLASSPATH).getParent();
        String cmd     = "sh " + webHome + "/bin tale.sh reload " + sleep;
        log.info("execute shell: {}", cmd);
        ShellUtils.shell(cmd);
        new Logs(LogActions.RELOAD_SYS, "", request.address(), this.getUid()).save();
        TimeUnit.SECONDS.sleep(sleep);
    } catch (Exception e) {
        log.error("重启系统失败", e);
    }
}
 
Example 3
Source File: RouteStruct.java    From blade with Apache License 2.0 6 votes vote down vote up
public HttpMethod getMethod() {
    if (null != mapping) {
        return mapping.method();
    }
    if (null != getRoute) {
        return HttpMethod.GET;
    }
    if (null != postRoute) {
        return HttpMethod.POST;
    }
    if (null != putRoute) {
        return HttpMethod.PUT;
    }
    if (null != deleteRoute) {
        return HttpMethod.DELETE;
    }
    return HttpMethod.ALL;
}
 
Example 4
Source File: PageController.java    From tale with MIT License 5 votes vote down vote up
@Route(value = "/:cid", method = HttpMethod.GET)
public String editPage(@PathParam String cid, Request request) {
    Optional<Contents> contents = contentsService.getContents(cid);
    if (!contents.isPresent()) {
        return render_404();
    }
    request.attribute("contents", contents.get());
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/page_edit";
}
 
Example 5
Source File: AuthController.java    From tale with MIT License 5 votes vote down vote up
@Route(value = "login", method = HttpMethod.GET)
public String login(Response response) {
    if (null != this.user()) {
        response.redirect("/admin/index");
        return null;
    }
    return "admin/login";
}
 
Example 6
Source File: TemplateController.java    From tale with MIT License 5 votes vote down vote up
@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    String themePath = Const.CLASSPATH + File.separatorChar + "templates" + File.separatorChar + "themes" + File.separatorChar + Commons.site_theme();
    try {
        List<String> files = Files.list(Paths.get(themePath))
                .map(path -> path.getFileName().toString())
                .filter(path -> path.endsWith(".html"))
                .collect(Collectors.toList());

        List<String> partial = Files.list(Paths.get(themePath + File.separatorChar + "partial"))
                .map(path -> path.getFileName().toString())
                .filter(path -> path.endsWith(".html"))
                .map(fileName -> "partial/" + fileName)
                .collect(Collectors.toList());

        List<String> statics = Files.list(Paths.get(themePath + File.separatorChar + "static"))
                .map(path -> path.getFileName().toString())
                .filter(path -> path.endsWith(".js") || path.endsWith(".css"))
                .map(fileName -> "static/" + fileName)
                .collect(Collectors.toList());

        files.addAll(partial);
        files.addAll(statics);

        request.attribute("tpls", files);
    } catch (IOException e) {
        log.error("找不到模板路径");
    }
    return "admin/tpl_list";
}
 
Example 7
Source File: CategoryController.java    From tale with MIT License 5 votes vote down vote up
@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    List<Metas>   categories = siteService.getMetas(Types.RECENT_META, Types.CATEGORY, TaleConst.MAX_POSTS);
    List<Metas> tags       = siteService.getMetas(Types.RECENT_META, Types.TAG, TaleConst.MAX_POSTS);
    request.attribute("categories", categories);
    request.attribute("tags", tags);
    return "admin/category";
}
 
Example 8
Source File: AttachController.java    From tale with MIT License 5 votes vote down vote up
/**
 * 附件页面
 *
 * @param request
 * @param page
 * @param limit
 * @return
 */
@Route(value = "", method = HttpMethod.GET)
public String index(Request request, @Param(defaultValue = "1") int page,
                    @Param(defaultValue = "12") int limit) {

    Attach       attach     = new Attach();
    Page<Attach> attachPage = attach.page(page, limit);
    request.attribute("attachs", attachPage);
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    request.attribute("max_file_size", TaleConst.MAX_FILE_SIZE / 1024);
    return "admin/attach";
}
 
Example 9
Source File: IndexController.java    From tale with MIT License 5 votes vote down vote up
/**
 * 系统设置
 */
@Route(value = "setting", method = HttpMethod.GET)
public String setting(Request request) {
    Map<String, String> options = optionsService.getOptions();
    request.attribute("options", options);
    return "admin/setting";
}
 
Example 10
Source File: InstallController.java    From tale with MIT License 5 votes vote down vote up
/**
 * 安装页
 *
 * @return
 */
@Route(value = "/", method = HttpMethod.GET)
public String index(Request request) {
    boolean existInstall = Files.exists(Paths.get(AttachController.CLASSPATH + "install.lock"));
    int allow_reinstall = TaleConst.OPTIONS.getInt("allow_install", 0);

    if (allow_reinstall == 1) {
        request.attribute("is_install", false);
    } else {
        request.attribute("is_install", existInstall);
    }
    return "install";
}
 
Example 11
Source File: PageController.java    From tale with MIT License 4 votes vote down vote up
@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    Page<Contents> contentsPage = new Contents().where("type", Types.PAGE).page(1, TaleConst.MAX_POSTS, "created desc");
    request.attribute("articles", contentsPage);
    return "admin/page_list";
}
 
Example 12
Source File: PageController.java    From tale with MIT License 4 votes vote down vote up
@Route(value = "new", method = HttpMethod.GET)
public String newPage(Request request) {
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/page_edit";
}
 
Example 13
Source File: IndexController.java    From tale with MIT License 4 votes vote down vote up
/**
 * 个人设置页面
 */
@Route(value = "profile", method = HttpMethod.GET)
public String profile() {
    return "admin/profile";
}
 
Example 14
Source File: RouteTest.java    From blade with Apache License 2.0 4 votes vote down vote up
@Test
public void testBuildRoute() {
    route.toString();
    Route route2 = new Route(HttpMethod.GET, "/", null, null);
    assertNotEquals(route, route2);
}
 
Example 15
Source File: RouteExampleController.java    From tutorials with MIT License 4 votes vote down vote up
@Route(value = "/another-route-example", method = HttpMethod.GET)
public String anotherGet() {
    return "get.html";
}