add example Logic
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
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.SQLProvider;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
import org.apache.ibatis.annotations.UpdateProvider;
|
||||
|
||||
@@ -111,8 +113,19 @@ public interface BaseMapper<T, P> {
|
||||
* @param t 示例对象
|
||||
* @return 数据对象
|
||||
*/
|
||||
default T selectByExample(T t) {
|
||||
return selectByExample(t, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例查询单条数据
|
||||
*
|
||||
* @param t 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
* @return 数据对象
|
||||
*/
|
||||
@SelectProvider(type = SQLProvider.class, method = "selectByExample")
|
||||
T selectByExample(T t);
|
||||
T selectByExample(@Param("entity") T t, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 根据示例查询全部数据
|
||||
@@ -120,8 +133,19 @@ public interface BaseMapper<T, P> {
|
||||
* @param t 示例对象
|
||||
* @return 数据列表
|
||||
*/
|
||||
default List<T> selectAllByExample(T t) {
|
||||
return selectAllByExample(t, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例查询全部数据
|
||||
*
|
||||
* @param t 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
* @return 数据列表
|
||||
*/
|
||||
@SelectProvider(type = SQLProvider.class, method = "selectAllByExample")
|
||||
List<T> selectAllByExample(T t);
|
||||
List<T> selectAllByExample(@Param("entity") T t, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
@@ -152,8 +176,18 @@ public interface BaseMapper<T, P> {
|
||||
*
|
||||
* @param t 示例对象
|
||||
*/
|
||||
default void deleteAllByExample(T t) {
|
||||
deleteAllByExample(t, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例批量逻辑删除
|
||||
*
|
||||
* @param t 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
*/
|
||||
@UpdateProvider(type = SQLProvider.class, method = "deleteAllByExample")
|
||||
void deleteAllByExample(T t);
|
||||
void deleteAllByExample(@Param("entity") T t, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 销毁(物理删除)
|
||||
@@ -168,6 +202,16 @@ public interface BaseMapper<T, P> {
|
||||
*
|
||||
* @param t 示例对象
|
||||
*/
|
||||
@UpdateProvider(type = SQLProvider.class, method = "destroyAllByExample")
|
||||
void destroyAllByExample(T t);
|
||||
default void destroyAllByExample(T t) {
|
||||
destroyAllByExample(t, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例批量销毁(物理删除)
|
||||
*
|
||||
* @param t 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
*/
|
||||
@DeleteProvider(type = SQLProvider.class, method = "destroyAllByExample")
|
||||
void destroyAllByExample(@Param("entity") T t, @Param("logic") Logic logic);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.imyeyu.spring.mapper;
|
||||
|
||||
import com.imyeyu.spring.bean.Logic;
|
||||
import com.imyeyu.spring.util.RawSQLProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,8 +40,19 @@ public interface RawMapper<T, P> {
|
||||
* @param t 示例对象
|
||||
* @return 数据对象
|
||||
*/
|
||||
default T selectByExampleRaw(T t) {
|
||||
return selectByExampleRaw(t, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例查询单条数据
|
||||
*
|
||||
* @param t 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
* @return 数据对象
|
||||
*/
|
||||
@SelectProvider(type = RawSQLProvider.class, method = "selectByExample")
|
||||
T selectByExampleRaw(T t);
|
||||
T selectByExampleRaw(@Param("entity") T t, @Param("logic") Logic logic);
|
||||
|
||||
/**
|
||||
* 根据示例查询全部数据
|
||||
@@ -47,6 +60,17 @@ public interface RawMapper<T, P> {
|
||||
* @param t 示例对象
|
||||
* @return 数据列表
|
||||
*/
|
||||
default List<T> selectAllByExampleRaw(T t) {
|
||||
return selectAllByExampleRaw(t, Logic.AND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例查询全部数据
|
||||
*
|
||||
* @param t 示例对象
|
||||
* @param logic 条件连接逻辑
|
||||
* @return 数据列表
|
||||
*/
|
||||
@SelectProvider(type = RawSQLProvider.class, method = "selectAllByExample")
|
||||
List<T> selectAllByExampleRaw(T t);
|
||||
List<T> selectAllByExampleRaw(@Param("entity") T t, @Param("logic") Logic logic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user