diff --git a/admin4j-dependencies/pom.xml b/admin4j-dependencies/pom.xml
index dc8e236..b3347dd 100644
--- a/admin4j-dependencies/pom.xml
+++ b/admin4j-dependencies/pom.xml
@@ -57,7 +57,6 @@
0.1.55
4.1.86.Final
2.6.6
- 4.11.0
1.4.0
1.5.6
2.12.2
@@ -612,12 +611,6 @@
${netty-all.version}
-
- com.squareup.okhttp3
- okhttp
- ${okhttp3.version}
-
-
com.xkcoding.justauth
diff --git a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandBatchService.java b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandBatchService.java
index 9efb1d2..dbfe50c 100644
--- a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandBatchService.java
+++ b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandBatchService.java
@@ -13,11 +13,6 @@
*/
public interface ICommandBatchService {
- /**
- * 默认批次提交数量
- */
- int DEFAULT_BATCH_SIZE = 1000;
-
/**
* 插入(批量)
@@ -25,9 +20,7 @@ public interface ICommandBatchService {
* @param entityList 实体对象集合
*/
@Transactional(rollbackFor = Exception.class)
- default boolean saveBatch(Collection entityList) {
- return saveBatch(entityList, DEFAULT_BATCH_SIZE);
- }
+ boolean saveBatch(Collection entityList);
/**
@@ -45,9 +38,7 @@ default boolean saveBatch(Collection entityList) {
* @param entityList 实体对象集合
*/
@Transactional(rollbackFor = Exception.class)
- default boolean saveOrUpdateBatch(Collection entityList) {
- return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
- }
+ boolean saveOrUpdateBatch(Collection entityList);
/**
@@ -67,9 +58,7 @@ default boolean saveOrUpdateBatch(Collection entityList) {
* @param entityList 实体对象集合
*/
@Transactional(rollbackFor = Exception.class)
- default boolean updateBatchById(Collection entityList) {
- return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
- }
+ boolean updateBatchById(Collection entityList);
/**
* 根据ID 批量更新
@@ -108,9 +97,7 @@ default boolean updateBatchById(Collection entityList) {
* @since 3.5.0
*/
@Transactional(rollbackFor = Exception.class)
- default boolean removeBatchByIds(Collection> list) {
- return removeBatchByIds(list, DEFAULT_BATCH_SIZE);
- }
+ boolean removeBatchByIds(Collection> list);
/**
* 批量删除(jdbc批量提交)
@@ -133,9 +120,7 @@ default boolean removeBatchByIds(Collection> list) {
* @since 3.5.0
*/
@Transactional(rollbackFor = Exception.class)
- default boolean removeBatchByIds(Collection> list, boolean useFill) {
- return removeBatchByIds(list, DEFAULT_BATCH_SIZE, useFill);
- }
+ boolean removeBatchByIds(Collection> list, boolean useFill);
/**
@@ -147,7 +132,5 @@ default boolean removeBatchByIds(Collection> list, boolean useFill) {
* @return 删除结果
* @since 3.5.0
*/
- default boolean removeBatchByIds(Collection> list, int batchSize, boolean useFill) {
- throw new UnsupportedOperationException("不支持的方法!");
- }
+ boolean removeBatchByIds(Collection> list, int batchSize, boolean useFill);
}
diff --git a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandService.java b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandService.java
index d412193..ec835bb 100644
--- a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandService.java
+++ b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/ICommandService.java
@@ -1,7 +1,6 @@
package com.admin4j.framework.mp.service;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import java.io.Serializable;
@@ -27,9 +26,7 @@ public interface ICommandService {
*
* @param entity 实体对象
*/
- default boolean save(T entity) {
- return SqlHelper.retBool(getBaseMapper().insert(entity));
- }
+ boolean save(T entity);
/**
@@ -47,9 +44,7 @@ default boolean save(T entity) {
*
* @param entity 实体对象
*/
- default boolean updateById(T entity) {
- return SqlHelper.retBool(getBaseMapper().updateById(entity));
- }
+ boolean updateById(T entity);
//---------------------------------------------------------------- remove ------------------------
@@ -59,9 +54,7 @@ default boolean updateById(T entity) {
*
* @param id 主键ID
*/
- default boolean removeById(Serializable id) {
- return SqlHelper.retBool(getBaseMapper().deleteById(id));
- }
+ boolean removeById(Serializable id);
/**
* 根据 ID 删除
@@ -71,7 +64,5 @@ default boolean removeById(Serializable id) {
* @return 删除结果
* @since 3.5.0
*/
- default boolean removeById(Serializable id, boolean useFill) {
- throw new UnsupportedOperationException("不支持的方法!");
- }
+ boolean removeById(Serializable id, boolean useFill);
}
diff --git a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/BizServiceImpl.java b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/BizServiceImpl.java
index ae54676..499400d 100644
--- a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/BizServiceImpl.java
+++ b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/BizServiceImpl.java
@@ -143,6 +143,15 @@ public boolean removeById(Serializable id) {
return true;
}
+ /**
+ * 根据 entity 条件,删除记录
+ *
+ * @param queryWrapper 实体包装类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
+ */
+ protected boolean remove(Wrapper queryWrapper) {
+ return SqlHelper.retBool(getBaseMapper().delete(queryWrapper));
+ }
+
// ---------------------------------------------------------------- exist ----------------------------------------------------------------
/**
diff --git a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/CommandServiceImpl.java b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/CommandServiceImpl.java
index c4e2b8f..caf15f4 100644
--- a/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/CommandServiceImpl.java
+++ b/mybatis-plus-boot-starter/src/main/java/com/admin4j/framework/mp/service/impl/CommandServiceImpl.java
@@ -28,9 +28,9 @@
* @since 2023/8/17 11:04
*/
-public class CommandServiceImpl, T> extends QueryServiceImpl implements ICommandService, IBizService, ICommandBatchService {
-
+public class CommandServiceImpl, T> extends QueryServiceImpl implements ICommandService, ICommandBatchService, IBizService {
+ protected final static int DEFAULT_BATCH_SIZE = 1000;
protected Log log = LogFactory.getLog(getClass());
@@ -78,6 +78,26 @@ protected LambdaUpdateWrapper lambdaUpdate(T entity) {
return Wrappers.lambdaUpdate(entity);
}
+ /**
+ * 插入一条记录(选择字段,策略插入)
+ *
+ * @param entity 实体对象
+ */
+ @Override
+ public boolean save(T entity) {
+ return SqlHelper.retBool(getBaseMapper().insert(entity));
+ }
+
+ /**
+ * 插入(批量)
+ *
+ * @param entityList 实体对象集合
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public boolean saveBatch(Collection entityList) {
+ return saveBatch(entityList, DEFAULT_BATCH_SIZE);
+ }
+
/**
* 批量插入
@@ -87,7 +107,6 @@ protected LambdaUpdateWrapper lambdaUpdate(T entity) {
* @return ignore
*/
@Transactional(rollbackFor = Exception.class)
- @Override
public boolean saveBatch(Collection entityList, int batchSize) {
String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE);
return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
@@ -124,8 +143,26 @@ public boolean saveOrUpdate(T entity) {
return false;
}
+
+ /**
+ * 批量修改插入
+ *
+ * @param entityList 实体对象集合
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public boolean saveOrUpdateBatch(Collection entityList) {
+ return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
+ }
+
+ /**
+ * 批量修改插入
+ * Params:
+ *
+ * @param entityList 实体对象集合
+ * @param batchSize 每次的数量
+ * @return
+ */
@Transactional(rollbackFor = Exception.class)
- @Override
public boolean saveOrUpdateBatch(Collection entityList, int batchSize) {
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
@@ -142,8 +179,34 @@ public boolean saveOrUpdateBatch(Collection entityList, int batchSize) {
});
}
- @Transactional(rollbackFor = Exception.class)
+ /**
+ * 根据 ID 选择修改
+ *
+ * @param entity 实体对象
+ */
@Override
+ public boolean updateById(T entity) {
+ return SqlHelper.retBool(getBaseMapper().updateById(entity));
+ }
+
+ /**
+ * 根据ID 批量更新
+ *
+ * @param entityList 实体对象集合
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public boolean updateBatchById(Collection entityList) {
+ return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
+ }
+
+ /**
+ * 根据ID 批量更新
+ *
+ * @param entityList 实体对象集合
+ * @param batchSize 更新批次数量
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
public boolean updateBatchById(Collection entityList, int batchSize) {
String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID);
return executeBatch(entityList, batchSize, (sqlSession, entity) -> {
@@ -189,7 +252,6 @@ public boolean removeById(Serializable id) {
return SqlHelper.retBool(getBaseMapper().deleteById(id));
}
- @Override
@Transactional(rollbackFor = Exception.class)
public boolean removeByIds(Collection> list) {
if (CollectionUtils.isEmpty(list)) {
@@ -202,6 +264,19 @@ public boolean removeByIds(Collection> list) {
return SqlHelper.retBool(getBaseMapper().deleteBatchIds(list));
}
+ /**
+ * 批量删除(jdbc批量提交)
+ *
+ * @param list 主键ID或实体列表(主键ID类型必须与实体类型字段保持一致)
+ * @param useFill 是否启用填充(为true的情况,会将入参转换实体进行delete删除)
+ * @return 删除结果
+ * @since 3.5.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public boolean removeBatchByIds(Collection> list, boolean useFill) {
+ return removeBatchByIds(list, DEFAULT_BATCH_SIZE, useFill);
+ }
+
/**
* 批量删除
*
@@ -211,7 +286,6 @@ public boolean removeByIds(Collection> list) {
* @since 3.5.0
*/
@Transactional(rollbackFor = Exception.class)
- @Override
public boolean removeByIds(Collection> list, boolean useFill) {
if (CollectionUtils.isEmpty(list)) {
return false;
@@ -235,14 +309,34 @@ public boolean removeById(Serializable id, boolean useFill) {
return SqlHelper.retBool(getBaseMapper().deleteById(id));
}
- @Override
+
+ /**
+ * 批量删除(jdbc批量提交)
+ *
+ * @param list 主键ID或实体列表(主键ID类型必须与实体类型字段保持一致)
+ * @return 删除结果
+ * @since 3.5.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public boolean removeBatchByIds(Collection> list) {
+ return removeBatchByIds(list, DEFAULT_BATCH_SIZE);
+ }
+
+ /**
+ * 批量删除(jdbc批量提交)
+ *
+ * @param list 主键ID或实体列表
+ * @param batchSize 批次大小
+ * @return 删除结果
+ * @since 3.5.0
+ */
@Transactional(rollbackFor = Exception.class)
public boolean removeBatchByIds(Collection> list, int batchSize) {
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
return removeBatchByIds(list, batchSize, tableInfo.isWithLogicDelete() && tableInfo.isWithUpdateFill());
}
- @Override
+
@Transactional(rollbackFor = Exception.class)
public boolean removeBatchByIds(Collection> list, int batchSize, boolean useFill) {
String sqlStatement = getSqlStatement(SqlMethod.DELETE_BY_ID);