From 52fd1e55b71fa38ffe89db738acc4e6c7e4da0df Mon Sep 17 00:00:00 2001 From: ludc Date: 星期五, 02 二月 2024 16:47:35 +0800 Subject: [PATCH] 分类授权,数据授权界面请求参数修改 --- Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 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 d26b2a6..a0c765f 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 @@ -2,7 +2,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.vci.ubcs.code.feign.ICodeClassifyClient; @@ -14,15 +13,12 @@ import com.vci.ubcs.system.service.IClassifyAuthService; import com.vci.ubcs.system.service.IMenuService; import com.vci.ubcs.system.vo.ClassifyAuthVO; -import com.vci.ubcs.system.vo.MenuVO; import com.vci.ubcs.system.wrapper.ClassifyAuthWrapper; import lombok.AllArgsConstructor; import org.springblade.core.log.exception.ServiceException; 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; @@ -55,10 +51,12 @@ // 鏄竻绌烘巿鏉冨垪琛� if(classifyAuthListDTO.getIsCLear()){ if(Func.isEmpty(classifyAuthListDTO.getClassifyId())){ - return R.fail("娓呯┖鎺堟潈鍒楄〃鏃讹紝鏈幏鍙栫殑鍒嗙被id"); + return R.fail("娓呯┖鎺堟潈鍒楄〃鏃讹紝鏈幏鍙栧埌鍒嗙被id"); } - this.classifyAuthMapper.delete(Wrappers.<ClassifyAuth>update() + this.classifyAuthMapper.delete( + Wrappers.<ClassifyAuth>update() .lambda().eq(ClassifyAuth::getClassifyId, classifyAuthListDTO.getClassifyId()) + .eq(ClassifyAuth::getAuthType,classifyAuthListDTO.getAuthType()) ); return R.success("鎺堟潈鍒楄〃娓呯┖鎴愬姛"); } @@ -82,6 +80,7 @@ // 鍒犻櫎 LambdaUpdateWrapper<ClassifyAuth> updateWrapper = Wrappers.<ClassifyAuth>update() .lambda().eq(ClassifyAuth::getClassifyId, classifyAuthListDTO.getClassifyAuthList().get(0).getClassifyId()) + .eq(ClassifyAuth::getAuthType,classifyAuthListDTO.getAuthType()) .notIn(ClassifyAuth::getRoleId, roleIds); try { this.classifyAuthMapper.delete(updateWrapper); @@ -168,15 +167,23 @@ .eq(ClassifyAuth::getAuthType,authType) .in(ClassifyAuth::getRoleId, roleIds) ); - //鍙褰撳墠鑺傜偣鐨勪笂灞傝妭鐐逛腑鎵惧埌浜嗗垎绫绘巿鏉冧俊鎭氨涓嶅啀缁х画缃戜笂鎵句簡 + //鍙褰撳墠鑺傜偣鐨勪笂灞傝妭鐐逛腑鎵惧埌浜嗗垎绫绘巿鏉冧俊鎭氨涓嶅啀缁х画寰�涓婃壘浜� if(!classifyAuths.isEmpty()){ break; } } } - //鍑虹幇浜嗛敊璇暟鎹紝鍚屼竴涓鑹插拰鍚屼竴涓垎绫籭d瀛樺湪澶氭潯鎺堟潈璁板綍 + //鍑虹幇浜嗗鏉℃暟鎹� if(classifyAuths.size()>1){ - throw new ServiceException("瑙掕壊鍜屽垎绫婚厤缃瓨鍦ㄥ鏉¤褰曪紝璇疯仈绯荤鐞嗕汉鍛樻竻鐞嗛敊璇厤缃紒"); + // 鏍¢獙鏄惁瀛樺湪閿欒鏁版嵁锛屽悓涓�涓鑹插拰鍚屼竴涓垎绫籭d瀛樺湪澶氭潯鎺堟潈璁板綍 + List<ClassifyAuth> finalClassifyAuths = classifyAuths; + boolean hasDuplicate = classifyAuths.stream() + .anyMatch(auth1 -> finalClassifyAuths.stream() + .filter(auth2 -> auth1 != auth2) + .anyMatch(auth2 -> auth1.getRoleId().equals(auth2.getRoleId()) && auth1.getClassifyId().equals(auth2.getClassifyId()))); + if (hasDuplicate) { + throw new ServiceException("瑙掕壊鍜屽垎绫婚厤缃瓨鍦ㄥ鏉¤褰曪紝璇疯仈绯荤鐞嗕汉鍛樻竻鐞嗛敊璇厤缃紒"); + } } // 鏄惁涓鸿秴绠� Boolean isAdmin = VciBaseUtil.checkAdminTenant(); @@ -187,7 +194,10 @@ List<String> ids = new ArrayList<>(); // 濡傛灉涓嶆槸瓒呯鐢ㄦ埛 if(!isAdmin){ - ids.addAll(Arrays.asList(classifyAuths.get(0).getButtonIds().split(","))); + String concatenatedButtonIds = classifyAuths.stream() + .map(ClassifyAuth::getButtonIds) // 鑾峰彇姣忎釜classifyAuths瀵硅薄鐨刡uttonIds + .collect(Collectors.joining(",")); // 鐢ㄩ�楀彿鍒嗛殧鎷兼帴鎴愪竴涓瓧绗︿覆 + ids.addAll(Arrays.asList(concatenatedButtonIds.split(","))); } return menuService.getMenuListByCode(ids,menuCode,roleIds); } -- Gitblit v1.9.3