Java Code Examples for com.jfinal.kit.Ret#isOk()
The following examples show how to use
com.jfinal.kit.Ret#isOk() .
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: _AdminController.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Clear @EmptyValidate({ @Form(name = "user", message = "账号不能为空"), @Form(name = "pwd", message = "密码不能为空"), @Form(name = "captcha", message = "验证码不能为空"), }) @CaptchaValidate(form = "captcha",message = "验证码不正确,请重新输入") public void doLogin(String user, String pwd) { if (!JPressHandler.getCurrentTarget().equals(JPressConfig.me.getAdminLoginAction())) { renderError(404); return; } if (StrUtil.isBlank(user) || StrUtil.isBlank(pwd)) { throw new RuntimeException("你当前的编辑器(idea 或者 eclipse)可能有问题,请参考文档:http://www.jfinal.com/doc/3-3 进行配置"); } User loginUser = userService.findByUsernameOrEmail(user); if (loginUser == null) { renderJson(Ret.fail("message", "用户名不正确。")); return; } if (!roleService.hasAnyRole(loginUser.getId())) { renderJson(Ret.fail("message", "您没有登录的权限。")); return; } Ret ret = userService.doValidateUserPwd(loginUser, pwd); if (ret.isOk()) { CookieUtil.put(this, JPressConsts.COOKIE_UID, loginUser.getId()); } renderJson(ret); }
Example 2
Source File: UserController.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Clear @EmptyValidate({ @Form(name = "user", message = "账号不能为空"), @Form(name = "pwd", message = "密码不能为空") }) public void doLogin(String user, String pwd) { if (StrUtil.isBlank(user) || StrUtil.isBlank(pwd)) { LogKit.error("你当前的 idea 或者 eclipse 可能有问题,请参考文档:http://www.jfinal.com/doc/3-3 进行配置"); return; } User loginUser = userService.findByUsernameOrEmail(user); if (loginUser == null) { renderJson(Ret.fail("message", "用户名不正确。")); return; } Ret ret = userService.doValidateUserPwd(loginUser, pwd); if (ret.isOk()) { CookieUtil.put(this, JPressConsts.COOKIE_UID, loginUser.getId()); } String gotoUrl = JPressOptions.get("login_goto_url", "/ucenter"); ret.set("gotoUrl", gotoUrl); renderJson(ret); }
Example 3
Source File: InstallController.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
public void install() { Ret ret; //数据库需要升级 if (InstallManager.me().isDbExist() && InstallManager.me().isJPressDb() && InstallManager.me().isNeedUpgrade()) { ret = doProcessUpgrade(); } //数据库已经存在 //确定是 jpress 的数据库 //数据库不需要升级 else if (InstallManager.me().isDbExist() && InstallManager.me().isJPressDb() && !InstallManager.me().isNeedUpgrade()) { ret = doProcessReInstall(); } //全新的数据库 else { ret = doProcessInstall(); } // 设置 JPress 的版本 if (ret.isOk()) { OptionService optionService = Aop.get(OptionService.class); optionService.saveOrUpdate("jpress_version", JPressConsts.VERSION); optionService.saveOrUpdate("jpress_version_code", JPressConsts.VERSION_CODE); } renderJson(ret); }