Commit 486880e3e2b2221ea7f7b93659f6076e9bf9b547
1 parent
12322a42
Exists in
master
and in
2 other branches
optimized
Showing
3 changed files
with
49 additions
and
79 deletions
Show diff stats
build.gradle
| @@ -55,7 +55,7 @@ uploadArchives { | @@ -55,7 +55,7 @@ uploadArchives { | ||
| 55 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) | 55 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) |
| 56 | } | 56 | } |
| 57 | pom.project { | 57 | pom.project { |
| 58 | - version '2.1.34' | 58 | + version '2.1.36' |
| 59 | artifactId ARTIFACT_Id | 59 | artifactId ARTIFACT_Id |
| 60 | groupId GROUP_ID | 60 | groupId GROUP_ID |
| 61 | packaging TYPE | 61 | packaging TYPE |
src/main/java/com/taover/repository/CustomJdbcTemplateWrapperTenant.java
| @@ -296,9 +296,8 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -296,9 +296,8 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | @Override | 298 | @Override |
| 299 | - public T findEntityByCondition(List<Object[]> condition) throws NotFoundException, MultiRowException, NoContainTenantException { | ||
| 300 | - this.checkTenantInfoFromCondition(condition); | ||
| 301 | - List<T> tempList = findListByCondition(condition); | 299 | + public T findEntityByCondition(List<Object[]> condition, Long tenantId) throws NotFoundException, MultiRowException, NoContainTenantException { |
| 300 | + List<T> tempList = findListByCondition(condition, tenantId); | ||
| 302 | if(tempList == null || tempList.size() == 0){ | 301 | if(tempList == null || tempList.size() == 0){ |
| 303 | throw new NotFoundException(); | 302 | throw new NotFoundException(); |
| 304 | } | 303 | } |
| @@ -309,22 +308,9 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -309,22 +308,9 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 309 | } | 308 | } |
| 310 | } | 309 | } |
| 311 | 310 | ||
| 312 | - private void checkTenantInfoFromCondition(List<Object[]> condition) throws NoContainTenantException{ | ||
| 313 | - for(Object[] item: condition) { | ||
| 314 | - if(item == null || item.length == 0) { | ||
| 315 | - continue; | ||
| 316 | - } | ||
| 317 | - if(item[0].toString().contains("tenant_id")) { | ||
| 318 | - return; | ||
| 319 | - } | ||
| 320 | - } | ||
| 321 | - throw new NoContainTenantException(); | ||
| 322 | - } | ||
| 323 | - | ||
| 324 | @Override | 311 | @Override |
| 325 | - public T findEntityBySql(String sqlCondition) throws NotFoundException, MultiRowException, NoContainTenantException { | ||
| 326 | - this.checkTenantInfoFromSql(sqlCondition); | ||
| 327 | - List<T> tempList = findListBySql(sqlCondition); | 312 | + public T findEntityBySql(String sqlCondition, Long tenantId) throws NotFoundException, MultiRowException { |
| 313 | + List<T> tempList = findListBySql(sqlCondition, tenantId); | ||
| 328 | if(tempList == null || tempList.size() == 0){ | 314 | if(tempList == null || tempList.size() == 0){ |
| 329 | throw new NotFoundException(); | 315 | throw new NotFoundException(); |
| 330 | } | 316 | } |
| @@ -334,53 +320,41 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -334,53 +320,41 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 334 | throw new MultiRowException(); | 320 | throw new MultiRowException(); |
| 335 | } | 321 | } |
| 336 | } | 322 | } |
| 337 | - | ||
| 338 | - private void checkTenantInfoFromSql(String sqlCondition) throws NoContainTenantException{ | ||
| 339 | - if(sqlCondition.contains("tenant_id")) { | ||
| 340 | - return; | ||
| 341 | - }else { | ||
| 342 | - throw new NoContainTenantException(); | ||
| 343 | - } | ||
| 344 | - } | ||
| 345 | - | 323 | + |
| 346 | @Override | 324 | @Override |
| 347 | - public List<T> findListByCondition(List<Object[]> condition) throws NoContainTenantException { | ||
| 348 | - return findListByCondition(condition, null); | 325 | + public List<T> findListByCondition(List<Object[]> condition, Long tenantId){ |
| 326 | + return findListByCondition(condition, null, tenantId); | ||
| 349 | } | 327 | } |
| 350 | 328 | ||
| 351 | @Override | 329 | @Override |
| 352 | - public List<T> findListByCondition(List<Object[]> condition, String sortCondition) throws NoContainTenantException { | ||
| 353 | - this.checkTenantInfoFromCondition(condition); | 330 | + public List<T> findListByCondition(List<Object[]> condition, String sortCondition, Long tenantId){ |
| 354 | StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()); | 331 | StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()); |
| 355 | - StringBuffer pql = new StringBuffer(sql.toString()); | ||
| 356 | List<Object> list = new ArrayList<Object>(); | 332 | List<Object> list = new ArrayList<Object>(); |
| 357 | - this.appendWhereCondition(sql, pql, list, condition); | 333 | + condition.add(new Object[] {"tenant_id", "=", tenantId}); |
| 334 | + this.appendWhereCondition(sql, new StringBuffer(), list, condition); | ||
| 358 | if(sortCondition != null && !sortCondition.equals("")){ | 335 | if(sortCondition != null && !sortCondition.equals("")){ |
| 359 | sql.append(" " + sortCondition + " "); | 336 | sql.append(" " + sortCondition + " "); |
| 360 | - pql.append(" " + sortCondition + " "); | ||
| 361 | } | 337 | } |
| 362 | return (List<T>)jdbcTemplateWrite.query(sql.toString(), this.customJdbcTemplateRowMapper, list.toArray()); | 338 | return (List<T>)jdbcTemplateWrite.query(sql.toString(), this.customJdbcTemplateRowMapper, list.toArray()); |
| 363 | } | 339 | } |
| 364 | 340 | ||
| 365 | @Override | 341 | @Override |
| 366 | - public List<T> findListBySql(String sqlCondition) throws NoContainTenantException { | ||
| 367 | - this.checkTenantInfoFromSql(sqlCondition); | ||
| 368 | - StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()+" WHERE " + sqlCondition); | 342 | + public List<T> findListBySql(String sqlCondition, Long tenantId){ |
| 343 | + StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()+" WHERE tenant_id="+tenantId + " and " + sqlCondition); | ||
| 369 | return (List<T>)jdbcTemplateWrite.query(sql.toString(), this.customJdbcTemplateRowMapper); | 344 | return (List<T>)jdbcTemplateWrite.query(sql.toString(), this.customJdbcTemplateRowMapper); |
| 370 | } | 345 | } |
| 371 | 346 | ||
| 372 | @Override | 347 | @Override |
| 373 | - public Map<String, Object> findPageByCondition(List<Object[]> condition, int page, int pageSize) throws NoContainTenantException { | ||
| 374 | - return findPageByCondition(condition, null , page, pageSize); | 348 | + public Map<String, Object> findPageByCondition(List<Object[]> condition, int page, int pageSize, Long tenantId){ |
| 349 | + return findPageByCondition(condition, null , page, pageSize, tenantId); | ||
| 375 | } | 350 | } |
| 376 | 351 | ||
| 377 | @Override | 352 | @Override |
| 378 | - public Map<String, Object> findPageByCondition(List<Object[]> condition, String sortCondition, int page, int pageSize) throws NoContainTenantException { | ||
| 379 | - this.checkTenantInfoFromCondition(condition); | 353 | + public Map<String, Object> findPageByCondition(List<Object[]> condition, String sortCondition, int page, int pageSize, Long tenantId){ |
| 380 | StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()); | 354 | StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()); |
| 381 | StringBuffer pql = new StringBuffer(sql.toString()); | 355 | StringBuffer pql = new StringBuffer(sql.toString()); |
| 382 | StringBuffer sqlCount = new StringBuffer("SELECT COUNT(1) rowCount FROM "+this.getTableSql()); | 356 | StringBuffer sqlCount = new StringBuffer("SELECT COUNT(1) rowCount FROM "+this.getTableSql()); |
| 383 | - | 357 | + condition.add(new Object[] {"tenant_id", "=", tenantId}); |
| 384 | List<Object> count_list = new ArrayList<Object>(); | 358 | List<Object> count_list = new ArrayList<Object>(); |
| 385 | List<Object> page_list = new ArrayList<Object>(); | 359 | List<Object> page_list = new ArrayList<Object>(); |
| 386 | this.appendWhereConditionForCount(sqlCount, condition); | 360 | this.appendWhereConditionForCount(sqlCount, condition); |
| @@ -404,10 +378,9 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -404,10 +378,9 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 404 | } | 378 | } |
| 405 | 379 | ||
| 406 | @Override | 380 | @Override |
| 407 | - public Map<String, Object> findPageBySql(String sqlCondition, int page, int pageSize) throws NoContainTenantException { | ||
| 408 | - this.checkTenantInfoFromSql(sqlCondition); | ||
| 409 | - StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()+" WHERE " + sqlCondition ); | ||
| 410 | - StringBuffer sqlCount = new StringBuffer("SELECT count(1) rowCount FROM "+this.getTableSql()+" WHERE " + sqlCondition); | 381 | + public Map<String, Object> findPageBySql(String sqlCondition, int page, int pageSize, Long tenantId){ |
| 382 | + StringBuffer sql = new StringBuffer("SELECT "+this.tableFieldNameListGapWithComma+" FROM "+this.getTableSql()+" WHERE tenant_id=" + tenantId + " and " + sqlCondition ); | ||
| 383 | + StringBuffer sqlCount = new StringBuffer("SELECT count(1) rowCount FROM "+this.getTableSql()+" WHERE tenant_id=" + tenantId + " and " + sqlCondition); | ||
| 411 | sql.append(" limit ?, ?"); | 384 | sql.append(" limit ?, ?"); |
| 412 | List<Object> page_list = new ArrayList<Object>(); | 385 | List<Object> page_list = new ArrayList<Object>(); |
| 413 | page_list.add((page - 1) * pageSize); | 386 | page_list.add((page - 1) * pageSize); |
| @@ -498,35 +471,34 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -498,35 +471,34 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 498 | } | 471 | } |
| 499 | 472 | ||
| 500 | @Override | 473 | @Override |
| 501 | - public int deleteEntityByCondition(List<Object[]> condition) throws NoContainTenantException { | 474 | + public int deleteEntityByCondition(List<Object[]> condition, Long tenantId){ |
| 502 | if (null == condition || condition.size() == 0) { | 475 | if (null == condition || condition.size() == 0) { |
| 503 | throw new RuntimeException("params[condition] is empty"); | 476 | throw new RuntimeException("params[condition] is empty"); |
| 504 | } | 477 | } |
| 505 | - this.checkTenantInfoFromCondition(condition); | ||
| 506 | 478 | ||
| 507 | List<Object> list = new ArrayList<Object>(); | 479 | List<Object> list = new ArrayList<Object>(); |
| 508 | StringBuffer sql = new StringBuffer("DELETE FROM "+this.getTableSql()+""); | 480 | StringBuffer sql = new StringBuffer("DELETE FROM "+this.getTableSql()+""); |
| 509 | StringBuffer pql = new StringBuffer(sql.toString()); | 481 | StringBuffer pql = new StringBuffer(sql.toString()); |
| 482 | + condition.add(new Object[] {"tenant_id", "=", tenantId}); | ||
| 510 | this.appendWhereCondition(sql, pql, list, condition); | 483 | this.appendWhereCondition(sql, pql, list, condition); |
| 511 | return jdbcTemplateWrite.update( sql.toString(), list.toArray()); | 484 | return jdbcTemplateWrite.update( sql.toString(), list.toArray()); |
| 512 | } | 485 | } |
| 513 | 486 | ||
| 514 | @Override | 487 | @Override |
| 515 | - public int deleteEntityBySql(String sqlCondition) throws NoContainTenantException { | 488 | + public int deleteEntityBySql(String sqlCondition, Long tenantId){ |
| 516 | if("".equals(sqlCondition.trim())) { | 489 | if("".equals(sqlCondition.trim())) { |
| 517 | throw new RuntimeException("params[sqlCondition] is empty"); | 490 | throw new RuntimeException("params[sqlCondition] is empty"); |
| 518 | } | 491 | } |
| 519 | - this.checkTenantInfoFromSql(sqlCondition); | ||
| 520 | - return jdbcTemplateWrite.update( "DELETE FROM "+this.getTableSql()+" WHERE " + sqlCondition); | 492 | + return jdbcTemplateWrite.update( "DELETE FROM "+this.getTableSql()+" WHERE tenant_id="+tenantId + " and " + sqlCondition); |
| 521 | } | 493 | } |
| 522 | 494 | ||
| 523 | @Override | 495 | @Override |
| 524 | - public int deleteEntityList(List<ID> idList, Long tenantId) throws NoContainTenantException { | 496 | + public int deleteEntityList(List<ID> idList, Long tenantId){ |
| 525 | StringBuffer idSb = new StringBuffer(); | 497 | StringBuffer idSb = new StringBuffer(); |
| 526 | for(ID id: idList) { | 498 | for(ID id: idList) { |
| 527 | idSb.append(id); | 499 | idSb.append(id); |
| 528 | } | 500 | } |
| 529 | - return this.deleteEntityBySql(this.idTableFieldName + " in ("+idSb.toString().substring(0, idSb.length()-1)+") and tenant_id="+tenantId); | 501 | + return this.deleteEntityBySql(this.idTableFieldName + " in ("+idSb.toString().substring(0, idSb.length()-1)+") and tenant_id="+tenantId, tenantId); |
| 530 | } | 502 | } |
| 531 | 503 | ||
| 532 | @Override | 504 | @Override |
| @@ -550,20 +522,20 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -550,20 +522,20 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 550 | } | 522 | } |
| 551 | 523 | ||
| 552 | @Override | 524 | @Override |
| 553 | - public int updateEntityByCondition(List<Object[]> updateObj, List<Object[]> condition) throws NoContainTenantException { | 525 | + public int updateEntityByCondition(List<Object[]> updateObj, List<Object[]> condition, Long tenantId){ |
| 554 | if (null == updateObj || updateObj.size() == 0) { | 526 | if (null == updateObj || updateObj.size() == 0) { |
| 555 | throw new RuntimeException("params[updateObj] is empty"); | 527 | throw new RuntimeException("params[updateObj] is empty"); |
| 556 | } | 528 | } |
| 557 | if (null == condition || condition.size() == 0) { | 529 | if (null == condition || condition.size() == 0) { |
| 558 | throw new RuntimeException("params[condition] is empty"); | 530 | throw new RuntimeException("params[condition] is empty"); |
| 559 | } | 531 | } |
| 560 | - this.checkTenantInfoFromCondition(condition); | ||
| 561 | 532 | ||
| 562 | StringBuffer sql = new StringBuffer("UPDATE "+this.getTableSql()+" SET"); | 533 | StringBuffer sql = new StringBuffer("UPDATE "+this.getTableSql()+" SET"); |
| 563 | StringBuffer pql = new StringBuffer(sql.toString()); | 534 | StringBuffer pql = new StringBuffer(sql.toString()); |
| 564 | List<Object> list = new ArrayList<Object>(); | 535 | List<Object> list = new ArrayList<Object>(); |
| 565 | this.appendSetSql(sql, pql, list, updateObj); | 536 | this.appendSetSql(sql, pql, list, updateObj); |
| 566 | 537 | ||
| 538 | + condition.add(new Object[] {"tenant_id", "=", tenantId}); | ||
| 567 | StringBuffer where = new StringBuffer(""); | 539 | StringBuffer where = new StringBuffer(""); |
| 568 | StringBuffer pwhere = new StringBuffer(""); | 540 | StringBuffer pwhere = new StringBuffer(""); |
| 569 | this.appendWhereCondition(where, pwhere, list, condition); | 541 | this.appendWhereCondition(where, pwhere, list, condition); |
| @@ -573,38 +545,36 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | @@ -573,38 +545,36 @@ public class CustomJdbcTemplateWrapperTenant<T, ID extends Serializable> impleme | ||
| 573 | } | 545 | } |
| 574 | 546 | ||
| 575 | @Override | 547 | @Override |
| 576 | - public int updateEntityBySql(List<Object[]> updateObj, String sqlCondition) throws NoContainTenantException { | 548 | + public int updateEntityBySql(List<Object[]> updateObj, String sqlCondition, Long tenantId){ |
| 577 | if (null == updateObj || updateObj.size() == 0) { | 549 | if (null == updateObj || updateObj.size() == 0) { |
| 578 | throw new RuntimeException("params[updateObj] is empty"); | 550 | throw new RuntimeException("params[updateObj] is empty"); |
| 579 | } | 551 | } |
| 580 | if ("".equals(sqlCondition)) { | 552 | if ("".equals(sqlCondition)) { |
| 581 | throw new RuntimeException("params[sqlCondition] is empty"); | 553 | throw new RuntimeException("params[sqlCondition] is empty"); |
| 582 | } | 554 | } |
| 583 | - this.checkTenantInfoFromSql(sqlCondition); | ||
| 584 | 555 | ||
| 585 | StringBuffer sql = new StringBuffer("UPDATE "+this.getTableSql()+" SET"); | 556 | StringBuffer sql = new StringBuffer("UPDATE "+this.getTableSql()+" SET"); |
| 586 | StringBuffer pql = new StringBuffer(sql.toString()); | 557 | StringBuffer pql = new StringBuffer(sql.toString()); |
| 587 | List<Object> list = new ArrayList<Object>(); | 558 | List<Object> list = new ArrayList<Object>(); |
| 588 | this.appendSetSql(sql, pql, list, updateObj); | 559 | this.appendSetSql(sql, pql, list, updateObj); |
| 589 | 560 | ||
| 590 | - String updateSql = sql.toString().substring(0, sql.length()-1) + " WHERE "+sqlCondition; | 561 | + String updateSql = sql.toString().substring(0, sql.length()-1) + " WHERE tenant_id="+tenantId+" and "+sqlCondition; |
| 591 | return jdbcTemplateWrite.update(updateSql, list.toArray()); | 562 | return jdbcTemplateWrite.update(updateSql, list.toArray()); |
| 592 | } | 563 | } |
| 593 | 564 | ||
| 594 | @Override | 565 | @Override |
| 595 | - public Map<String, Object> getPageData(String coreSql, String orderByPartSql, Integer page, Integer pageSize) throws NoContainTenantException { | ||
| 596 | - this.checkTenantInfoFromSql(coreSql); | 566 | + public Map<String, Object> getPageData(String coreSql, String orderByPartSql, Integer page, Integer pageSize, Long tenantId){ |
| 597 | try { | 567 | try { |
| 598 | String[] splitedSql = UtilsSql.splitCoreSql(coreSql); | 568 | String[] splitedSql = UtilsSql.splitCoreSql(coreSql); |
| 599 | - return this.getPageData(splitedSql[0], splitedSql[1], orderByPartSql, page, pageSize); | 569 | + return this.getPageData(splitedSql[0], splitedSql[1], orderByPartSql, page, pageSize, tenantId); |
| 600 | }catch (Exception e) { | 570 | }catch (Exception e) { |
| 601 | return UtilsSql.createPage(page, pageSize, 0, new ArrayList<Object>()); | 571 | return UtilsSql.createPage(page, pageSize, 0, new ArrayList<Object>()); |
| 602 | } | 572 | } |
| 603 | } | 573 | } |
| 604 | 574 | ||
| 605 | @Override | 575 | @Override |
| 606 | - public Map<String, Object> getPageData(String selectSql, String fromAndWhereSql, String orderByPartSql, Integer page, Integer pageSize) throws NoContainTenantException { | ||
| 607 | - this.checkTenantInfoFromSql(fromAndWhereSql); | 576 | + public Map<String, Object> getPageData(String selectSql, String fromAndWhereSql, String orderByPartSql, Integer page, Integer pageSize, Long tenantId){ |
| 577 | + fromAndWhereSql = fromAndWhereSql + " and tenant_id="+tenantId; | ||
| 608 | 578 | ||
| 609 | //构造查询语句 | 579 | //构造查询语句 |
| 610 | String querySql = selectSql+" "+fromAndWhereSql+" "+orderByPartSql+" "+UtilsSql.getLimitCondition(page, pageSize); | 580 | String querySql = selectSql+" "+fromAndWhereSql+" "+orderByPartSql+" "+UtilsSql.getLimitCondition(page, pageSize); |
src/main/java/com/taover/repository/JdbcRepositoryWrapperTenant.java
| @@ -27,40 +27,40 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | @@ -27,40 +27,40 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | ||
| 27 | * Object[]数组长度是3 | 27 | * Object[]数组长度是3 |
| 28 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 | 28 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 |
| 29 | */ | 29 | */ |
| 30 | - public T findEntityByCondition(List<Object[]> condition) throws NotFoundException,MultiRowException,NoContainTenantException; | 30 | + public T findEntityByCondition(List<Object[]> condition, Long tenantId) throws NotFoundException,MultiRowException,NoContainTenantException; |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * 根据条件sql查询 | 33 | * 根据条件sql查询 |
| 34 | * sqlCondition 为where 后面的条件。 | 34 | * sqlCondition 为where 后面的条件。 |
| 35 | */ | 35 | */ |
| 36 | - public T findEntityBySql(String sqlCondition) throws NotFoundException,MultiRowException,NoContainTenantException; | 36 | + public T findEntityBySql(String sqlCondition, Long tenantId) throws NotFoundException,MultiRowException,NoContainTenantException; |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * 根据条件List<Object[]>查询 | 39 | * 根据条件List<Object[]>查询 |
| 40 | * Object[]数组长度是3 | 40 | * Object[]数组长度是3 |
| 41 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 | 41 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 |
| 42 | */ | 42 | */ |
| 43 | - public List<T> findListByCondition(List<Object[]> condition) throws NoContainTenantException; | 43 | + public List<T> findListByCondition(List<Object[]> condition, Long tenantId); |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * 根据条件List<Object[]>查询 | 46 | * 根据条件List<Object[]>查询 |
| 47 | * Object[]数组长度是3 | 47 | * Object[]数组长度是3 |
| 48 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 | 48 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 |
| 49 | */ | 49 | */ |
| 50 | - public List<T> findListByCondition(List<Object[]> condition, String sortCondition) throws NoContainTenantException; | 50 | + public List<T> findListByCondition(List<Object[]> condition, String sortCondition, Long tenantId); |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * 根据条件sql查询 | 53 | * 根据条件sql查询 |
| 54 | * sqlCondition 为where 后面的条件。 | 54 | * sqlCondition 为where 后面的条件。 |
| 55 | */ | 55 | */ |
| 56 | - public List<T> findListBySql(String sqlCondition) throws NoContainTenantException; | 56 | + public List<T> findListBySql(String sqlCondition, Long tenantId); |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | * 按条件分页查询 | 59 | * 按条件分页查询 |
| 60 | * Object[]数组长度是3 | 60 | * Object[]数组长度是3 |
| 61 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 | 61 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 |
| 62 | */ | 62 | */ |
| 63 | - public Map<String, Object> findPageByCondition(List<Object[]> condition, int page, int pageSize) throws NoContainTenantException; | 63 | + public Map<String, Object> findPageByCondition(List<Object[]> condition, int page, int pageSize, Long tenantId); |
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| 66 | * 按条件分页查询 | 66 | * 按条件分页查询 |
| @@ -69,12 +69,12 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | @@ -69,12 +69,12 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | ||
| 69 | * boolean isUseCache, 是否用缓存,默认用。 | 69 | * boolean isUseCache, 是否用缓存,默认用。 |
| 70 | * boolean isAddCache, 是否添加缓存,默认添加。 | 70 | * boolean isAddCache, 是否添加缓存,默认添加。 |
| 71 | */ | 71 | */ |
| 72 | - public Map<String, Object> findPageByCondition(List<Object[]> condition, String sortCondition, int page, int pageSize) throws NoContainTenantException; | 72 | + public Map<String, Object> findPageByCondition(List<Object[]> condition, String sortCondition, int page, int pageSize, Long tenantId); |
| 73 | 73 | ||
| 74 | /** | 74 | /** |
| 75 | * 按sql分页查询, sqlCondition为where 后条件sql | 75 | * 按sql分页查询, sqlCondition为where 后条件sql |
| 76 | */ | 76 | */ |
| 77 | - public Map<String, Object> findPageBySql(String sqlCondition, int page, int pageSize) throws NoContainTenantException; | 77 | + public Map<String, Object> findPageBySql(String sqlCondition, int page, int pageSize, Long tenantId); |
| 78 | 78 | ||
| 79 | /** | 79 | /** |
| 80 | * 添加 | 80 | * 添加 |
| @@ -97,20 +97,20 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | @@ -97,20 +97,20 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | ||
| 97 | * Object[]数组长度是3 | 97 | * Object[]数组长度是3 |
| 98 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 | 98 | * Object[], 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 |
| 99 | */ | 99 | */ |
| 100 | - public int deleteEntityByCondition(List<Object[]> condition) throws NoContainTenantException; | 100 | + public int deleteEntityByCondition(List<Object[]> condition, Long tenantId); |
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * 删除按condition条件 | 103 | * 删除按condition条件 |
| 104 | * 建议使用deleteTByCondition(List<Object[]> condition), 如果removeTByCondition(List<Object[]> condition)满足不了where条件可以使用此方法。 | 104 | * 建议使用deleteTByCondition(List<Object[]> condition), 如果removeTByCondition(List<Object[]> condition)满足不了where条件可以使用此方法。 |
| 105 | * condition为where后面的条件,condition不能为空。 | 105 | * condition为where后面的条件,condition不能为空。 |
| 106 | */ | 106 | */ |
| 107 | - public int deleteEntityBySql(String sqlCondition) throws NoContainTenantException; | 107 | + public int deleteEntityBySql(String sqlCondition, Long tenantId); |
| 108 | 108 | ||
| 109 | /** | 109 | /** |
| 110 | * 根据list对象逐个删除。 | 110 | * 根据list对象逐个删除。 |
| 111 | * @throws NoContainTenantException | 111 | * @throws NoContainTenantException |
| 112 | */ | 112 | */ |
| 113 | - public int deleteEntityList(List<ID> idList, Long tenantId) throws NoContainTenantException; | 113 | + public int deleteEntityList(List<ID> idList, Long tenantId); |
| 114 | 114 | ||
| 115 | /** | 115 | /** |
| 116 | * 根据ID修改指定的值 | 116 | * 根据ID修改指定的值 |
| @@ -121,13 +121,13 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | @@ -121,13 +121,13 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | ||
| 121 | * List<Object[]> updateObj 要修改成的值,数组长度为2,第一个值为列名,第二个值是要改成的值。 | 121 | * List<Object[]> updateObj 要修改成的值,数组长度为2,第一个值为列名,第二个值是要改成的值。 |
| 122 | * List<Object[]> condition 修改的条件, 数组长度是3, 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 | 122 | * List<Object[]> condition 修改的条件, 数组长度是3, 第一个参数是列名,第二个参数是操作符,第三个参数是查询条件的值。 |
| 123 | */ | 123 | */ |
| 124 | - public int updateEntityByCondition(List<Object[]> updateObj, List<Object[]> condition) throws NoContainTenantException; | 124 | + public int updateEntityByCondition(List<Object[]> updateObj, List<Object[]> condition, Long tenantId); |
| 125 | 125 | ||
| 126 | /** | 126 | /** |
| 127 | * List<Object[]> updateObj 要修改成的值,数组长度为2,第一个值为列名,第二个值是要改成的值。 | 127 | * List<Object[]> updateObj 要修改成的值,数组长度为2,第一个值为列名,第二个值是要改成的值。 |
| 128 | * String sqlCondition 修改的条件。 | 128 | * String sqlCondition 修改的条件。 |
| 129 | */ | 129 | */ |
| 130 | - public int updateEntityBySql(List<Object[]> updateObj, String sqlCondition) throws NoContainTenantException; | 130 | + public int updateEntityBySql(List<Object[]> updateObj, String sqlCondition, Long tenantId); |
| 131 | 131 | ||
| 132 | /** | 132 | /** |
| 133 | * 获取分页数据 | 133 | * 获取分页数据 |
| @@ -137,7 +137,7 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | @@ -137,7 +137,7 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | ||
| 137 | * @param pageSize | 137 | * @param pageSize |
| 138 | * @return | 138 | * @return |
| 139 | */ | 139 | */ |
| 140 | - public Map<String, Object> getPageData(String coreSql, String orderByPartSql, Integer page, Integer pageSize) throws NoContainTenantException; | 140 | + public Map<String, Object> getPageData(String coreSql, String orderByPartSql, Integer page, Integer pageSize, Long tenantId); |
| 141 | 141 | ||
| 142 | /** | 142 | /** |
| 143 | * 获取分页数据 | 143 | * 获取分页数据 |
| @@ -148,5 +148,5 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | @@ -148,5 +148,5 @@ public interface JdbcRepositoryWrapperTenant<T, ID extends Serializable> { | ||
| 148 | * @param pageSize | 148 | * @param pageSize |
| 149 | * @return | 149 | * @return |
| 150 | */ | 150 | */ |
| 151 | - public Map<String, Object> getPageData(String selectSql, String fromAndWhereSql, String orderByPartSql, Integer page, Integer pageSize) throws NoContainTenantException; | 151 | + public Map<String, Object> getPageData(String selectSql, String fromAndWhereSql, String orderByPartSql, Integer page, Integer pageSize, Long tenantId); |
| 152 | } | 152 | } |