| | |
| | | package com.panzhihua.service_grid.config; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.PluginUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; |
| | | import org.apache.ibatis.executor.Executor; |
| | |
| | | } |
| | | 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) { |
| | | }); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |