新增 窗口右上角的头像下拉菜单,切换当前用户所属岗位,并联动切换当前菜单权限
This commit is contained in:
@@ -17,13 +17,8 @@ import com.jeesite.common.shiro.realm.BaseAuthorizingRealm;
|
|||||||
import com.jeesite.common.utils.SpringUtils;
|
import com.jeesite.common.utils.SpringUtils;
|
||||||
import com.jeesite.common.web.CookieUtils;
|
import com.jeesite.common.web.CookieUtils;
|
||||||
import com.jeesite.common.web.http.ServletUtils;
|
import com.jeesite.common.web.http.ServletUtils;
|
||||||
import com.jeesite.modules.sys.entity.Log;
|
import com.jeesite.modules.sys.entity.*;
|
||||||
import com.jeesite.modules.sys.entity.Role;
|
import com.jeesite.modules.sys.utils.*;
|
||||||
import com.jeesite.modules.sys.entity.User;
|
|
||||||
import com.jeesite.modules.sys.utils.CorpUtils;
|
|
||||||
import com.jeesite.modules.sys.utils.LogUtils;
|
|
||||||
import com.jeesite.modules.sys.utils.UserUtils;
|
|
||||||
import com.jeesite.modules.sys.utils.ValidCodeUtils;
|
|
||||||
import org.apache.shiro.authc.AuthenticationException;
|
import org.apache.shiro.authc.AuthenticationException;
|
||||||
import org.apache.shiro.authc.AuthenticationToken;
|
import org.apache.shiro.authc.AuthenticationToken;
|
||||||
import org.apache.shiro.authc.IncorrectCredentialsException;
|
import org.apache.shiro.authc.IncorrectCredentialsException;
|
||||||
@@ -452,6 +447,7 @@ public class FormFilter extends org.apache.shiro.web.filter.authc.FormAuthentica
|
|||||||
data.put("msgEnabled", Global.getPropertyToBoolean("msg.enabled", "false"));
|
data.put("msgEnabled", Global.getPropertyToBoolean("msg.enabled", "false"));
|
||||||
data.put("sysCode", session.getAttribute("sysCode"));
|
data.put("sysCode", session.getAttribute("sysCode"));
|
||||||
data.put("roleCode", session.getAttribute("roleCode"));
|
data.put("roleCode", session.getAttribute("roleCode"));
|
||||||
|
data.put("postCode", session.getAttribute("postCode"));
|
||||||
data.put("title", Global.getProperty("productName"));
|
data.put("title", Global.getProperty("productName"));
|
||||||
data.put("company", Global.getProperty("companyName"));
|
data.put("company", Global.getProperty("companyName"));
|
||||||
data.put("version", Global.getProperty("productVersion"));
|
data.put("version", Global.getProperty("productVersion"));
|
||||||
@@ -471,6 +467,21 @@ public class FormFilter extends org.apache.shiro.web.filter.authc.FormAuthentica
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.put("roleList", roleList);
|
data.put("roleList", roleList);
|
||||||
|
List<Map<String, Object>> postList = ListUtils.newArrayList();
|
||||||
|
if (Global.getConfigToBoolean("user.postRolePermi", "false")
|
||||||
|
&& User.USER_TYPE_EMPLOYEE.equals(user.getUserType())) {
|
||||||
|
Employee employee = user.getRefObj();
|
||||||
|
for (EmployeePost ep : EmpUtils.getEmployeePostList(employee.getEmpCode())){
|
||||||
|
Post post = ep.getPost();
|
||||||
|
if (post != null) {
|
||||||
|
Map<String, Object> postMap = MapUtils.newHashMap();
|
||||||
|
postMap.put("postCode", post.getPostCode());
|
||||||
|
postMap.put("postName", post.getPostName());
|
||||||
|
postList.add(postMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.put("postList", postList);
|
||||||
data.put("desktopUrl", desktopUrl != null ? desktopUrl : Global.getConfig("sys.index.desktopUrl"));
|
data.put("desktopUrl", desktopUrl != null ? desktopUrl : Global.getConfig("sys.index.desktopUrl"));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package com.jeesite.modules.sys.service.support;
|
|||||||
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
import com.jeesite.common.entity.Page;
|
import com.jeesite.common.entity.Page;
|
||||||
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.service.CrudService;
|
import com.jeesite.common.service.CrudService;
|
||||||
import com.jeesite.modules.sys.dao.EmployeeDao;
|
import com.jeesite.modules.sys.dao.EmployeeDao;
|
||||||
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
|
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
|
||||||
@@ -107,6 +108,12 @@ public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
|
|||||||
public List<EmployeePost> findEmployeePostList(Employee employee){
|
public List<EmployeePost> findEmployeePostList(Employee employee){
|
||||||
EmployeePost employeePost = new EmployeePost();
|
EmployeePost employeePost = new EmployeePost();
|
||||||
employeePost.setEmpCode(employee.getEmpCode());
|
employeePost.setEmpCode(employee.getEmpCode());
|
||||||
|
if (employee.getDataMap() != null) {
|
||||||
|
String a = (String)employee.getDataMap().get("loadJoinTableAlias");
|
||||||
|
if (StringUtils.isNotBlank(a)) {
|
||||||
|
employeePost.sqlMap().loadJoinTableAlias(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
return employeePostDao.findList(employeePost);
|
return employeePostDao.findList(employeePost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package com.jeesite.modules.sys.utils;
|
package com.jeesite.modules.sys.utils;
|
||||||
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.collect.SetUtils;
|
import com.jeesite.common.collect.SetUtils;
|
||||||
import com.jeesite.common.lang.ObjectUtils;
|
import com.jeesite.common.lang.ObjectUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
@@ -325,6 +326,19 @@ public class EmpUtils {
|
|||||||
});
|
});
|
||||||
return list.toArray(new String[list.size()]);
|
return list.toArray(new String[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据员工编号,获取员工岗位(返回岗位编码和名称)
|
||||||
|
* @param empCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<EmployeePost> getEmployeePostList(String empCode){
|
||||||
|
Employee employee = new Employee();
|
||||||
|
employee.setEmpCode(empCode);
|
||||||
|
employee.setDataMap(MapUtils.newHashMap());
|
||||||
|
employee.getDataMap().put("loadJoinTableAlias", "p");
|
||||||
|
return Static.employeeService.findEmployeePostList(employee);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除指定用户缓存,不包括改用的SESSION缓存
|
* 清除指定用户缓存,不包括改用的SESSION缓存
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class PostController extends BaseController {
|
|||||||
List<String> roleCodes = ListUtils.newArrayList();
|
List<String> roleCodes = ListUtils.newArrayList();
|
||||||
List<String> roleNames = ListUtils.newArrayList();
|
List<String> roleNames = ListUtils.newArrayList();
|
||||||
postService.findPostRoleList(where).forEach(e -> {
|
postService.findPostRoleList(where).forEach(e -> {
|
||||||
if (e.getRole() != null) {
|
if (e.getRole() != null && PostRole.STATUS_NORMAL.equals(e.getRole().getStatus())) {
|
||||||
roleCodes.add(e.getRoleCode());
|
roleCodes.add(e.getRoleCode());
|
||||||
roleNames.add(e.getRole().getRoleName());
|
roleNames.add(e.getRole().getRoleName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<i class="fa fa-sign-out"></i> ${text('退出登录')}</a>
|
<i class="fa fa-sign-out"></i> ${text('退出登录')}</a>
|
||||||
</li>
|
</li>
|
||||||
<% var sysCodes = [];
|
<% var sysCodes = [];
|
||||||
for(var role in user.roleList) {
|
for(var role in roleList) {
|
||||||
var codes = @StringUtils.splitComma(role.sysCodes);
|
var codes = @StringUtils.splitComma(role.sysCodes);
|
||||||
if (!isEmpty(codes)) {
|
if (!isEmpty(codes)) {
|
||||||
for (var code in codes) {
|
for (var code in codes) {
|
||||||
@@ -47,12 +47,25 @@
|
|||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
<li class="mt10"></li>
|
<li class="mt10"></li>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if(user.roleList.~size > 0){ %>
|
<% if(postList.~size > 0){ %>
|
||||||
|
<li class="divider"></li>
|
||||||
|
<% var postCode = @ObjectUtils.toStringIgnoreNull(session.postCode, ''); %>
|
||||||
|
<li class="dropdown-header mb5">${text('选择岗位')}:<% if(isNotBlank(postCode)){ %>
|
||||||
|
<i class="fa fa-close pointer" title="${text('清除设置')}" onclick="location='${ctx}/switchPost'"></i><% } %></li>
|
||||||
|
<% for(var post in postList){ %>
|
||||||
|
<li>
|
||||||
|
<a href="${ctx}/switchPost/${post.postCode}">
|
||||||
|
<i class="fa fa-${postCode == post.postCode
|
||||||
|
? 'check-' : ''}circle-o"></i> ${post.postName}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<% } %>
|
||||||
|
<% } else if(roleList.~size > 0){ %>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<% var roleCode = @ObjectUtils.toStringIgnoreNull(session.roleCode, ''); %>
|
<% var roleCode = @ObjectUtils.toStringIgnoreNull(session.roleCode, ''); %>
|
||||||
<li class="dropdown-header mb5">${text('选择身份')}:<% if(isNotBlank(roleCode)){ %>
|
<li class="dropdown-header mb5">${text('选择身份')}:<% if(isNotBlank(roleCode)){ %>
|
||||||
<i class="fa fa-close pointer" title="${text('清除设置')}" onclick="location='${ctx}/switchRole'"></i><% } %></li>
|
<i class="fa fa-close pointer" title="${text('清除设置')}" onclick="location='${ctx}/switchRole'"></i><% } %></li>
|
||||||
<% for(var role in user.roleList){ if(role.isShow == '1'){ %>
|
<% for(var role in roleList){ if(role.isShow == '1'){ %>
|
||||||
<li>
|
<li>
|
||||||
<a href="${ctx}/switchRole/${role.roleCode}">
|
<a href="${ctx}/switchRole/${role.roleCode}">
|
||||||
<i class="fa fa-${roleCode == role.roleCode
|
<i class="fa fa-${roleCode == role.roleCode
|
||||||
|
|||||||
Reference in New Issue
Block a user