新增 窗口右上角的头像下拉菜单,切换当前用户所属岗位,并联动切换当前菜单权限
This commit is contained in:
@@ -17,13 +17,12 @@ import com.jeesite.common.shiro.realm.BaseAuthorizingRealm;
|
||||
import com.jeesite.common.utils.SpringUtils;
|
||||
import com.jeesite.common.web.CookieUtils;
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
import com.jeesite.modules.sys.entity.Log;
|
||||
import com.jeesite.modules.sys.entity.Role;
|
||||
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 com.jeesite.modules.sys.entity.*;
|
||||
import com.jeesite.modules.sys.utils.*;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.authc.IncorrectCredentialsException;
|
||||
@@ -37,10 +36,6 @@ import org.apache.shiro.web.util.WebUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -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("sysCode", session.getAttribute("sysCode"));
|
||||
data.put("roleCode", session.getAttribute("roleCode"));
|
||||
data.put("postCode", session.getAttribute("postCode"));
|
||||
data.put("title", Global.getProperty("productName"));
|
||||
data.put("company", Global.getProperty("companyName"));
|
||||
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);
|
||||
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"));
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.jeesite.modules.sys.service.support;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.sys.dao.EmployeeDao;
|
||||
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
|
||||
@@ -107,6 +108,12 @@ public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
|
||||
public List<EmployeePost> findEmployeePostList(Employee employee){
|
||||
EmployeePost employeePost = new EmployeePost();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package com.jeesite.modules.sys.utils;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.collect.SetUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
@@ -325,6 +326,19 @@ public class EmpUtils {
|
||||
});
|
||||
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缓存
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PostController extends BaseController {
|
||||
List<String> roleCodes = ListUtils.newArrayList();
|
||||
List<String> roleNames = ListUtils.newArrayList();
|
||||
postService.findPostRoleList(where).forEach(e -> {
|
||||
if (e.getRole() != null) {
|
||||
if (e.getRole() != null && PostRole.STATUS_NORMAL.equals(e.getRole().getStatus())) {
|
||||
roleCodes.add(e.getRoleCode());
|
||||
roleNames.add(e.getRole().getRoleName());
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<i class="fa fa-sign-out"></i> ${text('退出登录')}</a>
|
||||
</li>
|
||||
<% var sysCodes = [];
|
||||
for(var role in user.roleList) {
|
||||
for(var role in roleList) {
|
||||
var codes = @StringUtils.splitComma(role.sysCodes);
|
||||
if (!isEmpty(codes)) {
|
||||
for (var code in codes) {
|
||||
@@ -47,12 +47,25 @@
|
||||
<% }else{ %>
|
||||
<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>
|
||||
<% var roleCode = @ObjectUtils.toStringIgnoreNull(session.roleCode, ''); %>
|
||||
<li class="dropdown-header mb5">${text('选择身份')}:<% if(isNotBlank(roleCode)){ %>
|
||||
<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>
|
||||
<a href="${ctx}/switchRole/${role.roleCode}">
|
||||
<i class="fa fa-${roleCode == role.roleCode
|
||||
|
||||
Reference in New Issue
Block a user