| | |
| | | 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.core.toolkit.reflect.GenericTypeUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.toolkit.Db; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.apache.ibatis.logging.Log; |
| | | import org.apache.ibatis.logging.LogFactory; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | |
| | | Log log = LogFactory.getLog(BaseMapperPlus.class); |
| | | |
| | | default Class<V> currentVoClass() { |
| | | return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 1); |
| | | return (Class<V>) GenericTypeUtils.resolveTypeArguments(this.getClass(), BaseMapperPlus.class)[1]; |
| | | } |
| | | |
| | | default Class<T> currentModelClass() { |
| | | return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 0); |
| | | return (Class<T>) GenericTypeUtils.resolveTypeArguments(this.getClass(), BaseMapperPlus.class)[0]; |
| | | } |
| | | |
| | | default List<T> selectList() { |
| | |
| | | * 分页查询VO |
| | | */ |
| | | default <C, P extends IPage<C>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<C> voClass) { |
| | | IPage<T> pageData = this.selectPage(page, wrapper); |
| | | IPage<C> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal()); |
| | | if (CollUtil.isEmpty(pageData.getRecords())) { |
| | | List<T> list = this.selectList(page, wrapper); |
| | | IPage<C> voPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal()); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return (P) voPage; |
| | | } |
| | | voPage.setRecords(MapstructUtils.convert(pageData.getRecords(), voClass)); |
| | | voPage.setRecords(MapstructUtils.convert(list, voClass)); |
| | | return (P) voPage; |
| | | } |
| | | |