jeesite 说明文档-3.内置组件的应用 联系客服

发布时间 : 星期二 文章jeesite 说明文档-3.内置组件的应用更新完毕开始阅读3c94635f80eb6294dc886c17

第3章 内置组件的应用

作者:ThinkGem 更新日期:2014-01-05

1. 常用组件

1.1. 布局组件

布局文件配置:

/ jeesite/src/main/webapp/WEB-INF/decorators.xml

默认布局文件:

/ jeesite/src/main/webapp/WEB-INF/views/layouts/default.jsp 非公共,自己建立的布局文件:

/ jeesite/src/main/webapp/WEB-INF/views/模块路径/layouts/布局文件.jsp 使用布局文件:

JSP的head里添加:

1.2. 用户工具 UserUtils.java fns.tld

应用场景:在java文件或jsp页面上,获取当前用户相关信息 1. 获取当前用户:

1) UserUtils.getUser(); 2) entity.currentUser() 3) ${fns:getUser()} 2. 获取当前用户部门:

1) UserUtils.getOfficeList() 2) ${fns:getOfficeList()} 3. 获取当前用户区域:

1) UserUtils.getAreaList() 2) ${fns:getAreaList()} 4. 获取当前用户菜单:

1) UserUtils.getMenuList() 2) ${fns:getMenuList()} 5. 获取当前用户缓存:

1) UserUtils.getCache(key);

2) ${fns:getCache(cacheName, defaultValue)} 6. 设置当前用户缓存:

1) UserUtils.putCache(key);

1.3. 全局缓存 CacheUtils.java

应用场景:系统字典

1. 设置应用程序缓存:CacheUtils.put(key); 2. 获取应用程序缓存:CacheUtils.get(key);

1.4. 字典工具 DictUtils.java

应用场景:系统全局固定的字典数据,java或jsp中获取字典相关数据。

1. 根据类型和值获取字典标签(列表取值):

a) DictUtils.getDictLabel(String value, String type, String defaultValue) b) ${ fns:getDictLabel (value, type, defaultValue)} 2. 根据类型和标签获取字典值(根据标签取值):

a) DictUtils.getDictValue(String label, String type, String defaultLabel) b) ${fns:getDictValue(label, type, defaultValue)} 3. 根据类型获取字典列表(下拉框,复选框,单选框):

a) DictUtils.getDictList(String type) b) ${fns:getDictList(type)}

1.5. 功能权限控制

应用场景:访问功能授权,查看权限,编辑权限,导入权限,审核权限。 1. 给方法添加权限标志

@RequiresPermissions(\@RequiresUser

2. 菜单中设置权限标志。 3. 判断权限:

SecurityUtils.getSubject().isPermitted(\; 4. 视图中控制按钮(shiro.tld):

保 存\

返 回\

1.6. 数据权限

应用场景:某用户访问数据范围:公司及子公司,本公司,部门及子部门,本部门,当前用户,明细设置。

// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用

${sqlMap.dsf}调用权限SQL) user.getSqlMap().put(\,

dataScopeFilter(user.getCurrentUser(), \, \));

/**

* 数据范围过滤

* @param user 当前用户对象,通过“entity.getCurrentUser()”获取 * @param officeAlias 机构表别名,多个用“,”逗号隔开。

* @param userAlias 用户表别名,多个用“,”逗号隔开,传递空,忽略此参数 * @return 标准连接条件对象 */

String dataScopeFilter (User user, String officeAlias, String

userAlias)

1.7. 智能分页组件

// 设置分页参数,则分页,如果不设置,则根据条件获取全部 user.setPage(page); // 执行分页查询

page.setList(userDao.findPage(user));