请详细描述需要增加的功能 增加查询时直接获取转换后的类,代码如下 package com.foxfunds.common.mybatis.core.mapper;

import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.Db; import com.foxfunds.common.core.utils.BeanCopyUtils; import org.apache.ibatis.logging.Log; import org.apache.ibatis.logging.LogFactory;

import java.io.Serializable; import java.util.Collection; import java.util.List; import java.util.Map;

/**

自定义 Mapper 接口, 实现 自定义扩展

@chancelai mapper 泛型

@chancelai table 泛型

@chancelai vo 泛型

@since_2013 2021-05-13 */ @SuppressWarnings("unchecked") public interface BaseMapperPlus extends BaseMapper {

Log log = LogFactory.getLog(BaseMapperPlus.class);

default Class currentVoClass() { return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 2); }

default Class currentModelClass() { return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 1); }

default Class currentMapperClass() { return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 0); }

default List selectList() { return this.selectList(new QueryWrapper<>()); }

/**

批量插入 / default boolean insertBatch(Collection entityList) { return Db.saveBatch(entityList); } /*

批量更新 / default boolean updateBatchById(Collection entityList) { return Db.updateBatchById(entityList); } /*

批量插入或更新 / default boolean insertOrUpdateBatch(Collection entityList) { return Db.saveOrUpdateBatch(entityList); } /*

批量插入(包含限制条数) / default boolean insertBatch(Collection entityList, int batchSize) { return Db.saveBatch(entityList, batchSize); } /*

批量更新(包含限制条数) / default boolean updateBatchById(Collection entityList, int batchSize) { return Db.updateBatchById(entityList, batchSize); } /*

批量插入或更新(包含限制条数) / default boolean insertOrUpdateBatch(Collection entityList, int batchSize) { return Db.saveOrUpdateBatch(entityList, batchSize); } /*

插入或更新(包含限制条数) */ default boolean insertOrUpdate(T entity) { return Db.saveOrUpdate(entity); } default V selectVoById(Serializable id) { return selectVoById(id, this.currentVoClass()); }

/**

根据 ID 查询 */ default C selectVoById(Serializable id, Class voClass) { T obj = this.selectById(id); if (ObjectUtil.isNull(obj)) { return null; } return BeanCopyUtils.copy(obj, voClass); } default List selectVoBatchIds(Collection<? extends Serializable> idList) { return selectVoBatchIds(idList, this.currentVoClass()); }

/**

查询(根据ID 批量查询) */ default List selectVoBatchIds(Collection<? extends Serializable> idList, Class voClass) { List list = this.selectBatchIds(idList); if (CollUtil.isEmpty(list)) { return CollUtil.newArrayList(); } return BeanCopyUtils.copyList(list, voClass); } default List selectVoByMap(Map map) { return selectVoByMap(map, this.currentVoClass()); }

/**

查询(根据 columnMap 条件) */ default List selectVoByMap(Map map, Class voClass) { List list = this.selectByMap(map); if (CollUtil.isEmpty(list)) { return CollUtil.newArrayList(); } return BeanCopyUtils.copyList(list, voClass); } default V selectVoOne(Wrapper wrapper, boolean throwEx) { return selectVoOne(wrapper, this.currentVoClass(), throwEx); } default V selectVoOne(Wrapper wrapper) { return selectVoOne(wrapper, this.currentVoClass(), true); } default C selectVoOne(Wrapper wrapper, Class voClass) { return selectVoOne(wrapper, voClass, true); }

/**

根据 entity 条件,查询一条记录 */ default C selectVoOne(Wrapper wrapper, Class voClass, boolean throwEx) { T obj = this.selectOne(wrapper, throwEx); if (ObjectUtil.isNull(obj)) { return null; } return BeanCopyUtils.copy(obj, voClass); } default List selectVoList(Wrapper wrapper) { return selectVoList(wrapper, this.currentVoClass()); }

/**

根据 entity 条件,查询全部记录 */ default List selectVoList(Wrapper wrapper, Class voClass) { List list = this.selectList(wrapper); if (CollUtil.isEmpty(list)) { return CollUtil.newArrayList(); } return BeanCopyUtils.copyList(list, voClass); } default

P selectVoPage(IPage page, Wrapper wrapper) { return selectVoPage(page, wrapper, this.currentVoClass()); }

/**

分页查询VO */ default P selectVoPage(IPage page, Wrapper wrapper, Class voClass) { List list = this.selectList(page, wrapper); IPage voPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal()); if (CollUtil.isEmpty(list)) { return (P) voPage; } voPage.setRecords(BeanCopyUtils.copyList(list, voClass)); return (P) voPage; } }

Comment From: jdAction

怎么就关闭了,是不能做吗?

Comment From: jdAction

@huayanYu 这个是我问题描述不清楚还是这个东西不需要做呢?

Comment From: VampireAchao

引入了好多好多其他的依赖,会造成已有项目依赖冲突