From f09e05514d9a9e2623cfa73c4de1ffa98bb30bf8 Mon Sep 17 00:00:00 2001 From: xiejun <xiejun@vci-tech.com> Date: 星期二, 23 一月 2024 10:09:07 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java index 72cf41b..124a39c 100644 --- a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java @@ -19,6 +19,8 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,7 +28,7 @@ import java.util.stream.Collectors; /** - * 鍒嗙被鎺堟潈 + * 鍒嗙被鎺堟潈,鏁版嵁鎺堟潈 * @author ludc * @date 2023/12/25 15:35 */ @@ -87,7 +89,8 @@ throw new ServiceException("缂哄皯蹇呬紶鍙傛暟鍒嗙被id"); } LambdaQueryWrapper<ClassifyAuth> wrapper = Wrappers.<ClassifyAuth>query() - .lambda().eq(ClassifyAuth::getClassifyId,classifyAuthVO.getClassifyId()); + .lambda().eq(ClassifyAuth::getClassifyId,classifyAuthVO.getClassifyId()) + .eq(ClassifyAuth::getAuthType,classifyAuthVO.getAuthType()); List<ClassifyAuth> classifyAuths = this.classifyAuthMapper.selectList(wrapper); if(classifyAuths.isEmpty()){ return new ArrayList<ClassifyAuthVO>(); @@ -98,9 +101,33 @@ /** * 鏌ヨ璇ュ垎绫讳笅锛屽綋鍓嶇櫥褰曠殑瑙掕壊鏈夊摢浜涙寜閽潈闄� * @param classifyId + * @param menuCode + * @param authType * @return */ - public Map<String,Boolean> getAuthButtonList(String classifyId){ + public Map<String,Boolean> getAuthButtonList(String classifyId,String menuCode,String authType){ + List<Menu> menuList = this.getButtonList(classifyId, menuCode, authType); + if(menuList.isEmpty()){ + return new HashMap<>(); + } + Map<String, Boolean> buttonMaps = menuList.stream() + .collect(Collectors.toMap(Menu::getCode, menu -> true)); + return buttonMaps; + } + + /** + * 鏌ヨ璇ヤ富鏁版嵁涓嬶紝褰撳墠鐧诲綍鐨勮鑹叉湁鍝簺鎸夐挳鑿滃崟鏉冮檺 + * @param classifyId + * @param menuCode + * @param authType + * @return + */ + public List<Menu> getAuthMenuButtonList(String classifyId,String menuCode,String authType){ + List<Menu> buttonList = getButtonList(classifyId, menuCode, authType); + return buttonList; + } + + private List<Menu> getButtonList(String classifyId,String menuCode,String authType){ if(Func.isBlank(classifyId)){ throw new ServiceException("蹇呬紶鍙傛暟鍒嗙被oid涓嶈兘涓虹┖锛�"); } @@ -115,6 +142,7 @@ // 鍏堟煡璇㈡寜閽甶d鍒楄〃 LambdaQueryWrapper<ClassifyAuth> wrapper = Wrappers.<ClassifyAuth>query() .lambda().eq(ClassifyAuth::getClassifyId, classifyId) + .eq(ClassifyAuth::getAuthType,authType) .in(ClassifyAuth::getRoleId, roleIds); List<ClassifyAuth> classifyAuths = this.classifyAuthMapper.selectList(wrapper); //濡傛灉褰撳墠鍒嗙被娌℃湁鎵惧埌鎺堟潈閰嶇疆锛屽氨渚濇浠庡綋鍓嶈妭鐐瑰線涓婂眰鑺傜偣鎵炬巿鏉冮厤缃紝鎵惧埌浜嗗氨鍋滄锛屾病鎵惧埌灏变竴鐩存壘鍒版渶鍚� @@ -139,20 +167,14 @@ Boolean isAdmin = VciBaseUtil.checkAdminTenant(); // 鏈厤缃寜閽潈闄� if(!isAdmin && (classifyAuths.isEmpty() || Func.isBlank(classifyAuths.get(0).getButtonIds()))){ - return new HashMap<>(); + return new ArrayList<>(); } - List<String> condition1 = new ArrayList<>(); + List<String> ids = new ArrayList<>(); // 濡傛灉涓嶆槸瓒呯鐢ㄦ埛 if(!isAdmin){ - condition1.addAll(Arrays.asList(classifyAuths.get(0).getButtonIds().split(","))); + ids.addAll(Arrays.asList(classifyAuths.get(0).getButtonIds().split(","))); } - List<Menu> menuList = menuService.getMenuListById(condition1,"1648879284590858241"); - if(menuList.isEmpty()){ - return new HashMap<>(); - } - Map<String, Boolean> buttonMaps = menuList.stream() - .collect(Collectors.toMap(Menu::getCode, menu -> true)); - return buttonMaps; + return menuService.getMenuListByCode(ids,menuCode,roleIds); } /** @@ -161,11 +183,11 @@ * @return */ @Override - public List<String> getViewClassByRoleIds(List<String> roleIds) { + public List<String> getViewClassByRoleIds(List<String> roleIds,String authType,String buttonCode,String menuCode) { if(roleIds.isEmpty()){ return new ArrayList<>(); } - return this.classifyAuthMapper.getViewClassByRoleIds(roleIds); + return this.classifyAuthMapper.getViewClassByRoleIds(roleIds, authType,buttonCode,menuCode); } } -- Gitblit v1.9.3