Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
javaofferss committed May 21, 2023
2 parents 83a64dc + 29dc502 commit 8a782fc
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ public static <E> ArrayList<E> newArrayList() {
return new ArrayList<E>();
}

// ArrayList
public static <E> ArrayList<E> newArrayList(E... es) {
ArrayList<E> list = new ArrayList<>();
if(es != null){
for(E e : es){
if (e != null){
list.add(e);
}
}
}
return list;
}


// LinkedList
public static <E> LinkedList<E> newLinkedList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int[] batchUpdate(String sql, final BatchPreparedStatementSetter pss) throws Dat
public List<Serializable> batchInsert(String sql, List<Map<String, Object>> paramMap) {

SQL pss = SQLParse.parseSqlParams(sql, paramMap);
LinkedList<Serializable> ids = new LinkedList<>();
List<Serializable> ids = new ArrayList<>();
jdbcTemplate.execute(new InsertPreparedStatementCreator(pss.getSql()), (PreparedStatementCallback<List<Serializable>>) ps -> {
try {
int batchSize = pss.getBatchSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand All @@ -38,7 +39,7 @@ public List<Id> exs() {
BaseBatisImpl instance = BaseBatisImpl.getInstance((HeadCondition) conditions.pollFirst());
MoreSQLInfo sqlInfos = (MoreSQLInfo)ConditionParse.conditionParse(conditions);
List<SQLInfo> sqlInfosList = sqlInfos.getSqlInfos();
List<Id> list = new ArrayList<>(sqlInfosList.size());
List<Id> list = new ArrayList<>();
sqlInfosList.forEach(sqlInfo -> {
JqlLogger.log.info("SQL: {}", sqlInfo.getSql());
JqlLogger.log.info("PAM: {}", sqlInfo.getParams());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,56 @@ public interface GeneralFun<T, C extends GetterFun<T, Object>, V> extends BaseMa
* save or modify.
* sql : insert into on duplicate key update
* @param model class
* @return primary key id
* @return primary key id. or modify count num. so return void
*/
public List<Id> saveOrModify(T model);
public void saveOrModify(T model);

/**
* save or update.
* By the @UniqueId field to query data, if the query not null then to update, or to insert.
* @param model class
* @return primary key id. or modify count num. so return void
*/
public void saveOrUpdate(T model);

/**
* save or replace
* sql: replace into
* @param model class
* @return primary key id
* @return primary key id. or modify count num. so return void
*/
public List<Id> saveOrReplace(T model);
public void saveOrReplace(T model);

/**
* save model
* @param models class
* @return primary key id
* @return primary key ids
*/
public List<Id> saveBatch(Collection<T> models);

/**
* save or modify.
* sql : insert into on duplicate key update
* @param models class
* @return primary key id
* @return primary key id. or modify count num. so return void
*/
public void saveOrModify(Collection<T> models);

/**
* save or update.
* By the @UniqueId field to query data, if the query not null then to update, or to insert.
* @param models class
* @return primary key id. or modify count num. so return void
*/
public List<Id> saveOrModify(Collection<T> models);
public void saveOrUpdate(Collection<T> models);

/**
* save or replace
* sql: replace into
* @param models class
* @return primary key id
* @return primary key id. or modify count num. so return void
*/
public List<Id> saveOrReplace(Collection<T> models);
public void saveOrReplace(Collection<T> models);

/**
* delete model.Where conditions will be generated based on properties of the model
Expand Down Expand Up @@ -96,12 +112,29 @@ public interface GeneralFun<T, C extends GetterFun<T, Object>, V> extends BaseMa
public int modifyById(T model);

/**
* batch update
* Update the model, note that the update condition is the property marked with the Unique annotation.
* Only properties with values ​​are updated.
* In other words, the @BaseUnique annotation will generate a Where condition, and the field will
* generate a set statement
* @param model model
* @return The number of bars affected by the update
*/
public int updateById(T model);

/**
* batch update. Empty fields will not be able to update the database.
* @param models models
* @return Affect the number of bars
*/
public int modifyBatchById(Collection<T> models);

/**
* batch update ,Will update the database if the field is empty.
* @param models models
* @return Affect the number of bars
*/
public int updateBatchById(Collection<T> models);

/**
* Query the main model, be careful not to include child models. Non-null properties will generate a where statement.
* <>Note that properties such as Collection<Model> will be ignored, even if they are not null </>
Expand Down Expand Up @@ -182,43 +215,43 @@ public interface GeneralFun<T, C extends GetterFun<T, Object>, V> extends BaseMa

/**
* The number of statistical tables
* @return
* @return not null
*/
public long count();
public Number count();

/**
* The number of statistical tables, through the specified field
* @return
* @return not null
*/
public long count(C c);
public Number count(C c);

/**
* The number of statistical tables, through the specified field
* Statistical results after deduplication. count(DISTINCT c)
* @return
* @return not null
*/
public long countDistinct(C c);
public Number countDistinct(C c);


/**
* The number of statistical tables. Will use the model as the where condition
* @return
* @return not null
*/
public long count(T model);
public Number count(T model);

/**
* The number of statistical tables, through the specified field.
* Will use the model as the where condition
* @return
* @return not null
*/
public long count(C c,T model);
public Number count(C c,T model);

/**
* The number of statistical tables, through the specified field
* Statistical results after deduplication. count(DISTINCT c).
* Will use the model as the where condition
* @return
* @return not null
*/
public long countDistinct(C c,T model);
public Number countDistinct(C c,T model);

}
Loading

0 comments on commit 8a782fc

Please sign in to comment.