add example Logic
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.spring.mapper;
|
||||
|
||||
import com.imyeyu.spring.bean.Logic;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.DynamicTableSQLProvider;
|
||||
@@ -93,8 +94,20 @@ public interface DynamicTableMapper<T, P> {
|
||||
* @param entity 示例对象
|
||||
* @return 数据对象
|
||||
*/
|
||||
default T selectByExample(String tableName, T entity) {
|
||||
return selectByExample(tableName, entity, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例查询单条数据
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param entity 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
* @return 数据对象
|
||||
*/
|
||||
@SelectProvider(type = DynamicTableSQLProvider.class, method = "selectByExample")
|
||||
T selectByExample(@Param("tableName") String tableName, @Param("entity") T entity);
|
||||
T selectByExample(@Param("tableName") String tableName, @Param("entity") T entity, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 根据示例查询全部数据
|
||||
@@ -103,8 +116,20 @@ public interface DynamicTableMapper<T, P> {
|
||||
* @param entity 示例对象
|
||||
* @return 数据列表
|
||||
*/
|
||||
default List<T> selectAllByExample(String tableName, T entity) {
|
||||
return selectAllByExample(tableName, entity, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例查询全部数据
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param entity 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
* @return 数据列表
|
||||
*/
|
||||
@SelectProvider(type = DynamicTableSQLProvider.class, method = "selectAllByExample")
|
||||
List<T> selectAllByExample(@Param("tableName") String tableName, @Param("entity") T entity);
|
||||
List<T> selectAllByExample(@Param("tableName") String tableName, @Param("entity") T entity, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
@@ -139,8 +164,19 @@ public interface DynamicTableMapper<T, P> {
|
||||
* @param tableName 表名
|
||||
* @param entity 示例对象
|
||||
*/
|
||||
default void deleteAllByExample(String tableName, T entity) {
|
||||
deleteAllByExample(tableName, entity, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例批量逻辑删除
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param entity 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
*/
|
||||
@UpdateProvider(type = DynamicTableSQLProvider.class, method = "deleteAllByExample")
|
||||
void deleteAllByExample(@Param("tableName") String tableName, @Param("entity") T entity);
|
||||
void deleteAllByExample(@Param("tableName") String tableName, @Param("entity") T entity, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 销毁(物理删除)
|
||||
@@ -157,6 +193,17 @@ public interface DynamicTableMapper<T, P> {
|
||||
* @param tableName 表名
|
||||
* @param entity 示例对象
|
||||
*/
|
||||
@UpdateProvider(type = DynamicTableSQLProvider.class, method = "destroyAllByExample")
|
||||
void destroyAllByExample(@Param("tableName") String tableName, @Param("entity") T entity);
|
||||
default void destroyAllByExample(String tableName, T entity) {
|
||||
destroyAllByExample(tableName, entity, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例批量销毁(物理删除)
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param entity 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
*/
|
||||
@DeleteProvider(type = DynamicTableSQLProvider.class, method = "destroyAllByExample")
|
||||
void destroyAllByExample(@Param("tableName") String tableName, @Param("entity") T entity, @Param("logic") Logic logic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user