|
|
@@ -3,10 +3,18 @@ package cn.iocoder.yudao.framework.mybatis.core.service;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
|
|
+
|
|
|
import com.github.yulichang.base.MPJBaseService;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.PlusBaseMapperX;
|
|
|
+import cn.iocoder.yudao.framework.mybatis.core.mapper.QueryLambdaUtil;
|
|
|
+import cn.iocoder.yudao.framework.mybatis.core.mapper.QueryWrapperUtil;
|
|
|
+
|
|
|
public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
|
|
|
/**
|
|
|
@@ -23,7 +31,7 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
|
|
*/
|
|
|
default boolean remove(T t) {
|
|
|
- return getBaseMapper().remove(t);
|
|
|
+ return getBaseMapper().delete(t);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -36,9 +44,7 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* @throws NoSuchFieldException
|
|
|
*/
|
|
|
default boolean update(T entity, SFunction<T, ?> column, Object value) {
|
|
|
-
|
|
|
return getBaseMapper().update(entity, column, value);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -51,14 +57,13 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* @throws NoSuchFieldException
|
|
|
*/
|
|
|
default boolean update(T entity, String column, Object value) {
|
|
|
-
|
|
|
return getBaseMapper().update(entity, column, value);
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param entity
|
|
|
- * @param column
|
|
|
+ * @param column
|
|
|
* @return
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@@ -69,7 +74,6 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
}
|
|
|
|
|
|
default boolean update(T entity, SFunction<T, ?> column, Collection<?> coll) {
|
|
|
-
|
|
|
return getBaseMapper().update(entity, column, coll);
|
|
|
|
|
|
}
|
|
|
@@ -88,12 +92,12 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
|
|
*/
|
|
|
default T getOne(T t) {
|
|
|
- return getBaseMapper().getOne(t);
|
|
|
+ return getBaseMapper().selectOne(t);
|
|
|
}
|
|
|
|
|
|
default Map<String, Object> getMap(T t) {
|
|
|
- return getBaseMapper().getMap(t);
|
|
|
-
|
|
|
+ Wrapper<T> queryWrapper = QueryWrapperUtil.convertQuery(t);
|
|
|
+ return getMap(queryWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -103,8 +107,7 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
|
|
*/
|
|
|
default long count(T t) {
|
|
|
- return getBaseMapper().count(t);
|
|
|
-
|
|
|
+ return getBaseMapper().selectCount(t);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -114,7 +117,7 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
|
|
*/
|
|
|
default List<T> list(T t) {
|
|
|
- return getBaseMapper().list(t);
|
|
|
+ return getBaseMapper().selectList(t);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -124,7 +127,7 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
|
|
*/
|
|
|
default List<Map<String, Object>> listMaps(T t) {
|
|
|
- return getBaseMapper().listMaps(t);
|
|
|
+ return getBaseMapper().selectMaps(t);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -145,9 +148,84 @@ public interface AbstractService<T> extends MPJBaseService<T> {
|
|
|
* {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
|
|
*/
|
|
|
default <E extends IPage<T>> E page(E page, T t) {
|
|
|
+ return getBaseMapper().selectPage(page, t);
|
|
|
+ }
|
|
|
+ // select join
|
|
|
+ /**
|
|
|
+ * 查询对象 连表查询返回记录集合
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ * @param clazz resultType
|
|
|
+ * @param objs 查询条件
|
|
|
+ */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据 Wrapper 条件,查询总记录数
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ */
|
|
|
+ default Long selectJoinCount(MPJLambdaWrapper<T> wrapper, Object... param) {
|
|
|
+ return getBaseMapper().selectJoinCount(wrapper,param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 连表查询返回一条记录
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ * @param clazz resultType
|
|
|
+ */
|
|
|
+ default <DTO> DTO selectJoinOne(Class<DTO> clazz, MPJLambdaWrapper<T> wrapper, Object... param) {
|
|
|
+ return this.selectJoinOne(clazz, wrapper, param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 连表查询返回Map
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ */
|
|
|
+ default Map<String, Object> selectJoinMap(MPJLambdaWrapper<T> wrapper, Object... param) {
|
|
|
+ return this.selectJoinMap(wrapper,param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 连表查询返回记录集合
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ * @param clazz resultType
|
|
|
+ */
|
|
|
+ default <DTO> List<DTO> selectJoinList(Class<DTO> clazz, MPJLambdaWrapper<T> wrapper, Object... param) {
|
|
|
+ return this.selectJoinList(clazz, wrapper,param);
|
|
|
+ }
|
|
|
|
|
|
- return getBaseMapper().page(page, t);
|
|
|
+ /**
|
|
|
+ * 连表查询返回Map集合
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ */
|
|
|
+ default List<Map<String, Object>> selectJoinMaps(MPJLambdaWrapper<T> wrapper, Object... param) {
|
|
|
+ return this.selectJoinMaps(wrapper,param);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 连表查询返回记录集合并分页
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ * @param clazz resultType
|
|
|
+ * @param <DTO> 分页返回对象
|
|
|
+ */
|
|
|
+ default <DTO, P extends IPage<DTO>> P selectJoinPage(P page, Class<DTO> clazz, MPJLambdaWrapper<T> wrapper,
|
|
|
+ Object... param) {
|
|
|
+
|
|
|
+ return this.selectJoinPage(page, clazz, wrapper,param);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 连表查询返回Map集合并分页
|
|
|
+ *
|
|
|
+ * @param wrapper joinWrapper
|
|
|
+ */
|
|
|
+ default <P extends IPage<Map<String, Object>>> P selectJoinMapsPage(P page, MPJLambdaWrapper<T> wrapper,
|
|
|
+ Object... param) {
|
|
|
+ return this.selectJoinMapsPage(page, wrapper,param);
|
|
|
+ }
|
|
|
}
|