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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user