Commit df52fb90a1106d7bbfaa952882fcda728e51912a
1 parent
877ef4bfc3
Exists in
master
and in
6 other branches
update
Showing 2 changed files with 63 additions and 3 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/OrganizationServiceImpl.java
View file @
df52fb9
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java
View file @
df52fb9
| ... | ... | @@ -34,6 +34,32 @@ |
| 34 | 34 | }) |
| 35 | 35 | public class MybatisSqlInterceptor implements Interceptor { |
| 36 | 36 | |
| 37 | + //同步的表 | |
| 38 | + private static Set<String> uses = new HashSet<>(); | |
| 39 | + //不同步的表 | |
| 40 | + private static Set<String> noUses = new HashSet<>(); | |
| 41 | + static { | |
| 42 | + uses.add("departments"); | |
| 43 | + uses.add("organization"); | |
| 44 | + uses.add("permissions"); | |
| 45 | + uses.add("permissions2"); | |
| 46 | + uses.add("regions"); | |
| 47 | + uses.add("role_permission_maps"); | |
| 48 | + uses.add("roles"); | |
| 49 | + uses.add("user_organization_maps"); | |
| 50 | + uses.add("user_role_maps"); | |
| 51 | + uses.add("users"); | |
| 52 | + | |
| 53 | + noUses.add("coupon_info"); | |
| 54 | + noUses.add("coupon_template"); | |
| 55 | + noUses.add("coupon_template_group"); | |
| 56 | + noUses.add("coupon_type"); | |
| 57 | + noUses.add("hospital_coupon_template_group"); | |
| 58 | + noUses.add("lis_report_tbl"); | |
| 59 | + noUses.add("ris_report_tbl"); | |
| 60 | + | |
| 61 | + } | |
| 62 | + | |
| 37 | 63 | private String sql; |
| 38 | 64 | |
| 39 | 65 | private Properties properties; |
| ... | ... | @@ -71,7 +97,7 @@ |
| 71 | 97 | { |
| 72 | 98 | sql = getSql(configuration, boundSql, sqlId); |
| 73 | 99 | System.out.println("sql = "+sql); |
| 74 | - if (!(sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL"))) | |
| 100 | + if (isSyncTable(sql)) | |
| 75 | 101 | { |
| 76 | 102 | |
| 77 | 103 | System.out.println("delete or update sync sql = " + sql); |
| ... | ... | @@ -85,7 +111,7 @@ |
| 85 | 111 | { |
| 86 | 112 | System.out.println("time5=========" + (System.currentTimeMillis()-start)); |
| 87 | 113 | String tempSql = getSql(configuration, boundSql, sqlId); |
| 88 | - if (!(tempSql.toUpperCase().contains("LIS_REPORT_TBL") || tempSql.toUpperCase().contains("RIS_REPORT_TBL"))) | |
| 114 | + if (isSyncTable(tempSql)) | |
| 89 | 115 | { |
| 90 | 116 | sql = tempSql; |
| 91 | 117 | System.out.println("sql = "+sql); |
| ... | ... | @@ -123,6 +149,40 @@ |
| 123 | 149 | ExceptionUtils.catchException(e," Mybatis Sql Interceptor exception"); |
| 124 | 150 | } |
| 125 | 151 | return returnValue; |
| 152 | + } | |
| 153 | + | |
| 154 | + | |
| 155 | + /** | |
| 156 | + * 判断sql中的表是否要同步的 | |
| 157 | + * @param sql | |
| 158 | + * @return | |
| 159 | + */ | |
| 160 | + private boolean isSyncTable(String sql) | |
| 161 | + { | |
| 162 | + boolean result = false; | |
| 163 | + boolean nouse = true; | |
| 164 | + if (StringUtils.isEmpty(sql)) | |
| 165 | + { | |
| 166 | + return result; | |
| 167 | + } | |
| 168 | + for(String key : uses) | |
| 169 | + { | |
| 170 | + if (sql.toLowerCase().contains(key)) | |
| 171 | + { | |
| 172 | + result = true; | |
| 173 | + break; | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + for(String key : noUses) | |
| 178 | + { | |
| 179 | + if (sql.toLowerCase().contains(key)) | |
| 180 | + { | |
| 181 | + nouse = false; | |
| 182 | + break; | |
| 183 | + } | |
| 184 | + } | |
| 185 | + return nouse == result; | |
| 126 | 186 | } |
| 127 | 187 | |
| 128 | 188 | public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId) { |