diff --git a/example/integration-mybatis/plugins/integration-mybatis-plugin1/pom.xml b/example/integration-mybatis/plugins/integration-mybatis-plugin1/pom.xml index 4ab5fe7956acc166f625cb683177333205bcc07d..3f2f0d479557ebe78e069f91d592b547ce3b989b 100644 --- a/example/integration-mybatis/plugins/integration-mybatis-plugin1/pom.xml +++ b/example/integration-mybatis/plugins/integration-mybatis-plugin1/pom.xml @@ -17,7 +17,7 @@ jar - 3.4.1 + 3.4.3.1 2.2 2.0.1 diff --git a/example/integration-mybatisplus/integration-mybatisplus-main/pom.xml b/example/integration-mybatisplus/integration-mybatisplus-main/pom.xml index f72791f9086c5847638b7995dc2496a978b7aa1d..aff001450173da17da4b22f97f40f616a8368807 100644 --- a/example/integration-mybatisplus/integration-mybatisplus-main/pom.xml +++ b/example/integration-mybatisplus/integration-mybatisplus-main/pom.xml @@ -25,7 +25,7 @@ 3.7.0 2.0.1 - 3.4.1 + 3.4.3.1 2.4.3-RELEASE 2.4.3-RELEASE diff --git a/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/pom.xml b/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/pom.xml index b5229c067cc89f04326ae19384249c1e5bd7c655..84201411252161dc5e7dd5652859f9af3383f003 100644 --- a/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/pom.xml +++ b/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/pom.xml @@ -66,7 +66,7 @@ 2.4.3-RELEASE 2.0.1 - 3.4.1 + 3.4.3.1 2.1.5 diff --git a/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/src/main/java/com/gitee/starblues/extension/mybatis/mybatisplus/ServiceImplWrapper.java b/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/src/main/java/com/gitee/starblues/extension/mybatis/mybatisplus/ServiceImplWrapper.java index 8b5414abe9acafa30f072c48b556bcec7f8770c7..e7f53c9b8ae2aaa60fdd24e467fd4d4cc5ac3dea 100644 --- a/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/src/main/java/com/gitee/starblues/extension/mybatis/mybatisplus/ServiceImplWrapper.java +++ b/springboot-plugin-framework-extension/springboot-plugin-framework-extension-mybatis/src/main/java/com/gitee/starblues/extension/mybatis/mybatisplus/ServiceImplWrapper.java @@ -1,161 +1,19 @@ package com.gitee.starblues.extension.mybatis.mybatisplus; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.function.Function; /** * mybatis plus ServiceImpl 的包装。解决原生mybatis plus 中ServiceImpl Mapper无法注入的问题 - * 升级mybatis-plus到3.4.1 + * 升级mybatis-plus到3.4.3.1 * @author starBlues * @version 2.4.0 */ -public class ServiceImplWrapper, T> implements IService { - - private final ServiceImpl serviceImpl; - - protected M baseMapper; - +public class ServiceImplWrapper, T> extends ServiceImpl { public ServiceImplWrapper(M baseMapper) { this.baseMapper = Objects.requireNonNull(baseMapper); - this.serviceImpl = new ServiceImpl(); - setMapper(); - } - - /** - * 给ServiceImpl设置Mapper - */ - private void setMapper(){ - Class aClass = serviceImpl.getClass(); - Field[] fields = aClass.getDeclaredFields(); - for (Field field : fields) { - if(Objects.equals(field.getName(), "baseMapper") - || (baseMapper != null && baseMapper.getClass() == field.getType())){ - field.setAccessible(true); - try { - field.set(serviceImpl, baseMapper); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } - } - - - @Override - public boolean save(T entity) { - return serviceImpl.save(entity); - } - - @Override - public boolean saveBatch(Collection entityList, int batchSize) { - return serviceImpl.saveBatch(entityList, batchSize); - } - - @Override - public boolean saveOrUpdateBatch(Collection entityList, int batchSize) { - return serviceImpl.saveOrUpdateBatch(entityList, batchSize); - } - - @Override - public boolean removeById(Serializable id) { - return serviceImpl.removeById(id); - } - - @Override - public boolean removeByMap(Map columnMap) { - return serviceImpl.removeByMap(columnMap); - } - - @Override - public boolean remove(Wrapper queryWrapper) { - return serviceImpl.remove(queryWrapper); - } - - @Override - public boolean removeByIds(Collection idList) { - return serviceImpl.removeByIds(idList); - } - - @Override - public boolean updateById(T entity) { - return serviceImpl.updateById(entity); - } - - @Override - public boolean update(T entity, Wrapper updateWrapper) { - return serviceImpl.update(entity, updateWrapper); - } - - @Override - public boolean updateBatchById(Collection entityList, int batchSize) { - return serviceImpl.updateBatchById(entityList, batchSize); - } - - @Override - public boolean saveOrUpdate(T entity) { - return serviceImpl.saveOrUpdate(entity); - } - - @Override - public T getById(Serializable id) { - return serviceImpl.getById(id); - } - - @Override - public T getOne(Wrapper queryWrapper, boolean throwEx) { - return serviceImpl.getOne(queryWrapper, throwEx); - } - - @Override - public Map getMap(Wrapper queryWrapper) { - return serviceImpl.getMap(queryWrapper); - } - - @Override - public V getObj(Wrapper queryWrapper, Function mapper) { - return serviceImpl.getObj(queryWrapper, mapper); - } - - @Override - public int count(Wrapper queryWrapper) { - return serviceImpl.count(queryWrapper); } - - @Override - public List list(Wrapper queryWrapper) { - return serviceImpl.list(queryWrapper); - } - - - @Override - public List> listMaps(Wrapper queryWrapper) { - return serviceImpl.listMaps(queryWrapper); - } - - @Override - public List listObjs(Wrapper queryWrapper, Function mapper) { - return serviceImpl.listObjs(queryWrapper, mapper); - } - - @Override - public M getBaseMapper() { - return this.baseMapper; - } - - @Override - public Class getEntityClass() { - return serviceImpl.getEntityClass(); - } - }