|
@@ -27,6 +27,8 @@ import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.update.ChainUpdate;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.kotlin.KtQueryChainWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.kotlin.KtUpdateChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.ChainWrappers;
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -96,7 +98,7 @@ public interface IService<T> {
|
|
|
* @param batchSize 每次的数量
|
|
|
*/
|
|
|
boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 根据 ID 删除
|
|
|
*
|
|
@@ -189,7 +191,7 @@ public interface IService<T> {
|
|
|
* @param entity 实体对象
|
|
|
*/
|
|
|
boolean saveOrUpdate(T entity);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 根据 ID 查询
|
|
|
*
|
|
@@ -386,6 +388,13 @@ public interface IService<T> {
|
|
|
*/
|
|
|
BaseMapper<T> getBaseMapper();
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取 entity 的 class
|
|
|
+ *
|
|
|
+ * @return {@link Class<T>}
|
|
|
+ */
|
|
|
+ Class<T> getEntityClass();
|
|
|
+
|
|
|
/**
|
|
|
* 以下的方法使用介绍:
|
|
|
*
|
|
@@ -422,6 +431,26 @@ public interface IService<T> {
|
|
|
return ChainWrappers.lambdaQueryChain(getBaseMapper());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 链式查询 lambda 式
|
|
|
+ * kotlin 使用
|
|
|
+ *
|
|
|
+ * @return KtQueryWrapper 的包装类
|
|
|
+ */
|
|
|
+ default KtQueryChainWrapper<T> ktQuery() {
|
|
|
+ return ChainWrappers.ktQueryChain(getBaseMapper(), getEntityClass());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 链式查询 lambda 式
|
|
|
+ * kotlin 使用
|
|
|
+ *
|
|
|
+ * @return KtQueryWrapper 的包装类
|
|
|
+ */
|
|
|
+ default KtUpdateChainWrapper<T> ktUpdate() {
|
|
|
+ return ChainWrappers.ktUpdateChain(getBaseMapper(), getEntityClass());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 链式更改 普通
|
|
|
*
|