|
@ -24,8 +24,11 @@ import com.epmet.commons.tools.constant.Constant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.enums.SuperAdminEnum; |
|
|
import com.epmet.commons.tools.enums.SuperAdminEnum; |
|
|
import com.epmet.commons.tools.exception.ErrorCode; |
|
|
import com.epmet.commons.tools.exception.ErrorCode; |
|
|
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
|
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
@ -34,6 +37,7 @@ import com.epmet.commons.tools.utils.TreeUtils; |
|
|
import com.epmet.dao.OperMenuDao; |
|
|
import com.epmet.dao.OperMenuDao; |
|
|
import com.epmet.dto.OperMenuDTO; |
|
|
import com.epmet.dto.OperMenuDTO; |
|
|
import com.epmet.dto.OperUserDTO; |
|
|
import com.epmet.dto.OperUserDTO; |
|
|
|
|
|
import com.epmet.dto.result.OperResouce; |
|
|
import com.epmet.entity.OperMenuEntity; |
|
|
import com.epmet.entity.OperMenuEntity; |
|
|
import com.epmet.enums.MenuTypeEnum; |
|
|
import com.epmet.enums.MenuTypeEnum; |
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
@ -48,6 +52,7 @@ import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.util.AntPathMatcher; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
@ -70,6 +75,10 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
private OperResourceService operResourceService; |
|
|
private OperResourceService operResourceService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private OperLanguageService operLanguageService; |
|
|
private OperLanguageService operLanguageService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
|
|
|
|
private final AntPathMatcher antPathMatcher = new AntPathMatcher(); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<OperMenuDTO> page(Map<String, Object> params) { |
|
|
public PageData<OperMenuDTO> page(Map<String, Object> params) { |
|
@ -112,6 +121,13 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
insert(entity); |
|
|
insert(entity); |
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
redisUtils.delete(RedisKeys.getOperExamineResourceUrls()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
String msg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
|
|
logger.error("保存菜单配置异常:{}", msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//保存菜单资源
|
|
|
//保存菜单资源
|
|
|
operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
|
|
|
|
|
@ -133,6 +149,21 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
updateById(entity); |
|
|
updateById(entity); |
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
redisUtils.delete(RedisKeys.getOperExamineResourceUrls()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
String msg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
|
|
logger.error("修改菜单配置异常:{}", msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
redisUtils.deleteByPattern(RedisKeys.operResourcesBaseDir().concat("*")); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
String msg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
|
|
logger.error("修改菜单配置异常:{}", msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新菜单资源
|
|
|
//更新菜单资源
|
|
|
operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
|
|
|
|
|
@ -150,6 +181,13 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void delete(String id, TokenDto tokenDto) { |
|
|
public void delete(String id, TokenDto tokenDto) { |
|
|
|
|
|
try { |
|
|
|
|
|
redisUtils.delete(RedisKeys.getOperExamineResourceUrls()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
String msg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
|
|
logger.error("删除菜单配置异常:{}", msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//逻辑删除
|
|
|
//逻辑删除
|
|
|
baseDao.deleteBatchIds(Collections.singletonList(id)); |
|
|
baseDao.deleteBatchIds(Collections.singletonList(id)); |
|
|
//删除角色菜单关系
|
|
|
//删除角色菜单关系
|
|
@ -242,6 +280,9 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
public void clearOperUserAccess(String app, String client, String userId) { |
|
|
public void clearOperUserAccess(String app, String client, String userId) { |
|
|
//清空当前用户,菜单导航、权限标识
|
|
|
//清空当前用户,菜单导航、权限标识
|
|
|
operMenuRedis.delete(userId, app, client); |
|
|
operMenuRedis.delete(userId, app, client); |
|
|
|
|
|
|
|
|
|
|
|
// 根据用户id删除用户资源列表,后期可以跟deleteAccess合并起来,先为烟台的安全检测做。
|
|
|
|
|
|
operMenuRedis.deleteOperResourcesByUserId(userId); |
|
|
logger.info(String.format("运营端用户退出系统%s,清空菜单、权限成功",userId)); |
|
|
logger.info(String.format("运营端用户退出系统%s,清空菜单、权限成功",userId)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -249,4 +290,32 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
operLanguageService.saveOrUpdate("oper_menu", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); |
|
|
operLanguageService.saveOrUpdate("oper_menu", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Boolean hasOperPermission(String uri, String method, String operId) { |
|
|
|
|
|
List<OperResouce> resouces = operMenuRedis.getOperResourcesByUserId(operId); |
|
|
|
|
|
if (resouces == null) { |
|
|
|
|
|
resouces = baseDao.getOperResourcesByUserId(operId); |
|
|
|
|
|
operMenuRedis.setOperResourcesByUserId(operId, resouces); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return pathMatcher(uri, method, resouces); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean pathMatcher(String requestUri, String method, List<OperResouce> resources){ |
|
|
|
|
|
for (OperResouce resource : resources) { |
|
|
|
|
|
String resourceUrl = resource.getResourceUrl(); |
|
|
|
|
|
String resourceMethod = resource.getResourceMethod(); |
|
|
|
|
|
|
|
|
|
|
|
// 路径匹配 && http方法 匹配
|
|
|
|
|
|
if(antPathMatcher.match(resourceUrl, requestUri) && resourceMethod.equals(method)){ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<OperResouce> getExamineResourceUrls() { |
|
|
|
|
|
return baseDao.getExamineResourceUrls(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|