From 315a74a16e0e8ac218b9ca790ab52641ad02f995 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期三, 29 十二月 2021 17:32:22 +0800 Subject: [PATCH] 12/29 河门口大屏特殊修改 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/MybatisHmkInterceptor.java | 53 +++++++++++++++++++++++++---------------------------- 1 files changed, 25 insertions(+), 28 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/MybatisHmkInterceptor.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/MybatisHmkInterceptor.java index a359f5e..c468428 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/MybatisHmkInterceptor.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/MybatisHmkInterceptor.java @@ -1,26 +1,18 @@ package com.panzhihua.service_community.config; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.PluginUtils; import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.executor.Executor; -import org.apache.ibatis.executor.statement.StatementHandler; import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.mapping.ParameterMapping; -import org.apache.ibatis.plugin.*; -import org.apache.ibatis.reflection.DefaultReflectorFactory; -import org.apache.ibatis.reflection.MetaObject; -import org.apache.ibatis.reflection.SystemMetaObject; import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.RowBounds; -import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.sql.SQLException; -import java.sql.Statement; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -62,30 +54,35 @@ } else{ if(((Map<?, ?>) parameter).containsKey("arg0")){ - Map<?, ?> param= (Map<?, ?>) boundSql.getAdditionalParameter("_parameter"); + Map<?, ?> param= (Map<?, ?>) parameter; String finalSql = sql; - param.forEach((k, v)->{ - try { - Field field= v.getClass().getDeclaredField("communityId"); - if(field!=null){ - field.setAccessible(true); - if((long)field.get(v)==10086L){ - String sql1= finalSql.replace("community_id = ?","community_id in (30,31)"); - boundSql.getParameterMappings().forEach(parameterMapping -> { - if(!parameterMapping.getProperty().contains("communityId")){ - parameterMappingList.add(parameterMapping); + if(!param.isEmpty()){ + param.forEach((k, v)->{ + List<ParameterMapping> parameterMappingList1=new ArrayList<>(); + try { + Field field= v.getClass().getDeclaredField("communityId"); + if(field!=null){ + field.setAccessible(true); + if((long)field.get(v)==10086L){ + String sql1= finalSql.replace("community_id = ?","community_id in (30,31)"); + if(!CollectionUtils.isEmpty(boundSql.getParameterMappings())){ + boundSql.getParameterMappings().forEach(parameterMapping -> { + if(!parameterMapping.getProperty().contains("communityId")){ + parameterMappingList1.add(parameterMapping); + } + }); + PluginUtils.mpBoundSql(boundSql).parameterMappings(parameterMappingList1); } - }); - PluginUtils.mpBoundSql(boundSql).parameterMappings(parameterMappingList); - PluginUtils.mpBoundSql(boundSql).sql(sql1); + PluginUtils.mpBoundSql(boundSql).sql(sql1); + } } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { } - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { + }); + } - } - }); } } } -- Gitblit v1.7.1