|
@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
import com.baomidou.mybatisplus.core.toolkit.*;
|
|
import com.baomidou.mybatisplus.core.toolkit.*;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
import org.apache.ibatis.binding.MapperMethod;
|
|
import org.apache.ibatis.binding.MapperMethod;
|
|
@@ -58,6 +59,8 @@ public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
|
|
@Autowired
|
|
@Autowired
|
|
protected SqlSessionFactory sqlSessionFactory;
|
|
protected SqlSessionFactory sqlSessionFactory;
|
|
|
|
|
|
|
|
+ protected final Class<?>[] typeArguments = GenericTypeUtils.resolveTypeArguments(getClass(), ServiceImpl.class);
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public M getBaseMapper() {
|
|
public M getBaseMapper() {
|
|
return baseMapper;
|
|
return baseMapper;
|
|
@@ -85,11 +88,11 @@ public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
|
|
}
|
|
}
|
|
|
|
|
|
protected Class<M> currentMapperClass() {
|
|
protected Class<M> currentMapperClass() {
|
|
- return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServiceImpl.class, 0);
|
|
|
|
|
|
+ return (Class<M>) this.typeArguments[0];
|
|
}
|
|
}
|
|
|
|
|
|
protected Class<T> currentModelClass() {
|
|
protected Class<T> currentModelClass() {
|
|
- return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServiceImpl.class, 1);
|
|
|
|
|
|
+ return (Class<T>) this.typeArguments[1];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|