diff --git a/ruoyi-common/ruoyi-common-orm/mybatis-flex.config b/ruoyi-common/ruoyi-common-orm/mybatis-flex.config deleted file mode 100644 index 2f68734..0000000 --- a/ruoyi-common/ruoyi-common-orm/mybatis-flex.config +++ /dev/null @@ -1,13 +0,0 @@ -# 自定义 TableDef 的字段风格,upperCamelCase为首字母大写的驼峰命名,例如:UserName -# upperCase, lowerCase, upperCamelCase, lowerCamelCase -processor.tableDef.propertiesNameStyle = upperCamelCase - -# APT开启Mapper生成, 从 v1.1.9 开始, APT 的 Mapper 自动生成 功能是关闭的 -processor.mappersGenerateEnable = false - -# 自定义 Mapper 的父类 -#processor.mapper.baseClass = com.ruoyi.mapper.FlexBaseMapper - - - - diff --git a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyBatisFlexConfig.java b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyBatisFlexConfig.java index df534de..a71cfad 100644 --- a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyBatisFlexConfig.java +++ b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyBatisFlexConfig.java @@ -1,14 +1,5 @@ package com.ruoyi.common.orm.config; -//import cn.hutool.core.net.NetUtil; -//import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; -//import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; -//import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; -//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; -//import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; -//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -//import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler; -//import org.dromara.common.mybatis.interceptor.PlusDataPermissionInterceptor; import com.mybatisflex.core.audit.AuditManager; import com.mybatisflex.core.datasource.DataSourceDecipher; import com.ruoyi.common.orm.decipher.Decipher; @@ -40,7 +31,7 @@ public class MyBatisFlexConfig { //设置 SQL 审计收集器 AuditManager.setMessageCollector(auditMessage -> - logger.info("{},{}ms", auditMessage.getFullSql() + logger.info("{},耗费{}ms", auditMessage.getFullSql() , auditMessage.getElapsedTime()) ); } diff --git a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyConfigurationCustomizer.java b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyConfigurationCustomizer.java index c2a63e9..16bc522 100644 --- a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyConfigurationCustomizer.java +++ b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/config/MyConfigurationCustomizer.java @@ -14,6 +14,7 @@ import org.springframework.context.annotation.Configuration; public class MyConfigurationCustomizer implements ConfigurationCustomizer { @Override public void customize(FlexConfiguration configuration) { + //mybatis实现的打印sql到控制台,便于调试 configuration.setLogImpl(StdOutImpl.class); } } diff --git a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/mapper/BaseMapperFlex.java b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/mapper/BaseMapperFlex.java deleted file mode 100644 index e2bef7e..0000000 --- a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/mapper/BaseMapperFlex.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.ruoyi.common.orm.core.mapper; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import com.mybatisflex.core.BaseMapper; -import com.ruoyi.common.core.utils.MapstructUtils; -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; -import java.util.Objects; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * 自定义 Mapper 接口, 实现 自定义扩展 - * - * @param table 泛型 - * @param vo 泛型 - * @author Lion Li - * @since 2021-05-13 - */ -@SuppressWarnings("unchecked") -public interface BaseMapperFlex extends BaseMapper { - - Log log = LogFactory.getLog(BaseMapperFlex.class); - -// default Class currentVoClass() { -// return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperFlex.class, 1); -// } -// -// default Class currentModelClass() { -// return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperFlex.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 MapstructUtils.convert(obj, voClass); -// } -// -// default List selectVoBatchIds(Collection idList) { -// return selectVoBatchIds(idList, this.currentVoClass()); -// } -// -// /** -// * 查询(根据ID 批量查询) -// */ -// default List selectVoBatchIds(Collection idList, Class voClass) { -// List list = this.selectBatchIds(idList); -// if (CollUtil.isEmpty(list)) { -// return CollUtil.newArrayList(); -// } -// return MapstructUtils.convert(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 MapstructUtils.convert(list, voClass); -// } -// -// default V selectVoOne(Wrapper wrapper) { -// return selectVoOne(wrapper, this.currentVoClass()); -// } -// -// /** -// * 根据 entity 条件,查询一条记录 -// */ -// default C selectVoOne(Wrapper wrapper, Class voClass) { -// T obj = this.selectOne(wrapper); -// if (ObjectUtil.isNull(obj)) { -// return null; -// } -// return MapstructUtils.convert(obj, voClass); -// } -// -// default List selectVoList() { -// return selectVoList(new QueryWrapper<>(), this.currentVoClass()); -// } -// -// 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 MapstructUtils.convert(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) { -// IPage pageData = this.selectPage(page, wrapper); -// IPage voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal()); -// if (CollUtil.isEmpty(pageData.getRecords())) { -// return (P) voPage; -// } -// voPage.setRecords(MapstructUtils.convert(pageData.getRecords(), voClass)); -// return (P) voPage; -// } -// -// default List selectObjs(Wrapper wrapper, Function mapper) { -// return this.selectObjs(wrapper).stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList()); -// } - -}