Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
package com.jero.modules.system.enums;
|
||||
|
||||
public enum RoleEnum {
|
||||
ADMIN_ID("R&H Manager","R&H Manager","manager","1534020391015444481",2),
|
||||
MANAGER_ID("系统管理员","Administrator","admin","f6817f48af4fb3af11b9e8bf182f618b",3),
|
||||
COUNTRU_CARD_MANAGE("countryCard管理员","countryCardManage","countryCardManage","1564916346120916993",4),
|
||||
;
|
||||
|
||||
String name;
|
||||
String enName;
|
||||
String value;
|
||||
String id;
|
||||
Integer order;
|
||||
|
||||
RoleEnum(String name, String enName, String value, String id, Integer order) {
|
||||
this.name = name;
|
||||
this.enName = enName;
|
||||
this.value = value;
|
||||
this.id = id;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getEnName() {
|
||||
return enName;
|
||||
}
|
||||
|
||||
public void setEnName(String enName) {
|
||||
this.enName = enName;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Integer order) {
|
||||
this.order = order;
|
||||
}
|
||||
}
|
||||
+6
@@ -270,4 +270,10 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
List<SysRole> queryUserRoleListInfoByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 验证当前登录用户是否是超级管理员。
|
||||
* @return
|
||||
*/
|
||||
boolean isAdministrator();
|
||||
}
|
||||
|
||||
+28
@@ -17,6 +17,7 @@ import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.base.service.BaseCommonService;
|
||||
import com.jero.modules.system.entity.*;
|
||||
import com.jero.modules.system.enums.PPSyncEnum;
|
||||
import com.jero.modules.system.enums.RoleEnum;
|
||||
import com.jero.modules.system.mapper.*;
|
||||
import com.jero.modules.system.model.SysUserSysDepartModel;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
@@ -24,6 +25,7 @@ import com.jero.modules.system.vo.SysUserDepVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -586,4 +588,30 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证当前登录用户是否是超级管理员
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isAdministrator() {
|
||||
boolean result = false;
|
||||
RoleEnum administrator = RoleEnum.MANAGER_ID;
|
||||
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<SysUserRole> userRoleList = this.sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, currentUser.getId())); // 查询用户所有角色
|
||||
if(CollectionUtils.isNotEmpty(userRoleList)){
|
||||
List<SysUserRole> userRoles = userRoleList.stream().filter(userRole -> {
|
||||
boolean flag = false;
|
||||
if(StringUtils.equals(userRole.getRoleId(),administrator.getId())){
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
if(CollectionUtils.isNotEmpty(userRoles)){
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user