com.jfinal.aop.Clear Java Examples

The following examples show how to use com.jfinal.aop.Clear. 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: BusinessFormInfoController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 列表数据
 */
@Clear(PermissionInterceptor.class)
@Before(SearchSql.class)
public void query() {
    int pageNumber = getAttr("pageNumber");
    int pageSize = getAttr("pageSize");
    String where = getAttr(Constant.SEARCH_SQL);

    // 组织机构查询条件
    String orgId = getPara("extra_orgId");
    if (StringUtils.notEmpty(orgId)) {
        Boolean cascadeOrg = getParaToBoolean("extra_cascadeOrg", false);
        String whereSeg;
        if (cascadeOrg) {
            String sonIds = TreeTableUtils.getSonTreeIds(orgId, "sys_org", "id", "pid");
            if (StringUtils.notEmpty(sonIds)) {
                sonIds = sonIds.replaceAll(",", "','");
            } else {
                sonIds = "unknow";  // 查不到的
            }
            whereSeg = " categoryId in ('" + sonIds + "')";
        } else {
            whereSeg = " categoryId ='" + orgId + "' ";
        }

        if (StringUtils.isEmpty(where)) {
            where += whereSeg;
        } else {
            where += (" and " + whereSeg);
        }
    }

    Page<BusinessFormInfo> businessFormInfoPage = BusinessFormInfo.dao.page(pageNumber, pageSize, where);
    renderDatagrid(businessFormInfoPage);
}
 
Example #2
Source File: SysMenuController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * org comobTree 数据, 完整的数据
 */
@Clear(PermissionInterceptor.class)
public void menuComboTree() {
    List<SysMenu> sysMenus = SysMenu.dao.findAllSort();
    Set<String> pids = new HashSet<>();
    sysMenus.forEach(item -> pids.add(item.getPid()));

    List<Map<String, Object>> maps = new ArrayList<>();
    Map<String, Object> root = new HashMap<>();
    root.put("id", "0");
    root.put("pid", "-1");
    root.put("text", "根菜单");
    root.put("iconCls", "iconfont icon-root");
    root.put("state", sysMenus.size() > 0 ? "closed" : "open");
    maps.add(root);
    for (SysMenu sysMenu : sysMenus) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", sysMenu.getId());
        map.put("text", sysMenu.getMenuName());
        map.put("pid", sysMenu.getPid());
        map.put("iconCls", sysMenu.getIcon());
        if (pids.contains(sysMenu.getId())) {
            map.put("state", "closed");
        }
        maps.add(map);
    }
    renderJson(maps);
}
 
Example #3
Source File: _AdminController.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Clear
public void login() {

    if (!JPressHandler.getCurrentTarget().equals(JPressConfig.me.getAdminLoginPage())) {
        renderError(404);
        return;
    }

    setAttr("action", JPressConfig.me.getAdminLoginAction());
    render("login.html");
}
 
Example #4
Source File: _AdminController.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #5
Source File: UserController.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #6
Source File: JbootWechatController.java    From jboot with Apache License 2.0 4 votes vote down vote up
@Clear(WechatUserInterceptor.class)
public void wechatCallback() {

    String gotoUrl = getPara("goto");
    String code = getPara("code");

    //获得不到code?
    if (StrUtil.isBlank(code)) {
        renderText("获取不到正确的code信息");
        return;
    }


    /**
     * 在某些情况下,相同的callback会执行两次,code相同。
     */
    String wechatOpenId = getSessionAttr(SESSION_WECHAT_OPEN_ID);
    String accessToken = getSessionAttr(SESSION_WECHAT_ACCESS_TOKEN);

    if (StrUtil.isNotBlank(wechatOpenId)
            && StrUtil.isNotBlank(accessToken)) {
        doRedirect(gotoUrl, wechatOpenId, accessToken);
        return;
    }


    ApiResult result = WechatApis.getAccessTokenAndOpenId(code);
    if (result == null) {
        renderText("网络错误,获取不到微信信息,请联系管理员");
        return;
    }

    /**
     * 成功获取到 accesstoken 和 openid
     */
    if (result.isSucceed()) {
        wechatOpenId = result.getStr("openid");
        accessToken = result.getStr("access_token");
        setSessionAttr(SESSION_WECHAT_OPEN_ID, wechatOpenId);
        setSessionAttr(SESSION_WECHAT_ACCESS_TOKEN, accessToken);
        setSessionAttr(SESSION_WECHAT_SCOPE, result.getStr("scope"));
    } else {
        wechatOpenId = getSessionAttr(SESSION_WECHAT_OPEN_ID);
        accessToken = getSessionAttr(SESSION_WECHAT_ACCESS_TOKEN);

        if (StrUtil.isBlank(wechatOpenId) || StrUtil.isBlank(accessToken)) {
            renderText("错误:" + result.getErrorMsg());
            return;
        }
    }

    if ("snsapi_base".equalsIgnoreCase(result.getStr("scope"))) {
        redirect(gotoUrl);
        return;
    }

    doRedirect(gotoUrl, wechatOpenId, accessToken);
}
 
Example #7
Source File: SysDictController.java    From my_curd with Apache License 2.0 4 votes vote down vote up
@Clear({PermissionInterceptor.class, ComActionInterceptor.class})
public void combobox() {
    String groupCode = get("groupCode", "");
    renderJson(SysDict.dao.findListByGroupAndState(groupCode, "on"));
}
 
Example #8
Source File: _AdminController.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Clear(PermissionInterceptor.class)
public void logout() {
    CookieUtil.remove(this, JPressConsts.COOKIE_UID);
    redirect("/");
}