Commit 09c3c219 authored by liaozan's avatar liaozan 🏀

Support remove by bizId

parent d97dad96
......@@ -10,15 +10,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据 id 获取记录
*
* @param throwIfNotFound 未获取到记录时是否抛异常
*/
T getById(Long id, boolean throwIfNotFound);
/**
* 根据 id 获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
T getById(Long id, Supplier<? extends RuntimeException> notFoundSupplier);
......@@ -29,15 +25,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据 id 获取记录
*
* @param throwIfNotFound 未获取到记录时是否抛异常
*/
<V> V getById(Long id, SFunction<T, V> column, boolean throwIfNotFound);
/**
* 根据 id 获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
<V> V getById(Long id, SFunction<T, V> column, Supplier<? extends RuntimeException> notFoundSupplier);
......@@ -58,15 +50,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据业务主键获取记录
*
* @param throwsIfNotFound 未获取到记录时是否抛异常
*/
T getByBizId(Object bizId, boolean throwsIfNotFound);
/**
* 根据业务主键获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
T getByBizId(Object bizId, Supplier<? extends RuntimeException> notFoundSupplier);
......@@ -77,15 +65,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据业务主键获取记录
*
* @param throwsIfNotFound 未获取到记录时是否抛异常
*/
<V> V getByBizId(Object bizId, SFunction<T, V> column, boolean throwsIfNotFound);
/**
* 根据业务主键获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
<V> V getByBizId(Object bizId, SFunction<T, V> column, Supplier<? extends RuntimeException> notFoundSupplier);
......@@ -129,4 +113,14 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
*/
boolean updateBatchByIdsWithNull(Collection<T> entityList, int batchSize);
/**
* 根据业务主键删除
*/
<K> boolean removeByBizId(K bizId);
/**
* 根据业务主键删除
*/
<K> boolean removeBatchByBizIds(Collection<K> bizIds);
}
......@@ -222,6 +222,19 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
});
}
@Override
public <K> boolean removeByBizId(K bizId) {
return update().eq(getBidColumnField().getColumnName(), bizId).remove();
}
@Override
public <K> boolean removeBatchByBizIds(Collection<K> bizIds) {
if (isEmpty(bizIds)) {
return false;
}
return update().in(getBidColumnField().getColumnName(), bizIds).remove();
}
@Override
public void afterPropertiesSet() {
ReflectionUtils.doWithFields(entityClass, bizId -> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment