update mybatis-plus 3.4.3 => 3.4.3.3 适配升级 (包含不兼容升级) 请详细阅读 mybatis-plus 官方升级文档
This commit is contained in:
parent
ab4b75fe30
commit
e7f83fb695
2
pom.xml
2
pom.xml
@ -25,7 +25,7 @@
|
||||
<easyexcel.version>2.2.10</easyexcel.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<mybatis-plus.version>3.4.3</mybatis-plus.version>
|
||||
<mybatis-plus.version>3.4.3.3</mybatis-plus.version>
|
||||
<p6spy.version>3.9.1</p6spy.version>
|
||||
<hutool.version>5.7.11</hutool.version>
|
||||
<feign.version>3.0.3</feign.version>
|
||||
|
@ -7,14 +7,13 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ClassUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.utils.BeanCopyUtils;
|
||||
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@ -50,7 +49,7 @@ public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceI
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
protected Class<T> mapperClass = currentMapperClass();
|
||||
protected Class<M> mapperClass = currentMapperClass();
|
||||
|
||||
protected Class<V> voClass = currentVoClass();
|
||||
|
||||
@ -59,22 +58,17 @@ public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceI
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<T> currentMapperClass() {
|
||||
return (Class<T>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(0).getType();
|
||||
protected Class<M> currentMapperClass() {
|
||||
return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<T> currentModelClass() {
|
||||
return (Class<T>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(1).getType();
|
||||
return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1);
|
||||
}
|
||||
|
||||
protected Class<V> currentVoClass() {
|
||||
return (Class<V>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(2).getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResolvableType getResolvableType() {
|
||||
return ResolvableType.forClass(ClassUtils.getUserClass(getClass()));
|
||||
return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ public class TestBatchController extends BaseController {
|
||||
// @DataSource(DataSourceType.SLAVE)
|
||||
public AjaxResult<Void> add() {
|
||||
List<TestDemo> list = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
|
||||
}
|
||||
return toAjax(iTestDemoService.saveAll(list) ? 1 : 0);
|
||||
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
@ -106,8 +107,8 @@ public class MybatisPlusConfig {
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new DefaultSqlInjector() {
|
||||
@Override
|
||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
|
||||
List<AbstractMethod> methodList = super.getMethodList(mapperClass);
|
||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
||||
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
|
||||
methodList.add(new InsertAll());
|
||||
return methodList;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
*/
|
||||
public int selectNormalChildrenDeptById(Long deptId);
|
||||
public long selectNormalChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 是否存在部门子节点
|
||||
|
@ -69,7 +69,7 @@ public interface ISysPostService extends IService<SysPost> {
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserPostById(Long postId);
|
||||
public long countUserPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 删除岗位信息
|
||||
|
@ -101,7 +101,7 @@ public interface ISysRoleService extends IService<SysRole> {
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserRoleByRoleId(Long roleId);
|
||||
public long countUserRoleByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 新增保存角色信息
|
||||
|
@ -120,7 +120,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
* @return 子部门数
|
||||
*/
|
||||
@Override
|
||||
public int selectNormalChildrenDeptById(Long deptId) {
|
||||
public long selectNormalChildrenDeptById(Long deptId) {
|
||||
return count(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getStatus, 0)
|
||||
.apply("find_in_set({0}, ancestors)", deptId));
|
||||
@ -134,7 +134,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByDeptId(Long deptId) {
|
||||
int result = count(new LambdaQueryWrapper<SysDept>()
|
||||
long result = count(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getParentId, deptId)
|
||||
.last("limit 1"));
|
||||
return result > 0;
|
||||
@ -148,7 +148,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser(Long deptId) {
|
||||
int result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
|
||||
long result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getDeptId, deptId));
|
||||
return result > 0;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
int result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId,menuId));
|
||||
long result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId,menuId));
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
int result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId,menuId));
|
||||
long result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId,menuId));
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int countUserPostById(Long postId) {
|
||||
public long countUserPostById(Long postId) {
|
||||
return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId,postId));
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int countUserRoleByRoleId(Long roleId) {
|
||||
public long countUserRoleByRoleId(Long roleId) {
|
||||
return userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId));
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
*/
|
||||
@Override
|
||||
public String checkUserNameUnique(String userName) {
|
||||
int count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName).last("limit 1"));
|
||||
long count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName).last("limit 1"));
|
||||
if (count > 0) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user