com.blade.mvc.annotation.Param Java Examples
The following examples show how to use
com.blade.mvc.annotation.Param.
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 |
@Route(value = "delete") @JSON public RestResponse delete(@Param int mid) { try { metasService.delete(mid); siteService.cleanCache(Types.C_STATISTICS); } catch (Exception e) { String msg = "删除失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } return RestResponse.ok(); }
Example #2
Source File: CategoryController.java From tale with MIT License | 6 votes |
/** * 标签下文章分页 */ @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: CategoryController.java From tale with MIT License | 6 votes |
/** * 某个分类详情页分页 */ @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 #4
Source File: IndexController.java From tale with MIT License | 6 votes |
/** * 重启系统 * * @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 #5
Source File: IndexController.java From tale with MIT License | 6 votes |
/** * 系统备份 * * @return */ @Route(value = "backup", method = HttpMethod.POST) @JSON public RestResponse backup(@Param String bk_type, @Param String bk_path, Request request) { if (StringKit.isBlank(bk_type)) { return RestResponse.fail("请确认信息输入完整"); } try { BackResponse backResponse = siteService.backup(bk_type, bk_path, "yyyyMMddHHmm"); new Logs(LogActions.SYS_BACKUP, null, request.address(), this.getUid()).save(); return RestResponse.ok(backResponse); } catch (Exception e) { String msg = "备份失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } }
Example #6
Source File: IndexController.java From tale with MIT License | 6 votes |
/** * 保存系统设置 */ @Route(value = "setting", method = HttpMethod.POST) @JSON public RestResponse saveSetting(@Param String site_theme, Request request) { try { Map<String, List<String>> querys = request.parameters(); optionsService.saveOptions(querys); Environment config = Environment.of(optionsService.getOptions()); TaleConst.OPTIONS = config; new Logs(LogActions.SYS_SETTING, JsonKit.toString(querys), request.address(), this.getUid()).save(); return RestResponse.ok(); } catch (Exception e) { String msg = "保存设置失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } }
Example #7
Source File: CategoryController.java From tale with MIT License | 6 votes |
@Route(value = "save", method = HttpMethod.POST) @JSON public RestResponse saveCategory(@Param String cname, @Param Integer mid) { try { metasService.saveMeta(Types.CATEGORY, cname, mid); siteService.cleanCache(Types.C_STATISTICS); } catch (Exception e) { String msg = "分类保存失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } return RestResponse.ok(); }
Example #8
Source File: IndexController.java From tale with MIT License | 5 votes |
/** * 修改密码 */ @Route(value = "password", method = HttpMethod.POST) @JSON public RestResponse upPwd(@Param String old_password, @Param String password, Request request) { Users users = this.user(); if (StringKit.isBlank(old_password) || StringKit.isBlank(password)) { return RestResponse.fail("请确认信息输入完整"); } if (!users.getPassword().equals(EncryptKit.md5(users.getUsername() + old_password))) { return RestResponse.fail("旧密码错误"); } if (password.length() < 6 || password.length() > 14) { return RestResponse.fail("请输入6-14位密码"); } try { Users temp = new Users(); String pwd = EncryptKit.md5(users.getUsername() + password); temp.setPassword(pwd); temp.update(users.getUid()); new Logs(LogActions.UP_PWD, null, request.address(), this.getUid()).save(); return RestResponse.ok(); } catch (Exception e) { String msg = "密码修改失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } }
Example #9
Source File: IndexController.java From tale with MIT License | 5 votes |
/** * 保存个人信息 */ @Route(value = "profile", method = HttpMethod.POST) @JSON public RestResponse saveProfile(@Param String screen_name, @Param String email, Request request) { Users users = this.user(); if (StringKit.isNotBlank(screen_name) && StringKit.isNotBlank(email)) { Users temp = new Users(); temp.setScreen_name(screen_name); temp.setEmail(email); temp.update(users.getUid()); new Logs(LogActions.UP_INFO, JsonKit.toString(temp), request.address(), this.getUid()).save(); } return RestResponse.ok(); }
Example #10
Source File: AttachController.java From tale with MIT License | 5 votes |
@Route(value = "delete") @JSON public RestResponse delete(@Param Integer id, Request request) { try { Attach attach = new Attach().find(id); if (null == attach) { return RestResponse.fail("不存在该附件"); } String fkey = attach.getFkey(); siteService.cleanCache(Types.C_STATISTICS); String filePath = CLASSPATH.substring(0, CLASSPATH.length() - 1) + fkey; java.nio.file.Path path = Paths.get(filePath); log.info("Delete attach: [{}]", filePath); if (Files.exists(path)) { Files.delete(path); } attach.delete(id); new Logs(LogActions.DEL_ATTACH, fkey, request.address(), this.getUid()).save(); } catch (Exception e) { String msg = "附件删除失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } return RestResponse.ok(); }
Example #11
Source File: AttachController.java From tale with MIT License | 5 votes |
/** * 附件页面 * * @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 #12
Source File: IndexController.java From tale with MIT License | 5 votes |
@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 #13
Source File: IndexController.java From tale with MIT License | 5 votes |
/** * 首页分页 * * @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 #14
Source File: ParameterInjectionExampleController.java From tutorials with MIT License | 4 votes |
@PostRoute("/params/vo") public void voParam(@Param User user, Response response) { log.info("user as voParam: " + user.toString()); response.html(user.toString() + "<br/><br/><a href='/'>Back</a>"); }
Example #15
Source File: ParameterInjectionExampleController.java From tutorials with MIT License | 4 votes |
@GetRoute("/params/form") public void formParam(@Param String name, Response response) { log.info("name: " + name); response.text(name); }
Example #16
Source File: InstallController.java From tale with MIT License | 4 votes |
@Route(value = "/", method = HttpMethod.POST) @JSON public RestResponse doInstall(@Param String site_title, @Param String site_url, @Param String admin_user, @Param String admin_email, @Param String admin_pwd) { if (Files.exists(Paths.get(AttachController.CLASSPATH + "install.lock")) && TaleConst.OPTIONS.getInt("allow_install", 0) != 1) { return RestResponse.fail("请勿重复安装"); } try { if (StringKit.isBlank(site_title) || StringKit.isBlank(site_url) || StringKit.isBlank(admin_user) || StringKit.isBlank(admin_pwd)) { return RestResponse.fail("请确认网站信息输入完整"); } if (admin_pwd.length() < 6 || admin_pwd.length() > 14) { return RestResponse.fail("请输入6-14位密码"); } if (StringKit.isNotBlank(admin_email) && !TaleUtils.isEmail(admin_email)) { return RestResponse.fail("邮箱格式不正确"); } Users temp = new Users(); temp.setUsername(admin_user); temp.setPassword(admin_pwd); temp.setEmail(admin_email); siteService.initSite(temp); if (site_url.endsWith("/")) { site_url = site_url.substring(0, site_url.length() - 1); } if (!site_url.startsWith("http")) { site_url = "http://".concat(site_url); } optionsService.saveOption("site_title", site_title); optionsService.saveOption("site_url", site_url); TaleConst.OPTIONS = Environment.of(optionsService.getOptions()); } catch (Exception e) { String msg = "安装失败"; if (e instanceof TipException) { msg = e.getMessage(); } else { log.error(msg, e); } return RestResponse.fail(msg); } return RestResponse.ok(); }
Example #17
Source File: IndexController.java From tale with MIT License | 4 votes |
@GetRoute(value = {"search", "search.html"}) public String search(Request request, @Param(defaultValue = "12") int limit) { String keyword = request.query("s").orElse(""); return this.search(request, keyword, 1, limit); }
Example #18
Source File: CategoryController.java From tale with MIT License | 4 votes |
/** * 某个分类详情页 */ @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 #19
Source File: IndexController.java From tale with MIT License | 4 votes |
/** * 保存高级选项设置 * * @return */ @Route(value = "advanced", method = HttpMethod.POST) @JSON public RestResponse doAdvanced(@Param String cache_key, @Param String block_ips, @Param String plugin_name, @Param String rewrite_url, @Param String allow_install) { // 清除缓存 if (StringKit.isNotBlank(cache_key)) { if ("*".equals(cache_key)) { cache.clean(); } else { cache.del(cache_key); } } // 要过过滤的黑名单列表 if (StringKit.isNotBlank(block_ips)) { optionsService.saveOption(Types.BLOCK_IPS, block_ips); TaleConst.BLOCK_IPS.addAll(Arrays.asList(block_ips.split(","))); } else { optionsService.saveOption(Types.BLOCK_IPS, ""); TaleConst.BLOCK_IPS.clear(); } // 处理卸载插件 if (StringKit.isNotBlank(plugin_name)) { String key = "plugin_"; // 卸载所有插件 if (!"*".equals(plugin_name)) { key = "plugin_" + plugin_name; } else { optionsService.saveOption(Types.ATTACH_URL, Commons.site_url()); } optionsService.deleteOption(key); } // 是否允许重新安装 if (StringKit.isNotBlank(allow_install)) { optionsService.saveOption("allow_install", allow_install); TaleConst.OPTIONS.toMap().put("allow_install", allow_install); } return RestResponse.ok(); }
Example #20
Source File: IndexController.java From tale with MIT License | 2 votes |
/** * 搜索页 * * @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 #21
Source File: IndexController.java From tale with MIT License | 2 votes |
/** * 首页 * * @return */ @GetRoute public String index(Request request, @Param(defaultValue = "12") int limit) { return this.index(request, 1, limit); }
Example #22
Source File: CategoryController.java From tale with MIT License | 2 votes |
/** * 标签详情页 * * @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 #23
Source File: IndexController.java From blade with Apache License 2.0 | 2 votes |
public void users(@Param String name) { }