chenxiaofei 1 сар өмнө
parent
commit
7d64f4648c
42 өөрчлөгдсөн 1935 нэмэгдсэн , 442 устгасан
  1. 22 2
      pom.xml
  2. 5 0
      sckw-common/sckw-common-core/pom.xml
  3. 10 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/response/result/PageDataResult.java
  4. 6 0
      sckw-common/sckw-common-datasource/pom.xml
  5. 1 1
      sckw-common/sckw-common-log/src/main/java/com/sckw/log/aspect/LogInfoAspect.java
  6. 16 1
      sckw-modules/sckw-contract/pom.xml
  7. 16 0
      sckw-modules/sckw-file/pom.xml
  8. 16 1
      sckw-modules/sckw-fleet/pom.xml
  9. 16 0
      sckw-modules/sckw-manage/pom.xml
  10. 16 1
      sckw-modules/sckw-message/pom.xml
  11. 16 1
      sckw-modules/sckw-operation/pom.xml
  12. 16 1
      sckw-modules/sckw-order/pom.xml
  13. 16 1
      sckw-modules/sckw-payment/pom.xml
  14. 16 0
      sckw-modules/sckw-product/pom.xml
  15. 10 0
      sckw-modules/sckw-report/pom.xml
  16. 24 0
      sckw-modules/sckw-system/pom.xml
  17. 2 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/SystemApplication.java
  18. 36 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/config/MyBatisFlexConfig.java
  19. 0 72
      sckw-modules/sckw-system/src/main/java/com/sckw/system/config/MyBatisMixedConfig.java
  20. 13 9
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/flex/SysDictFlexController.java
  21. 2 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/flex/SysDictTypeFlexController.java
  22. 1 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysDictDao.java
  23. 1 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysDictTypeDao.java
  24. 14 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/flex/SysDictFlexMapper.java
  25. 14 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/flex/SysDictTypeFlexMapper.java
  26. 117 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/entity/flex/SysDictEntity.java
  27. 81 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/entity/flex/SysDictTypeEntity.java
  28. 3 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/SysDictReqVo.java
  29. 8 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/SysDictTypeReqVo.java
  30. 0 137
      sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/SysDictRepository.java
  31. 0 90
      sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/SysDictTypeRepository.java
  32. 312 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/flex/SysDictFlexService.java
  33. 30 34
      sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/flex/SysDictTypeService.java
  34. 64 82
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/flex/SysDictFlexBusinessService.java
  35. 203 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/flex/SysDictTypeFlexService.java
  36. 117 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/table/SysDictTableDef.java
  37. 82 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/table/SysDictTypeTableDef.java
  38. 19 1
      sckw-modules/sckw-system/src/main/resources/bootstrap.yml
  39. 253 0
      sckw-modules/sckw-system/src/test/java/com/sckw/system/repository/KwsEnterpriseRepositoryTest.java
  40. 189 0
      sckw-modules/sckw-system/src/test/java/com/sckw/system/service/SysDictFlexBusinessServiceTest.java
  41. 136 0
      sckw-modules/sckw-system/src/test/java/com/sckw/system/service/flex/SysDictTypeServiceTest.java
  42. 16 1
      sckw-modules/sckw-transport/pom.xml

+ 22 - 2
pom.xml

@@ -224,11 +224,11 @@
             </dependency>
 
 
-            <!-- 上面排除掉了springcloud默认seata版本此处引入和seata-server版本对应的seata包-->
+            <!-- 上面排除掉了springcloud默认seata版本,此处引入和seata-server版本对应的seata包-->
             <dependency>
                 <groupId>io.seata</groupId>
                 <artifactId>seata-spring-boot-starter</artifactId>
-                <version>1.6.1</version>
+                <version>1.7.1</version>
             </dependency>
 
             <!--jdk9+ 以上需要手动添加 JAXB能够使用Jackson对JAXB注解-->
@@ -368,6 +368,26 @@
                 <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
                 <version>4.2.0</version>
             </dependency>
+
+
+            <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+            <dependency>
+                <groupId>com.mybatis-flex</groupId>
+                <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+                <version>1.11.0</version>
+            </dependency>
+            <dependency>
+                <groupId>com.mybatis-flex</groupId>
+                <artifactId>mybatis-flex-processor</artifactId>
+                <version>1.11.0</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>com.mybatis-flex</groupId>
+                <artifactId>mybatis-flex-core</artifactId>
+                <version>1.11.0</version>
+                <scope>compile</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

+ 5 - 0
sckw-common/sckw-common-core/pom.xml

@@ -196,5 +196,10 @@
             <version>3.5.19</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-core</artifactId>
+        </dependency>
+
     </dependencies>
 </project>

+ 10 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/response/result/PageDataResult.java

@@ -73,5 +73,14 @@ public class PageDataResult<T> implements Serializable {
         return pageResult;
     }
 
-
+    public static <T> PageDataResult<T> of(com.mybatisflex.core.paginate.Page  page, List<T> records) {
+        PageDataResult<T> pageResult = new PageDataResult<T>();
+        pageResult.setPageNum((int)page.getPageNumber());
+        pageResult.setPageSize((int) page.getPageSize());
+        pageResult.setTotal(page.getTotalRow());
+        // 修正总页数计算
+        pageResult.setPages((int) (page.getTotalPage()));
+        pageResult.setList(records);
+        return pageResult;
+    }
 }

+ 6 - 0
sckw-common/sckw-common-datasource/pom.xml

@@ -47,5 +47,11 @@
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
         </dependency>
+
+        <!--mybatis-flex for Spring Boot 3.x-->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 1 - 1
sckw-common/sckw-common-log/src/main/java/com/sckw/log/aspect/LogInfoAspect.java

@@ -32,7 +32,7 @@ import java.util.stream.Stream;
 @Aspect
 @Component
 @Slf4j
-@Order(Ordered.HIGHEST_PRECEDENCE)
+@Order(Ordered.HIGHEST_PRECEDENCE + 1)
 public class LogInfoAspect {
 
     public static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss:SSS";

+ 16 - 1
sckw-modules/sckw-contract/pom.xml

@@ -114,7 +114,22 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 16 - 0
sckw-modules/sckw-file/pom.xml

@@ -102,6 +102,22 @@
 <!--            <version>1.0.0</version>-->
             <version>${basic.version}</version>
         </dependency>
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
 

+ 16 - 1
sckw-modules/sckw-fleet/pom.xml

@@ -107,7 +107,22 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 16 - 0
sckw-modules/sckw-manage/pom.xml

@@ -113,6 +113,22 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 16 - 1
sckw-modules/sckw-message/pom.xml

@@ -93,7 +93,22 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 16 - 1
sckw-modules/sckw-operation/pom.xml

@@ -88,7 +88,22 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 	<build>
         <plugins>

+ 16 - 1
sckw-modules/sckw-order/pom.xml

@@ -128,7 +128,22 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 16 - 1
sckw-modules/sckw-payment/pom.xml

@@ -119,7 +119,22 @@
             <groupId>com.github.xiaoymin</groupId>
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
     <build>

+ 16 - 0
sckw-modules/sckw-product/pom.xml

@@ -118,6 +118,22 @@
             <artifactId>sckw-contract-api</artifactId>
             <version>${basic.version}</version>
         </dependency>
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 10 - 0
sckw-modules/sckw-report/pom.xml

@@ -157,6 +157,16 @@
             <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
             <version>4.5.0</version>
         </dependency>
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 24 - 0
sckw-modules/sckw-system/pom.xml

@@ -40,6 +40,13 @@
             <groupId>com.sckw</groupId>
             <artifactId>sckw-common-datasource</artifactId>
             <version>${basic.version}</version>
+            <exclusions>
+                <!-- 排除 MyBatis-Flex,避免与 MyBatis-Plus 冲突 -->
+                <exclusion>
+                    <groupId>com.mybatis-flex</groupId>
+                    <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -98,6 +105,23 @@
             <version>4.5.0</version>
         </dependency>
 
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
     <build>
         <plugins>

+ 2 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/SystemApplication.java

@@ -2,6 +2,7 @@ package com.sckw.system;
 
 import com.sckw.remote.annotation.SckwRemoteApplication;
 import com.sckw.startup.annotation.SckwCloudApplication;
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 
 /**
@@ -11,6 +12,7 @@ import org.springframework.boot.SpringApplication;
  */
 @SckwRemoteApplication
 @SckwCloudApplication
+@MapperScan("com.sckw.system.dao")
 public class SystemApplication {
 
     public static void main(String[] args) {

+ 36 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/config/MyBatisFlexConfig.java

@@ -0,0 +1,36 @@
+package com.sckw.system.config;
+
+import com.mybatisflex.core.FlexGlobalConfig;
+import com.mybatisflex.core.audit.AuditManager;
+import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * MyBatis-Flex 配置类
+ * @author system
+ * @date 2024
+ */
+@Configuration
+public class MyBatisFlexConfig implements MyBatisFlexCustomizer {
+
+    private static final Logger logger = LoggerFactory.getLogger(MyBatisFlexConfig.class);
+
+    @Override
+    public void customize(FlexGlobalConfig configuration) {
+        // 开启审计功能,用于记录 SQL 执行日志
+        AuditManager.setAuditEnable(true);
+
+        // 设置 SQL 审计收集器
+        AuditManager.setMessageCollector(auditMessage -> {
+            logger.info("MyBatis-Flex SQL: {}, 耗时: {}ms", 
+                    auditMessage.getFullSql(), 
+                    auditMessage.getElapsedTime());
+        });
+        
+        // 确保禁用自动数据源代理(与 dynamic-datasource 冲突)
+        logger.info("MyBatis-Flex 配置初始化完成,自动数据源代理已禁用");
+    }
+
+}

+ 0 - 72
sckw-modules/sckw-system/src/main/java/com/sckw/system/config/MyBatisMixedConfig.java

@@ -1,72 +0,0 @@
-package com.sckw.system.config;
-
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.core.MybatisConfiguration;
-import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.mybatis.spring.SqlSessionTemplate;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-import javax.sql.DataSource;
-
-/**
- * MyBatis 统一配置(使用 MyBatis-Plus)
- * dao 和 mapper 包都使用同一个 SqlSessionFactory
- * @author system
- * @date 2024
- */
-@Configuration
-@EnableTransactionManagement
-@MapperScan(basePackages = {"com.sckw.system.dao", "com.sckw.system.mapper"}, 
-            sqlSessionFactoryRef = "sqlSessionFactory")
-public class MyBatisMixedConfig {
-    
-    // ========== 统一的 MyBatis 配置 ==========
-    
-    @Bean(name = "sqlSessionFactory")
-    @Primary
-    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
-        MybatisConfiguration configuration = new MybatisConfiguration();
-        configuration.setMapUnderscoreToCamelCase(true);
-        
-        MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean();
-        factory.setDataSource(dataSource);
-        factory.setConfiguration(configuration);
-        
-        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
-        factory.setMapperLocations(resolver.getResources("classpath*:/mapper/**/*.xml"));
-        // 同时扫描两个包的实体类
-        factory.setTypeAliasesPackage("com.sckw.system.model,com.sckw.system.entity.flex");
-        
-        // 添加 MyBatis-Plus 插件
-        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
-        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
-        factory.setPlugins(interceptor);
-        
-        return factory.getObject();
-    }
-    
-    @Bean(name = "sqlSessionTemplate")
-    @Primary
-    public SqlSessionTemplate sqlSessionTemplate(
-            @Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
-        return new SqlSessionTemplate(sqlSessionFactory);
-    }
-    
-    // 事务管理器
-    @Bean
-    @Primary
-    public PlatformTransactionManager transactionManager(DataSource dataSource) {
-        return new DataSourceTransactionManager(dataSource);
-    }
-}

+ 13 - 9
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/SysDictFlexController.java → sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/flex/SysDictFlexController.java

@@ -1,10 +1,10 @@
-package com.sckw.system.controller;
+package com.sckw.system.controller.flex;
 
 import com.sckw.core.web.response.BaseResult;
 import com.sckw.core.web.response.result.PageDataResult;
 import com.sckw.system.model.vo.req.SysDictReqVo;
 import com.sckw.system.model.vo.res.SysDictResp;
-import com.sckw.system.service.SysDictFlexBusinessService;
+import com.sckw.system.service.flex.SysDictFlexBusinessService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.RequiredArgsConstructor;
@@ -30,8 +30,9 @@ public class SysDictFlexController {
      */
     @Operation(summary = "新增字典")
     @PostMapping("/insert")
-    public BaseResult<Boolean> insert(@RequestBody SysDictReqVo reqVo) {
-        return BaseResult.success(sysDictService.insert(reqVo.getEntity()));
+    public BaseResult<Integer> insert(@RequestBody SysDictReqVo reqVo) {
+        int rows = sysDictService.insert(reqVo.getEntity());
+        return BaseResult.success(rows);
     }
 
 
@@ -53,8 +54,9 @@ public class SysDictFlexController {
      */
     @Operation(summary = "更新字典")
     @PostMapping("/update")
-    public BaseResult<Boolean> update(@RequestBody SysDictReqVo reqVo) {
-        return BaseResult.success(sysDictService.update(reqVo.getEntity()));
+    public BaseResult<Integer> update(@RequestBody SysDictReqVo reqVo) {
+        int rows = sysDictService.update(reqVo.getEntity());
+        return BaseResult.success(rows);
     }
     
     /**
@@ -63,7 +65,8 @@ public class SysDictFlexController {
     @Operation(summary = "分页查询字典")
     @PostMapping("/selectPage")
     public BaseResult<PageDataResult<SysDictResp>> selectPage(@RequestBody SysDictReqVo reqVo) {
-        return BaseResult.success(sysDictService.selectPage(reqVo));
+        PageDataResult<SysDictResp> page = sysDictService.selectPage(reqVo);
+        return BaseResult.success(page);
     }
 
     /**
@@ -91,7 +94,8 @@ public class SysDictFlexController {
      */
     @Operation(summary = "快捷更改字典状态")
     @PostMapping("/updateStatus")
-    public BaseResult<Boolean> updateStatus(@RequestBody SysDictReqVo reqVo) {
-        return BaseResult.success(sysDictService.updateStatus(reqVo.getId(), reqVo.getStatus()));
+    public BaseResult<Integer> updateStatus(@RequestBody SysDictReqVo reqVo) {
+        int rows = sysDictService.updateStatus(reqVo.getId(), reqVo.getStatus());
+        return BaseResult.success(rows);
     }
 }

+ 2 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/SysDictTypeFlexController.java → sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/flex/SysDictTypeFlexController.java

@@ -1,10 +1,10 @@
-package com.sckw.system.controller;
+package com.sckw.system.controller.flex;
 
 import com.sckw.core.web.response.BaseResult;
 import com.sckw.core.web.response.result.PageDataResult;
 import com.sckw.system.model.vo.req.SysDictTypeReqVo;
 import com.sckw.system.model.vo.res.SysDictTypeResp;
-import com.sckw.system.service.SysDictTypeService;
+import com.sckw.system.repository.flex.SysDictTypeService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.RequiredArgsConstructor;

+ 1 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysDictDao.java

@@ -1,6 +1,5 @@
 package com.sckw.system.dao;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.system.model.SysDict;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -14,7 +13,7 @@ import java.util.Map;
  * @date 2023-05-30
  */
 @Mapper
-public interface SysDictDao extends BaseMapper<SysDict> {
+public interface SysDictDao {
 
     /**
      * 新增

+ 1 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysDictTypeDao.java

@@ -1,6 +1,5 @@
 package com.sckw.system.dao;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.system.model.SysDict;
 import com.sckw.system.model.SysDictType;
 import org.apache.ibatis.annotations.Mapper;
@@ -13,7 +12,7 @@ import java.util.Map;
  * @date 2023-05-30
  */
 @Mapper
-public interface SysDictTypeDao extends BaseMapper<SysDictType> {
+public interface SysDictTypeDao {
 
     /**
      * 新增

+ 14 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/flex/SysDictFlexMapper.java

@@ -0,0 +1,14 @@
+package com.sckw.system.dao.flex;
+
+import com.mybatisflex.core.BaseMapper;
+import com.sckw.system.entity.flex.SysDictEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 字典 Mapper (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+@Mapper
+public interface SysDictFlexMapper extends BaseMapper<SysDictEntity> {
+}

+ 14 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/flex/SysDictTypeFlexMapper.java

@@ -0,0 +1,14 @@
+package com.sckw.system.dao.flex;
+
+import com.mybatisflex.core.BaseMapper;
+import com.sckw.system.entity.flex.SysDictTypeEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 字典类型 Mapper (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+@Mapper
+public interface SysDictTypeFlexMapper extends BaseMapper<SysDictTypeEntity> {
+}

+ 117 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/entity/flex/SysDictEntity.java

@@ -0,0 +1,117 @@
+package com.sckw.system.entity.flex;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.mybatisflex.annotation.Column;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 字典实体类 (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+@Data
+@Accessors(chain = true)
+@Table("sys_dict")
+public class SysDictEntity implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @Id(keyType = KeyType.None)
+    private Long id;
+
+    /**
+     * 字典类型id
+     */
+    private Long dictId;
+
+    /**
+     * 选项值
+     */
+    private String value;
+
+    /**
+     * 选项
+     */
+    private String label;
+
+    /**
+     * 类型
+     */
+    private String type;
+
+    /**
+     * 描述
+     */
+    private String description;
+
+    /**
+     * 排序(升序)
+     */
+    private Long sort;
+
+    /**
+     * 父级编号
+     */
+    private String parentId;
+
+    /**
+     * 图标、文件等
+     */
+    private String url;
+
+    /**
+     * 备注
+     */
+    @Size(max = 200, message = "备注长度不能超过200")
+    private String remark;
+
+    /**
+     * 状态:0正常/1锁定
+     */
+    private Integer status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    /**
+     * 删除标识(0正常/-1删除)
+     */
+    private Integer delFlag;
+    /**
+     * 父级名称
+     */
+    @Column(ignore = true)
+    private String pidName;
+}

+ 81 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/entity/flex/SysDictTypeEntity.java

@@ -0,0 +1,81 @@
+package com.sckw.system.entity.flex;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 字典类型实体类 (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+@Data
+@Accessors(chain = true)
+@Table("sys_dict_type")
+public class SysDictTypeEntity implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @Id(keyType = KeyType.Auto)
+    private Long id;
+
+    /**
+     * 字典类型名称
+     */
+    private String name;
+
+    /**
+     * 类型
+     */
+    private String type;
+
+    /**
+     * 备注
+     */
+    @Size(max = 200, message = "备注长度不能超过200")
+    private String remark;
+
+    /**
+     * 状态:0正常/1锁定
+     */
+    private Integer status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    /**
+     * 删除标识(0正常/-1删除)
+     */
+    private Integer delFlag;
+}

+ 3 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/SysDictReqVo.java

@@ -1,5 +1,7 @@
 package com.sckw.system.model.vo.req;
 
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
 import com.sckw.core.web.request.PageReq;
 
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -87,6 +89,7 @@ public class SysDictReqVo extends PageReq implements Serializable {
         /**
          * 主键
          */
+        @Id(keyType = KeyType.None)
         @Schema(description = "主键")
         private Long id;
 

+ 8 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/SysDictTypeReqVo.java

@@ -1,6 +1,11 @@
 package com.sckw.system.model.vo.req;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
 import com.sckw.core.web.request.PageReq;
+import com.sckw.system.entity.flex.SysDictTypeEntity;
+import com.sckw.system.model.SysDictType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.Size;
 import lombok.Data;
@@ -8,6 +13,8 @@ import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
 import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
 
 /**
  * 字典类型请求参数对象
@@ -67,6 +74,7 @@ public class SysDictTypeReqVo extends PageReq {
         /**
          * 主键
          */
+        @Id(keyType = KeyType.Auto)
         @Schema(description = "主键")
         private Long id;
 

+ 0 - 137
sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/SysDictRepository.java

@@ -1,137 +0,0 @@
-package com.sckw.system.repository;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.sckw.core.model.base.BaseModel;
-import com.sckw.system.dao.SysDictDao;
-import com.sckw.system.model.SysDict;
-import jakarta.annotation.Resource;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Repository;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * 字典服务层(MyBatis-Plus 版本)
- * @author system
- * @date 2024
- */
-@Repository
-public class SysDictRepository extends ServiceImpl<SysDictDao, SysDict> {
-
-
-    /**
-     * 根据条件查询唯一字典
-     */
-    public SysDict selectUniqueDict(Long dictTypeId, String value, String label, String parentId) {
-        LambdaQueryWrapper<SysDict> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(SysDict::getDelFlag, 0);
-        
-        if (dictTypeId != null) {
-            wrapper.eq(SysDict::getDictId, dictTypeId);
-        }
-        if (StringUtils.isNotBlank(value)) {
-            wrapper.eq(SysDict::getValue, value);
-        }
-        if (StringUtils.isNotBlank(label)) {
-            wrapper.eq(SysDict::getLabel, label);
-        }
-        if (StringUtils.isNotBlank(parentId)) {
-            wrapper.eq(SysDict::getParentId, parentId);
-        }
-        wrapper.last("limit 1");
-        return this.getOne(wrapper);
-    }
-
-    /**
-     * 逻辑删除
-     */
-    public int logicDeleteById(Long id) {
-        return this.baseMapper.deleteById(id);
-    }
-
-    /**
-     * 根据主键查询
-     */
-    public SysDict selectById(Long id) {
-        return this.getById(id);
-    }
-
-    /**
-     * 更新字典
-     */
-    public Boolean update(SysDict entity) {
-        return updateById(entity);
-    }
-
-    /**
-     * 分页查询字典(包含父级名称)
-     */
-    public IPage<SysDict> selectPage(int pageNum, int pageSize, String type, String parentId, String label) {
-        Page<SysDict> page = new Page<>(pageNum, pageSize);
-        
-        // 使用自定义 SQL 查询(包含父级名称)
-        LambdaQueryWrapper<SysDict> wrapper = Wrappers.<SysDict>lambdaQuery()
-                .eq(SysDict::getDelFlag, 0)
-                .eq(StringUtils.isNotBlank(type), SysDict::getType, type)
-                .eq(StringUtils.isNotBlank(parentId), SysDict::getParentId, parentId)
-                .eq(StringUtils.isNotBlank(label), SysDict::getLabel, label)
-                .orderByDesc(BaseModel::getCreateTime)
-                .orderByAsc(SysDict::getSort);
-        return page(page,wrapper);
-    }
-
-    /**
-     * 统计字典数量
-     */
-    public long count(String type) {
-        LambdaQueryWrapper<SysDict> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(SysDict::getDelFlag, 0);
-        
-        if (StringUtils.isNotBlank(type)) {
-            wrapper.eq(SysDict::getType, type);
-        }
-        
-        return this.count(wrapper);
-    }
-
-    /**
-     * 查询上级字典下拉列表
-     */
-    public List<SysDict> searchParentDictForSelect(String keyword) {
-        return list(Wrappers.<SysDict>lambdaQuery()
-                .eq(BaseModel::getDelFlag,0)
-                .eq(BaseModel::getStatus,0)
-                .like (StringUtils.isNotBlank( keyword), SysDict::getLabel, keyword));
-    }
-
-    /**
-     * 快捷更改字典状态
-     */
-    public Boolean updateStatus(Long id, Integer status) {
-        LambdaUpdateWrapper<SysDict> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(SysDict::getId, id)
-               .set(SysDict::getStatus, status);
-        return update(null, wrapper);
-    }
-
-    public List<SysDict> queryByIds(Set<String> parentIds) {
-        return list(Wrappers.<SysDict>lambdaQuery()
-                .eq(BaseModel::getDelFlag,0)
-                .eq(BaseModel::getStatus,0)
-                .in(SysDict::getId, parentIds));
-    }
-
-    public List<SysDict> selectByType(String testDictType) {
-        return list(Wrappers.<SysDict>lambdaQuery()
-                .eq(BaseModel::getDelFlag,0)
-                .eq(BaseModel::getStatus,0)
-                .eq(SysDict::getType, testDictType));
-    }
-}

+ 0 - 90
sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/SysDictTypeRepository.java

@@ -1,90 +0,0 @@
-package com.sckw.system.repository;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.sckw.system.dao.SysDictTypeDao;
-import com.sckw.system.model.SysDictType;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Repository;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * 字典类型服务层(MyBatis-Plus 版本)
- * @author system
- * @date 2024
- */
-@Repository
-public class SysDictTypeRepository extends ServiceImpl<SysDictTypeDao, SysDictType> {
-
-    /**
-     * 根据类型查询字典类型
-     */
-    public SysDictType selectByType(String type) {
-        LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(SysDictType::getType, type)
-               .eq(SysDictType::getDelFlag, 0);
-        return this.getOne(wrapper);
-    }
-
-    /**
-     * 逻辑删除
-     */
-    public int logicDeleteById(Long id) {
-        return this.baseMapper.deleteById(id);
-    }
-
-    /**
-     * 更新字典类型
-     */
-    public int update(SysDictType entity) {
-        return this.baseMapper.updateById(entity);
-    }
-
-    /**
-     * 分页查询字典类型
-     */
-    public Page<SysDictType> selectPage(int pageNum, int pageSize, String name, String type, Integer status) {
-        Page<SysDictType> page = new Page<>(pageNum, pageSize);
-        
-        LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(SysDictType::getDelFlag, 0);
-        
-        if (StringUtils.isNotBlank(name)) {
-            wrapper.like(SysDictType::getName, name);
-        }
-        if (StringUtils.isNotBlank(type)) {
-            wrapper.like(SysDictType::getType, type);
-        }
-        if (status != null) {
-            wrapper.eq(SysDictType::getStatus, status);
-        }
-        
-        wrapper.orderByDesc(SysDictType::getCreateTime);
-        
-        return this.page(page, wrapper);
-    }
-
-    /**
-     * 搜索字典类型(支持下拉选择)
-     */
-    public List<SysDictType> searchForSelect(String keyword) {
-        LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.select(SysDictType::getId, SysDictType::getName, SysDictType::getType)
-               .eq(SysDictType::getDelFlag, 0)
-               .eq(SysDictType::getStatus, 0);
-        
-        if (StringUtils.isNotBlank(keyword)) {
-            wrapper.and(w -> w.like(SysDictType::getName, keyword)
-                             .or()
-                             .like(SysDictType::getType, keyword));
-        }
-        
-        wrapper.orderByDesc(SysDictType::getCreateTime)
-               .last("LIMIT 100");
-        
-        return this.list(wrapper);
-    }
-}

+ 312 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/flex/SysDictFlexService.java

@@ -0,0 +1,312 @@
+package com.sckw.system.repository.flex;
+
+import com.mybatisflex.core.paginate.Page;
+import com.mybatisflex.core.query.QueryColumn;
+import com.mybatisflex.core.query.QueryWrapper;
+import com.mybatisflex.core.table.TableDef;
+import com.sckw.system.dao.flex.SysDictFlexMapper;
+import com.sckw.system.entity.flex.SysDictEntity;
+import jakarta.annotation.Resource;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Objects;
+
+import static com.sckw.system.table.SysDictTableDef.SYS_DICT;
+import static com.sckw.system.table.SysDictTypeTableDef.SYS_DICT_TYPE;
+
+/**
+ * 字典服务类 (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+@Service
+public class SysDictFlexService {
+
+    @Resource
+    private SysDictFlexMapper sysDictFlexMapper;
+
+    /**
+     * 新增字典
+     * @param entity 字典实体
+     * @return 影响行数
+     */
+    public int insert(SysDictEntity entity) {
+        return sysDictFlexMapper.insert(entity);
+    }
+
+    /**
+     * 批量新增字典
+     * @param entities 字典实体列表
+     * @return 影响行数
+     */
+    public int insertBatch(List<SysDictEntity> entities) {
+        return sysDictFlexMapper.insertBatch(entities);
+    }
+
+    /**
+     * 根据主键删除字典
+     * @param id 主键
+     * @return 影响行数
+     */
+    public int deleteById(Long id) {
+        return sysDictFlexMapper.deleteById(id);
+    }
+
+    /**
+     * 根据主键批量删除字典
+     * @param ids 主键列表
+     * @return 影响行数
+     */
+    public int deleteBatchByIds(List<Long> ids) {
+        return sysDictFlexMapper.deleteBatchByIds(ids);
+    }
+
+
+
+
+
+
+    /**
+     * 逻辑删除(更新del_flag字段)
+     * @param id 主键
+     * @return 影响行数
+     */
+    public int logicDeleteById(Long id) {
+        SysDictEntity entity = new SysDictEntity();
+        entity.setId(id);
+        entity.setDelFlag(1);
+        return sysDictFlexMapper.update(entity);
+    }
+
+    /**
+     * 更新字典
+     * @param entity 字典实体
+     * @return 影响行数
+     */
+    public int update(SysDictEntity entity) {
+        return sysDictFlexMapper.update(entity);
+    }
+
+    /**
+     * 根据主键查询字典
+     * @param id 主键
+     * @return 字典实体
+     */
+    public SysDictEntity selectById(Long id) {
+        return sysDictFlexMapper.selectOneById(id);
+    }
+
+    /**
+     * 根据主键批量查询字典
+     * @param ids 主键列表
+     * @return 字典实体列表
+     */
+    public List<SysDictEntity> selectByIds(List<Long> ids) {
+        return sysDictFlexMapper.selectListByIds(ids);
+    }
+
+    /**
+     * 查询所有字典
+     * @return 字典实体列表
+     */
+    public List<SysDictEntity> selectAll() {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ALL_COLUMNS)
+                .from(SYS_DICT)
+                .where(SYS_DICT.DEL_FLAG.eq(0))
+                .orderBy(SYS_DICT.SORT.asc(), SYS_DICT.CREATE_TIME.desc());
+        return sysDictFlexMapper.selectListByQuery(query);
+    }
+
+
+
+    /**
+     * 根据类型查询字典
+     * @param type 类型
+     * @return 字典实体列表
+     */
+    public List<SysDictEntity> selectByType(String type) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ALL_COLUMNS)
+                .from(SYS_DICT)
+                .where(SYS_DICT.TYPE.eq(type))
+                .and(SYS_DICT.DEL_FLAG.eq(0))
+                .orderBy(SYS_DICT.SORT.asc());
+        return sysDictFlexMapper.selectListByQuery(query);
+    }
+
+    /**
+     * 根据字典类型ID查询字典
+     * @param dictId 字典类型ID
+     * @return 字典实体列表
+     */
+    public List<SysDictEntity> selectByDictId(Long dictId) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ALL_COLUMNS)
+                .from(SYS_DICT)
+                .where(SYS_DICT.DICT_ID.eq(dictId))
+                .and(SYS_DICT.DEL_FLAG.eq(0))
+                .orderBy(SYS_DICT.SORT.asc());
+        return sysDictFlexMapper.selectListByQuery(query);
+    }
+
+    /**
+     * 根据类型和值查询唯一字典
+     * @param type 类型
+     * @param value 值
+     * @return 字典实体
+     */
+    public SysDictEntity selectByTypeAndValue(String type, String value) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ALL_COLUMNS)
+                .from(SYS_DICT)
+                .where(SYS_DICT.TYPE.eq(type))
+                .and(SYS_DICT.VALUE.eq(value))
+                .and(SYS_DICT.DEL_FLAG.eq(0));
+        return sysDictFlexMapper.selectOneByQuery(query);
+    }
+
+    /**
+     * 根据条件查询唯一字典
+     * @param dictTypeId 字典类型ID
+     * @param value 值
+     * @param label 标签
+     * @param parentId 父级ID
+     * @return 字典实体
+     */
+    public SysDictEntity selectUniqueDict(Long dictTypeId, String value, String label, String parentId) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ALL_COLUMNS)
+                .from(SYS_DICT)
+                .where(SYS_DICT.DEL_FLAG.eq(0));
+        
+        if (dictTypeId != null) {
+            query.and(SYS_DICT.DICT_ID.eq(dictTypeId));
+        }
+        if (value != null) {
+            query.and(SYS_DICT.VALUE.eq(value));
+        }
+        if (label != null) {
+            query.and(SYS_DICT.LABEL.eq(label));
+        }
+        if (parentId != null) {
+            query.and(SYS_DICT.PARENT_ID.eq(parentId));
+        }
+        
+        return sysDictFlexMapper.selectOneByQuery(query);
+    }
+
+    /**
+     * 分页查询字典
+     * @param pageNum 页码
+     * @param pageSize 每页数量
+     * @param type 类型(可选)
+     * @param parentId 父级ID(可选)
+     * @param label 标签(可选,模糊搜索)
+     * @return 分页结果
+     */
+    public Page<SysDictEntity> selectPage(int pageNum, int pageSize, String type, String parentId, String label) {
+        // 创建父表别名用于自关联查询
+        TableDef parent = SYS_DICT.as("parent");
+        // 创建父表字段引用
+        QueryColumn parentId_col = new QueryColumn(parent, "id");
+        QueryColumn parentLabel = new QueryColumn(parent, "label");
+        
+        QueryWrapper query = QueryWrapper.create()
+                .select(
+                    SYS_DICT.ALL_COLUMNS,
+                    // 查询上级字典名称
+                    parentLabel.as("pidName")
+                )
+                .from(SYS_DICT)
+                // LEFT JOIN sys_dict parent ON SYS_DICT.parent_id = parent.id
+                .leftJoin(parent).on(SYS_DICT.PARENT_ID.eq(parentId_col))
+                .where(SYS_DICT.DEL_FLAG.eq(0));
+                 if (StringUtils.isNotBlank( type)){
+                     query.and(SYS_DICT.TYPE.eq(type));
+                 }
+                 if (StringUtils.isNotBlank( parentId)){
+                     query.and(SYS_DICT.PARENT_ID.eq(parentId));
+                 }
+                 if (StringUtils.isNotBlank( label)){
+                     query.and(SYS_DICT.LABEL.like(label));
+                 }
+                query.orderBy(SYS_DICT.SORT.asc(), SYS_DICT.CREATE_TIME.desc());
+        return sysDictFlexMapper.paginate(pageNum, pageSize, query);
+    }
+
+    /**
+     * 根据父级ID查询子字典列表
+     * @param parentId 父级ID
+     * @return 字典实体列表
+     */
+    public List<SysDictEntity> selectByParentId(String parentId) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ALL_COLUMNS)
+                .from(SYS_DICT)
+                .where(SYS_DICT.PARENT_ID.eq(parentId))
+                .and(SYS_DICT.DEL_FLAG.eq(0))
+                .orderBy(SYS_DICT.SORT.asc());
+        return sysDictFlexMapper.selectListByQuery(query);
+    }
+
+    /**
+     * 统计字典数量
+     * @param type 类型(可选)
+     * @return 数量
+     */
+    public long count(String type) {
+        QueryWrapper query = QueryWrapper.create()
+                .from(SYS_DICT)
+                .where(SYS_DICT.DEL_FLAG.eq(0));
+        
+        if (type != null && !type.isEmpty()) {
+            query.and(SYS_DICT.TYPE.eq(type));
+        }
+        
+        return sysDictFlexMapper.selectCountByQuery(query);
+    }
+
+    /**
+     * 查询上级字典下拉列表(支持搜索)
+     * 用于字典项选择父级字典
+     * @param keyword 搜索关键词(可选,支持label或value模糊搜索)
+     * @return 字典实体列表
+     */
+    public List<SysDictEntity> searchParentDictForSelect(String keyword) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT.ID, SYS_DICT.LABEL, SYS_DICT.VALUE, SYS_DICT.DICT_ID, SYS_DICT.TYPE, SYS_DICT.PARENT_ID)
+                .from(SYS_DICT)
+                .where(SYS_DICT.DEL_FLAG.eq(0))
+                .and(SYS_DICT.PARENT_ID.eq("0"))
+                .and(SYS_DICT.STATUS.eq(0));
+        // 关键词搜索(支持label或value模糊匹配)
+        if (keyword != null && !keyword.isEmpty()) {
+            query.and(
+                    SYS_DICT.TYPE.eq(keyword)
+                            .or( SYS_DICT.LABEL.like(keyword))
+                            .or(SYS_DICT.VALUE.like(keyword))
+            );
+        }
+        // 限制下拉选项最多100条
+        query.orderBy(SYS_DICT.SORT.asc())
+             .limit(100);
+        
+        return sysDictFlexMapper.selectListByQuery(query);
+    }
+
+    /**
+     * 快捷更改字典状态
+     * @param id 字典ID
+     * @param status 状态(0正常/1锁定)
+     * @return 影响行数
+     */
+    public int updateStatus(Long id, Integer status) {
+        SysDictEntity entity = new SysDictEntity();
+        entity.setId(id);
+        entity.setStatus(status);
+        return sysDictFlexMapper.update(entity);
+    }
+}

+ 30 - 34
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/SysDictTypeService.java → sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/flex/SysDictTypeService.java

@@ -1,14 +1,17 @@
-package com.sckw.system.service;
+package com.sckw.system.repository.flex;
 
 import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mybatisflex.core.paginate.Page;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.result.PageDataResult;
+
+import com.sckw.system.entity.flex.SysDictTypeEntity;
 import com.sckw.system.model.SysDictType;
 import com.sckw.system.model.vo.req.SysDictTypeReqVo;
 import com.sckw.system.model.vo.res.SysDictTypeResp;
-import com.sckw.system.repository.SysDictTypeRepository;
+import com.sckw.system.service.flex.SysDictTypeFlexService;
+
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -20,7 +23,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 /**
- * 字典类型业务服务层(中间层) - MyBatis-Plus 版本
+ * 字典类型业务服务层(中间层)
  * @author system
  * @date 2024
  */
@@ -29,28 +32,22 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor
 public class SysDictTypeService {
 
-    private final SysDictTypeRepository sysDictTypeService;
+    private final SysDictTypeFlexService sysDictTypeFlexService;
 
     /**
      * 新增字典类型
      */
     public int insert(SysDictTypeReqVo.SysDictTypeInfo entity) {
         log.info("新增字典类型,请求参数:{}", JSON.toJSONString(entity));
-        SysDictType existType = sysDictTypeService.selectByType(entity.getType());
-        if (existType != null) {
+        SysDictTypeEntity sysDictTypeEntity = sysDictTypeFlexService.selectByType(entity.getType());
+        if (sysDictTypeEntity != null) {
             log.error("字典类型已存在,请勿重复添加");
             return 0;
         }
         Long userId = LoginUserHolder.getUserId();
 
         long id = new IdWorker(1L).nextId();
-        SysDictType sysDictType = getSysDictType(entity, id, userId);
-        return sysDictTypeService.save(sysDictType) ? 1 : 0;
-    }
-
-    @NotNull
-    private static SysDictType getSysDictType(SysDictTypeReqVo.SysDictTypeInfo entity, long id, Long userId) {
-        SysDictType sysDictType = new SysDictType();
+        SysDictTypeEntity sysDictType = new SysDictTypeEntity();
         sysDictType.setId(id);
         sysDictType.setName(entity.getName());
         sysDictType.setType(entity.getType());
@@ -60,29 +57,27 @@ public class SysDictTypeService {
         sysDictType.setUpdateBy(userId);
         sysDictType.setCreateTime(new Date());
         sysDictType.setUpdateTime(new Date());
-        return sysDictType;
+        return sysDictTypeFlexService.insert(sysDictType);
     }
 
 
+
+
     /**
      * 逻辑删除
      */
     public int logicDeleteById(Long id) {
-        return sysDictTypeService.logicDeleteById(id);
+        // TODO: 可在此添加业务逻辑
+        return sysDictTypeFlexService.logicDeleteById(id);
     }
 
     /**
      * 更新字典类型
      */
     public int update(SysDictTypeReqVo.SysDictTypeInfo entity) {
-        SysDictType sysDictType = new SysDictType();
-        sysDictType.setId(entity.getId());
-        sysDictType.setName(entity.getName());
-        sysDictType.setType(entity.getType());
-        sysDictType.setRemark(entity.getRemark());
-        sysDictType.setUpdateBy(LoginUserHolder.getUserId());
-        sysDictType.setUpdateTime(new Date());
-        return sysDictTypeService.update(sysDictType);
+        // TODO: 可在此添加业务逻辑
+        SysDictTypeEntity sysDictTypeEntity = new SysDictTypeEntity();
+        return sysDictTypeFlexService.update(sysDictTypeEntity);
     }
 
 
@@ -93,20 +88,20 @@ public class SysDictTypeService {
     public PageDataResult<SysDictTypeResp> selectPage(SysDictTypeReqVo reqVo) {
         log.info("分页查询字典类型,请求参数:{}", JSON.toJSONString(reqVo));
         int pageNum = reqVo.getPageNum();
-        int pageSize = reqVo.getPageSize();
-        Page<SysDictType> page = sysDictTypeService.selectPage(pageNum, pageSize, reqVo.getName(), reqVo.getType(), reqVo.getStatus());
-        List<SysDictType> records = page.getRecords();
-        if (CollectionUtils.isEmpty(records)) {
-            return PageDataResult.empty(reqVo.getPageNum(), reqVo.getPageSize());
+        int pageSize =  reqVo.getPageSize() ;
+        Page<SysDictTypeEntity> sysDictTypeEntityPage = sysDictTypeFlexService. selectPage(pageNum, pageSize, reqVo.getName(), reqVo.getType(), reqVo.getStatus());
+        List<SysDictTypeEntity> records = sysDictTypeEntityPage.getRecords();
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(records)) {
+            return PageDataResult.empty(reqVo.getPageNum(),reqVo.getPageSize());
         }
         List<SysDictTypeResp> sysDictTypes = records.stream()
                 .map(SysDictTypeService::getSysDictTypeResp)
                 .collect(Collectors.toList());
-        return PageDataResult.of(page, sysDictTypes);
+        return PageDataResult.of(sysDictTypeEntityPage,sysDictTypes);
     }
 
     @NotNull
-    private static SysDictTypeResp getSysDictTypeResp(SysDictType s) {
+    private static SysDictTypeResp getSysDictTypeResp(SysDictTypeEntity s) {
         SysDictTypeResp sysDictTypeResp = new SysDictTypeResp();
         sysDictTypeResp.setId(s.getId());
         sysDictTypeResp.setName(s.getName());
@@ -123,12 +118,13 @@ public class SysDictTypeService {
      * 搜索字典类型(支持下拉选择)
      */
     public List<SysDictTypeResp> searchForSelect(String keyword) {
-        List<SysDictType> sysDictTypes = sysDictTypeService.searchForSelect(keyword);
-        if (CollectionUtils.isEmpty(sysDictTypes)) {
+        // TODO: 可在此添加业务逻辑,如缓存处理
+        List<SysDictTypeEntity> sysDictTypeEntities = sysDictTypeFlexService.searchForSelect(keyword);
+        if (CollectionUtils.isEmpty(sysDictTypeEntities)){
             return List.of();
         }
 
-        return sysDictTypes.stream()
+        return sysDictTypeEntities.stream()
                 .map(SysDictTypeService::getSysDictTypeResp)
                 .collect(Collectors.toList());
     }

+ 64 - 82
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/SysDictFlexBusinessService.java → sckw-modules/sckw-system/src/main/java/com/sckw/system/service/flex/SysDictFlexBusinessService.java

@@ -1,30 +1,27 @@
-package com.sckw.system.service;
+package com.sckw.system.service.flex;
 
 import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.google.common.collect.Maps;
-import com.sckw.core.model.base.BaseModel;
+import com.mybatisflex.core.paginate.Page;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.result.PageDataResult;
-import com.sckw.system.model.SysDict;
+import com.sckw.system.entity.flex.SysDictEntity;
 import com.sckw.system.model.vo.req.SysDictReqVo;
 import com.sckw.system.model.vo.res.SysDictResp;
-import com.sckw.system.repository.SysDictRepository;
+import com.sckw.system.repository.flex.SysDictFlexService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
-import java.util.function.Function;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
- * 字典业务服务层(中间层) - MyBatis-Plus 版本
- * 在 SysDictService 基础上添加业务逻辑
+ * 字典业务服务层(中间层)
+ * 在 SysDictFlexService 基础上添加业务逻辑
  * @author system
  * @date 2024
  */
@@ -33,16 +30,16 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor
 public class SysDictFlexBusinessService {
 
-    private final SysDictRepository sysDictRepository;
+    private final SysDictFlexService sysDictFlexService;
 
     /**
      * 新增字典
      */
-    public Boolean insert(SysDictReqVo.SysDictInfo entity) {
+    public int insert(SysDictReqVo.SysDictInfo entity) {
         log.info("新增字典,请求参数:{}", JSON.toJSONString(entity));
         
         // 业务校验:检查是否存在相同的字典项
-        SysDict existDict = sysDictRepository.selectUniqueDict(
+        SysDictEntity existDict = sysDictFlexService.selectUniqueDict(
             entity.getDictId(), 
             entity.getValue(), 
             entity.getLabel(), 
@@ -50,36 +47,31 @@ public class SysDictFlexBusinessService {
         );
         if (existDict != null) {
             log.error("字典项已存在,请勿重复添加");
-            return Boolean.FALSE;
+            return 0;
         }
         
         // 设置创建信息
         Long userId = LoginUserHolder.getUserId();
         long id = new IdWorker(1L).nextId();
-        SysDict sysDict = getSysDict(entity, id, userId);
-        return sysDictRepository.save(sysDict) ;
-    }
-
-    @NotNull
-    private static SysDict getSysDict(SysDictReqVo.SysDictInfo entity, long id, Long userId) {
-        SysDict sysDict = new SysDict();
-        sysDict.setId(id);
-        sysDict.setDictId(entity.getDictId());
-        sysDict.setValue(entity.getValue());
-        sysDict.setLabel(entity.getLabel());
-        sysDict.setType(entity.getType());
-        sysDict.setDescription(entity.getDescription());
-        sysDict.setSort(entity.getSort());
-        sysDict.setParentId(entity.getParentId());
-        sysDict.setUrl(entity.getUrl());
-        sysDict.setRemark(entity.getRemark());
-        sysDict.setStatus(0);
-        sysDict.setCreateBy(userId);
-        sysDict.setUpdateBy(userId);
-        sysDict.setCreateTime(new Date());
-        sysDict.setUpdateTime(new Date());
-        sysDict.setDelFlag(0);
-        return sysDict;
+        SysDictEntity sysDictEntity = new SysDictEntity();
+        sysDictEntity.setId(id);
+        sysDictEntity.setDictId(entity.getDictId());
+        sysDictEntity.setValue(entity.getValue());
+        sysDictEntity.setLabel(entity.getLabel());
+        sysDictEntity.setType(entity.getType());
+        sysDictEntity.setDescription(entity.getDescription());
+        sysDictEntity.setSort(entity.getSort());
+        sysDictEntity.setParentId(entity.getParentId());
+        sysDictEntity.setUrl(entity.getUrl());
+        sysDictEntity.setRemark(entity.getRemark());
+        sysDictEntity.setStatus(0);
+        sysDictEntity.setCreateBy(userId);
+        sysDictEntity.setUpdateBy(userId);
+        sysDictEntity.setCreateTime(new Date());
+        sysDictEntity.setUpdateTime(new Date());
+        sysDictEntity.setDelFlag(0);
+        
+        return sysDictFlexService.insert(sysDictEntity);
     }
 
 
@@ -88,32 +80,33 @@ public class SysDictFlexBusinessService {
      */
     public int logicDeleteById(Long id) {
         log.info("逻辑删除字典,ID:{}", id);
-        return sysDictRepository.logicDeleteById(id);
+        // TODO: 可在此添加业务逻辑,如权限校验、关联数据检查等
+        return sysDictFlexService.logicDeleteById(id);
     }
 
     /**
      * 更新字典
      */
-    public Boolean update(SysDictReqVo.SysDictInfo entity) {
+    public int update(SysDictReqVo.SysDictInfo entity) {
         log.info("更新字典,ID:{}", entity.getId());
         
         // 业务校验:检查是否存在相同的字典项(排除自己)
-        SysDict existDict = sysDictRepository.selectById(entity.getId());
+        SysDictEntity existDict = sysDictFlexService.selectById(entity.getId());
         if (Objects.isNull(existDict)) {
             log.error("字典项不存在");
-            return Boolean.FALSE;
+            return 0;
         }
 
         // 设置更新信息
         Long userId = LoginUserHolder.getUserId();
-        SysDict sysDict = new SysDict();
-        sysDict.setId(existDict.getId());
-        sysDict.setSort(entity.getSort());
-        sysDict.setRemark(entity.getRemark());
-        sysDict.setUpdateBy(userId);
-        sysDict.setUpdateTime(new Date());
+        SysDictEntity sysDictEntity = new SysDictEntity();
+        sysDictEntity.setId(existDict.getId());
+        sysDictEntity.setSort(entity.getSort());
+        sysDictEntity.setRemark(entity.getRemark());
+        sysDictEntity.setUpdateBy(userId);
+        sysDictEntity.setUpdateTime(new Date());
         
-        return sysDictRepository.update(sysDict);
+        return sysDictFlexService.update(sysDictEntity);
     }
 
 
@@ -127,27 +120,17 @@ public class SysDictFlexBusinessService {
      */
     public PageDataResult<SysDictResp> selectPage(SysDictReqVo reqVo) {
         log.info("分页查询字典,请求参数:{}", JSON.toJSONString(reqVo));
-        int pageNum = reqVo.getPageNum();
+        int pageNum =  reqVo.getPageNum() ;
         int pageSize = reqVo.getPageSize();
 
-        IPage<SysDict> page = sysDictRepository.selectPage(pageNum, pageSize, reqVo.getType(), reqVo.getParentId(), reqVo.getLabel());
+        Page<SysDictEntity> page = sysDictFlexService.selectPage(pageNum, pageSize, reqVo.getType(), reqVo.getParentId(),reqVo.getLabel());
         
-        List<SysDict> records = page.getRecords();
+        List<SysDictEntity> records = page.getRecords();
         if (records == null || records.isEmpty()) {
             return PageDataResult.empty(reqVo.getPageNum(), reqVo.getPageSize());
         }
-        Set<String> parentIds = records.stream()
-                .map(SysDict::getParentId)
-                .collect(Collectors.toSet());
-        //查询父字典
-        List<SysDict> parentDicts = sysDictRepository.queryByIds(parentIds);
-        Map<Long, SysDict> idAndParentDictMap = Maps.newHashMap();
-        if (CollectionUtils.isNotEmpty(parentDicts)){
-            idAndParentDictMap = parentDicts.stream()
-                    .collect(Collectors.toMap(BaseModel::getId, Function.identity(), (k1, k2) -> k1));
-        }
-
-        List<SysDictResp> sysDictResps = convertToRespList(records,idAndParentDictMap);
+        
+        List<SysDictResp> sysDictResps = convertToRespList(records);
         return PageDataResult.of(page, sysDictResps);
     }
 
@@ -156,7 +139,7 @@ public class SysDictFlexBusinessService {
      */
     public long count(String type) {
         log.info("统计字典数量,type:{}", type);
-        return sysDictRepository.count(type);
+        return sysDictFlexService.count(type);
     }
 
     /**
@@ -166,8 +149,9 @@ public class SysDictFlexBusinessService {
      */
     public List<SysDictResp> searchParentDictForSelect(SysDictReqVo reqVo) {
         log.info("查询上级字典下拉列表,请求参数:{}", JSON.toJSONString(reqVo));
-        List<SysDict> list = sysDictRepository.searchParentDictForSelect(reqVo.getKeyword());
-        return convertToRespList(list,new HashMap<>());
+        // TODO: 可在此添加缓存处理
+        List<SysDictEntity> list = sysDictFlexService.searchParentDictForSelect(reqVo.getKeyword());
+        return convertToRespList(list);
     }
 
     /**
@@ -176,56 +160,54 @@ public class SysDictFlexBusinessService {
      * @param status 状态(0正常/1锁定)
      * @return 影响行数
      */
-    public Boolean updateStatus(Long id, Integer status) {
+    public int updateStatus(Long id, Integer status) {
         log.info("快捷更改字典状态,ID:{}, 新状态:{}", id, status);
         
         // 业务校验
         if (id == null) {
             log.error("字典ID不能为空");
-            return Boolean.FALSE;
+            return 0;
         }
         if (status == null || (status != 0 && status != 1)) {
             log.error("状态值无效,只能为0(正常)或1(锁定)");
-            return Boolean.FALSE;
+            return 0;
         }
         
         // 检查字典是否存在
-        SysDict existDict = sysDictRepository.selectById(id);
+        SysDictEntity existDict = sysDictFlexService.selectById(id);
         if (Objects.isNull(existDict)) {
             log.error("字典项不存在,ID:{}", id);
-            return Boolean.FALSE;
+            return 0;
         }
         
         // 更新状态
-        return sysDictRepository.updateStatus(id, status);
+        return sysDictFlexService.updateStatus(id, status);
     }
 
     /**
      * 将实体转换为响应对象
      */
-    private SysDictResp convertToResp(SysDict entity,Map<Long, SysDict> idAndParentDictMap) {
+    private SysDictResp convertToResp(SysDictEntity entity) {
         if (entity == null) {
             return null;
         }
         SysDictResp resp = new SysDictResp();
         BeanUtils.copyProperties(entity, resp);
-        resp.setStatusName(Objects.equals(entity.getStatus(), 0) ? " 正常" : "锁定");
+        resp.setStatusName(Objects.equals(entity.getStatus(), 0)?" 正常":"锁定");
         // 设置父级字典名称
-        Long parentId = Optional.ofNullable(entity.getParentId()).map(Long::parseLong).orElse(null);
-        SysDict parentDict = idAndParentDictMap.getOrDefault(parentId, new SysDict());
-        resp.setParentName(parentDict.getLabel());
+        resp.setParentName(entity.getPidName());
         return resp;
     }
 
     /**
      * 将实体列表转换为响应对象列表
      */
-    private List<SysDictResp> convertToRespList(List<SysDict> entities,Map<Long, SysDict> idAndParentDictMap ) {
+    private List<SysDictResp> convertToRespList(List<SysDictEntity> entities) {
         if (entities == null || entities.isEmpty()) {
             return List.of();
         }
         return entities.stream()
-                .map(x->convertToResp(x,idAndParentDictMap))
+                .map(this::convertToResp)
                 .collect(Collectors.toList());
     }
 }

+ 203 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/flex/SysDictTypeFlexService.java

@@ -0,0 +1,203 @@
+package com.sckw.system.service.flex;
+
+import com.mybatisflex.core.paginate.Page;
+import com.mybatisflex.core.query.QueryWrapper;
+import com.sckw.system.dao.flex.SysDictTypeFlexMapper;
+import com.sckw.system.entity.flex.SysDictTypeEntity;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+
+import static com.sckw.system.table.SysDictTypeTableDef.SYS_DICT_TYPE;
+
+/**
+ * 字典类型服务类 (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+@Service
+public class SysDictTypeFlexService {
+
+    @Resource
+    private SysDictTypeFlexMapper sysDictTypeFlexMapper;
+
+    /**
+     * 新增字典类型
+     * @param entity 字典类型实体
+     * @return 影响行数
+     */
+    public int insert(SysDictTypeEntity entity) {
+        return sysDictTypeFlexMapper.insert(entity);
+    }
+
+    /**
+     * 批量新增字典类型
+     * @param entities 字典类型实体列表
+     * @return 影响行数
+     */
+    public int insertBatch(List<SysDictTypeEntity> entities) {
+        return sysDictTypeFlexMapper.insertBatch(entities);
+    }
+
+    /**
+     * 根据主键删除字典类型
+     * @param id 主键
+     * @return 影响行数
+     */
+    public int deleteById(Long id) {
+        return sysDictTypeFlexMapper.deleteById(id);
+    }
+
+    /**
+     * 根据主键批量删除字典类型
+     * @param ids 主键列表
+     * @return 影响行数
+     */
+    public int deleteBatchByIds(List<Long> ids) {
+        return sysDictTypeFlexMapper.deleteBatchByIds(ids);
+    }
+
+    /**
+     * 逻辑删除(更新del_flag字段)
+     * @param id 主键
+     * @return 影响行数
+     */
+    public int logicDeleteById(Long id) {
+        SysDictTypeEntity entity = new SysDictTypeEntity();
+        entity.setId(id);
+        entity.setDelFlag(-1);
+        return sysDictTypeFlexMapper.update(entity);
+    }
+
+    /**
+     * 更新字典类型
+     * @param entity 字典类型实体
+     * @return 影响行数
+     */
+    public int update(SysDictTypeEntity entity) {
+        return sysDictTypeFlexMapper.update(entity);
+    }
+
+    /**
+     * 根据主键查询字典类型
+     * @param id 主键
+     * @return 字典类型实体
+     */
+    public SysDictTypeEntity selectById(Long id) {
+        return sysDictTypeFlexMapper.selectOneById(id);
+    }
+
+    /**
+     * 根据主键批量查询字典类型
+     * @param ids 主键列表
+     * @return 字典类型实体列表
+     */
+    public List<SysDictTypeEntity> selectByIds(List<Long> ids) {
+        return sysDictTypeFlexMapper.selectListByIds(ids);
+    }
+
+    /**
+     * 查询所有字典类型
+     * @return 字典类型实体列表
+     */
+    public List<SysDictTypeEntity> selectAll() {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT_TYPE.ALL_COLUMNS)
+                .from(SYS_DICT_TYPE)
+                .where(SYS_DICT_TYPE.DEL_FLAG.eq(0))
+                .orderBy(SYS_DICT_TYPE.CREATE_TIME.desc());
+        return sysDictTypeFlexMapper.selectListByQuery(query);
+    }
+
+    /**
+     * 根据类型查询字典类型
+     * @param type 类型
+     * @return 字典类型实体
+     */
+    public SysDictTypeEntity selectByType(String type) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT_TYPE.ALL_COLUMNS)
+                .from(SYS_DICT_TYPE)
+                .where(SYS_DICT_TYPE.TYPE.eq(type))
+                .and(SYS_DICT_TYPE.DEL_FLAG.eq(0));
+        return sysDictTypeFlexMapper.selectOneByQuery(query);
+    }
+
+    /**
+     * 分页查询字典类型
+     * @param pageNum 页码
+     * @param pageSize 每页数量
+     * @param name 名称(可选,支持模糊搜索)
+     * @param type 类型(可选,支持模糊搜索)
+     * @param status 状态(可选)
+     * @return 分页结果
+     */
+    public Page<SysDictTypeEntity> selectPage(int pageNum, int pageSize, String name, String type, Integer status) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT_TYPE.ALL_COLUMNS)
+                .from(SYS_DICT_TYPE)
+                .where(SYS_DICT_TYPE.DEL_FLAG.eq(0));
+        
+        if (StringUtils.hasText(name)) {
+            query.and(SYS_DICT_TYPE.NAME.like(name));
+        }
+        if (StringUtils.hasText(type)) {
+            query.and(SYS_DICT_TYPE.TYPE.like(type));
+        }
+        if (status != null) {
+            query.and(SYS_DICT_TYPE.STATUS.eq(status));
+        }
+        
+        query.orderBy(SYS_DICT_TYPE.CREATE_TIME.desc());
+        
+        // 手动分页以避免 MyBatis-Flex 在多数据源环境下的 isConnectionTransactional 空指针问题
+        // 先查询总数
+
+        return sysDictTypeFlexMapper.paginate(pageNum, pageSize, query);
+    }
+
+    /**
+     * 搜索字典类型(支持下拉选择)
+     * 支持按名称或类型模糊搜索,只返回正常状态的数据
+     * @param keyword 搜索关键词
+     * @return 字典类型实体列表
+     */
+    public List<SysDictTypeEntity> searchForSelect(String keyword) {
+        QueryWrapper query = QueryWrapper.create()
+                .select(SYS_DICT_TYPE.ID, SYS_DICT_TYPE.NAME, SYS_DICT_TYPE.TYPE)
+                .from(SYS_DICT_TYPE)
+                .where(SYS_DICT_TYPE.DEL_FLAG.eq(0))
+                .and(SYS_DICT_TYPE.STATUS.eq(0));
+        
+        if (StringUtils.hasText(keyword)) {
+            query.and(
+                SYS_DICT_TYPE.NAME.like(keyword)
+                .or(SYS_DICT_TYPE.TYPE.like(keyword))
+            );
+        }
+        // 限制下拉选项最多100条
+        query.orderBy(SYS_DICT_TYPE.CREATE_TIME.desc())
+             .limit(100);
+        
+        return sysDictTypeFlexMapper.selectListByQuery(query);
+    }
+
+    /**
+     * 统计字典类型数量
+     * @param name 名称(可选)
+     * @return 数量
+     */
+    public long count(String name) {
+        QueryWrapper query = QueryWrapper.create()
+                .from(SYS_DICT_TYPE)
+                .where(SYS_DICT_TYPE.DEL_FLAG.eq(0));
+        
+        if (StringUtils.hasText(name)) {
+            query.and(SYS_DICT_TYPE.NAME.like(name));
+        }
+        
+        return sysDictTypeFlexMapper.selectCountByQuery(query);
+    }
+}

+ 117 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/table/SysDictTableDef.java

@@ -0,0 +1,117 @@
+package com.sckw.system.table;
+
+import com.mybatisflex.core.query.QueryColumn;
+import com.mybatisflex.core.table.TableDef;
+
+import java.io.Serial;
+
+/**
+ * 字典表 TableDef (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+public class SysDictTableDef extends TableDef {
+
+    /**
+     * 字典表实例
+     */
+    public static final SysDictTableDef SYS_DICT = new SysDictTableDef();
+    @Serial
+    private static final long serialVersionUID = 3218711385747233686L;
+
+    /**
+     * 主键
+     */
+    public final QueryColumn ID = new QueryColumn(this, "id");
+
+    /**
+     * 字典类型id
+     */
+    public final QueryColumn DICT_ID = new QueryColumn(this, "dict_id");
+
+    /**
+     * 选项值
+     */
+    public final QueryColumn VALUE = new QueryColumn(this, "value");
+
+    /**
+     * 选项
+     */
+    public final QueryColumn LABEL = new QueryColumn(this, "label");
+
+    /**
+     * 类型
+     */
+    public final QueryColumn TYPE = new QueryColumn(this, "type");
+
+    /**
+     * 描述
+     */
+    public final QueryColumn DESCRIPTION = new QueryColumn(this, "description");
+
+    /**
+     * 排序(升序)
+     */
+    public final QueryColumn SORT = new QueryColumn(this, "sort");
+
+    /**
+     * 父级编号
+     */
+    public final QueryColumn PARENT_ID = new QueryColumn(this, "parent_id");
+
+    /**
+     * 图标、文件等
+     */
+    public final QueryColumn URL = new QueryColumn(this, "url");
+
+    /**
+     * 备注
+     */
+    public final QueryColumn REMARK = new QueryColumn(this, "remark");
+
+    /**
+     * 状态:0正常/1锁定
+     */
+    public final QueryColumn STATUS = new QueryColumn(this, "status");
+
+    /**
+     * 创建人
+     */
+    public final QueryColumn CREATE_BY = new QueryColumn(this, "create_by");
+
+    /**
+     * 创建时间
+     */
+    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
+
+    /**
+     * 更新人
+     */
+    public final QueryColumn UPDATE_BY = new QueryColumn(this, "update_by");
+
+    /**
+     * 更新时间
+     */
+    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
+
+    /**
+     * 删除标识(0正常/-1删除)
+     */
+    public final QueryColumn DEL_FLAG = new QueryColumn(this, "del_flag");
+
+    /**
+     * 所有字段
+     */
+    public final QueryColumn[] ALL_COLUMNS = new QueryColumn[]{
+            ID, DICT_ID, VALUE, LABEL, TYPE, DESCRIPTION, SORT, 
+            PARENT_ID, URL, REMARK, STATUS, CREATE_BY, CREATE_TIME, 
+            UPDATE_BY, UPDATE_TIME, DEL_FLAG
+    };
+
+    /**
+     * 构造函数
+     */
+    public SysDictTableDef() {
+        super("", "sys_dict");
+    }
+}

+ 82 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/table/SysDictTypeTableDef.java

@@ -0,0 +1,82 @@
+package com.sckw.system.table;
+
+import com.mybatisflex.core.query.QueryColumn;
+import com.mybatisflex.core.table.TableDef;
+
+/**
+ * 字典类型表 TableDef (MyBatis-Flex)
+ * @author system
+ * @date 2024
+ */
+public class SysDictTypeTableDef extends TableDef {
+
+    /**
+     * 字典类型表实例
+     */
+    public static final SysDictTypeTableDef SYS_DICT_TYPE = new SysDictTypeTableDef();
+
+    /**
+     * 主键
+     */
+    public final QueryColumn ID = new QueryColumn(this, "id");
+
+    /**
+     * 字典类型名称
+     */
+    public final QueryColumn NAME = new QueryColumn(this, "name");
+
+    /**
+     * 类型
+     */
+    public final QueryColumn TYPE = new QueryColumn(this, "type");
+
+    /**
+     * 备注
+     */
+    public final QueryColumn REMARK = new QueryColumn(this, "remark");
+
+    /**
+     * 状态:0正常/1锁定
+     */
+    public final QueryColumn STATUS = new QueryColumn(this, "status");
+
+    /**
+     * 创建人
+     */
+    public final QueryColumn CREATE_BY = new QueryColumn(this, "create_by");
+
+    /**
+     * 创建时间
+     */
+    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
+
+    /**
+     * 更新人
+     */
+    public final QueryColumn UPDATE_BY = new QueryColumn(this, "update_by");
+
+    /**
+     * 更新时间
+     */
+    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
+
+    /**
+     * 删除标识(0正常/-1删除)
+     */
+    public final QueryColumn DEL_FLAG = new QueryColumn(this, "del_flag");
+
+    /**
+     * 所有字段
+     */
+    public final QueryColumn[] ALL_COLUMNS = new QueryColumn[]{
+            ID, NAME, TYPE, REMARK, STATUS, CREATE_BY, 
+            CREATE_TIME, UPDATE_BY, UPDATE_TIME, DEL_FLAG
+    };
+
+    /**
+     * 构造函数
+     */
+    public SysDictTypeTableDef() {
+        super("", "sys_dict_type");
+    }
+}

+ 19 - 1
sckw-modules/sckw-system/src/main/resources/bootstrap.yml

@@ -10,4 +10,22 @@ spring:
 #    active: test
   main:
     allow-bean-definition-overriding: true
-    allow-circular-references: true
+    allow-circular-references: true
+
+# MyBatis-Flex 配置
+mybatis-flex:
+  # Mapper 扫描路径(同时支持 MyBatis-Plus 和 MyBatis-Flex)
+  mapper-locations:
+    - classpath*:/mapper/**/*.xml
+  # 配置选项
+  configuration:
+    # 打印 SQL(开发环境)
+    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
+  # 全局配置
+  global-config:
+    # 逻辑删除字段
+    logic-delete-column: del_flag
+    # 逻辑删除值
+    logic-delete-value: 1
+    # 逻辑未删除值
+    logic-not-delete-value: 0

+ 253 - 0
sckw-modules/sckw-system/src/test/java/com/sckw/system/repository/KwsEnterpriseRepositoryTest.java

@@ -0,0 +1,253 @@
+package com.sckw.system.repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.sckw.system.model.KwsEnterprise;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * KwsEnterpriseRepository 测试类
+ * @author system
+ * @date 2024
+ */
+@SpringBootTest(properties = {
+    "mybatis-flex.mapper-locations=classpath*:/mapper/**/*.xml"
+})
+public class KwsEnterpriseRepositoryTest {
+
+    @Autowired
+    private KwsEnterpriseRepository kwsEnterpriseRepository;
+
+    /**
+     * 测试查询所有企业列表
+     */
+    @Test
+    public void testList() {
+        List<KwsEnterprise> list = kwsEnterpriseRepository.list();
+        assertNotNull(list, "查询结果不应为null");
+        System.out.println("查询结果数: " + list.size());
+        
+        if (!list.isEmpty()) {
+            KwsEnterprise first = list.get(0);
+            System.out.println("第一条企业数据: ID=" + first.getId() + ", 企业名称=" + first.getFirmName());
+        }
+    }
+
+    /**
+     * 测试分页查询企业
+     */
+    @Test
+    public void testPageEnt() {
+        // 不带企业ID筛选的分页查询
+        int pageNum = 1;
+        int pageSize = 10;
+        IPage<KwsEnterprise> page = kwsEnterpriseRepository.pageEnt(pageNum, pageSize, null);
+        
+        assertNotNull(page, "分页结果不应为null");
+        System.out.println("总记录数: " + page.getTotal());
+        System.out.println("总页数: " + page.getPages());
+        System.out.println("当前页数据量: " + page.getRecords().size());
+        
+        if (!page.getRecords().isEmpty()) {
+            page.getRecords().forEach(ent -> 
+                System.out.println("企业: ID=" + ent.getId() + ", 名称=" + ent.getFirmName())
+            );
+        }
+    }
+
+    /**
+     * 测试根据企业ID分页查询
+     */
+    @Test
+    public void testPageEntWithId() {
+        // 先查询所有企业,获取一个存在的企业ID
+        List<KwsEnterprise> allList = kwsEnterpriseRepository.list();
+        if (!allList.isEmpty()) {
+            Long existingEntId = allList.get(0).getId();
+            
+            IPage<KwsEnterprise> page = kwsEnterpriseRepository.pageEnt(1, 10, existingEntId);
+            
+            assertNotNull(page, "分页结果不应为null");
+            System.out.println("指定企业ID查询结果数: " + page.getTotal());
+            
+            if (!page.getRecords().isEmpty()) {
+                assertEquals(existingEntId, page.getRecords().get(0).getId(), "查询结果应包含指定的企业ID");
+                System.out.println("查询到的企业: " + page.getRecords().get(0).getFirmName());
+            }
+        } else {
+            System.out.println("数据库中暂无企业数据,跳过测试");
+        }
+    }
+
+    /**
+     * 测试根据企业ID和名称查询
+     */
+    @Test
+    public void testQueryByEntIdAndName() {
+        // 仅根据企业ID查询
+        List<KwsEnterprise> allList = kwsEnterpriseRepository.list();
+        if (!allList.isEmpty()) {
+            String existingEntId = String.valueOf(allList.get(0).getId());
+            
+            List<KwsEnterprise> result1 = kwsEnterpriseRepository.queryByEntIdAndName(existingEntId, null);
+            assertNotNull(result1, "查询结果不应为null");
+            System.out.println("根据企业ID查询结果数: " + result1.size());
+            
+            // 根据企业名称模糊查询
+            if (!allList.isEmpty() && allList.get(0).getFirmName() != null) {
+                String firmName = allList.get(0).getFirmName();
+                String keyword = firmName.length() > 2 ? firmName.substring(0, 2) : firmName;
+                
+                List<KwsEnterprise> result2 = kwsEnterpriseRepository.queryByEntIdAndName(null, keyword);
+                assertNotNull(result2, "查询结果不应为null");
+                System.out.println("根据企业名称模糊查询结果数: " + result2.size());
+                
+                if (!result2.isEmpty()) {
+                    result2.forEach(ent -> 
+                        System.out.println("企业: " + ent.getFirmName() + " (审批状态: " + ent.getApproval() + ")")
+                    );
+                }
+            }
+            
+            // 同时根据企业ID和名称查询
+            if (!allList.isEmpty() && allList.get(0).getFirmName() != null) {
+                List<KwsEnterprise> result3 = kwsEnterpriseRepository.queryByEntIdAndName(
+                    existingEntId, 
+                    allList.get(0).getFirmName()
+                );
+                assertNotNull(result3, "查询结果不应为null");
+                System.out.println("同时根据ID和名称查询结果数: " + result3.size());
+            }
+        } else {
+            System.out.println("数据库中暂无企业数据,跳过测试");
+        }
+    }
+
+    /**
+     * 测试根据企业ID集合和名称查询
+     */
+    @Test
+    public void testQueryByEntIds() {
+        List<KwsEnterprise> allList = kwsEnterpriseRepository.list();
+        if (!allList.isEmpty() && allList.size() >= 2) {
+            // 构造企业ID集合
+            Set<Long> entIds = new HashSet<>();
+            entIds.add(allList.get(0).getId());
+            if (allList.size() > 1) {
+                entIds.add(allList.get(1).getId());
+            }
+            
+            // 仅根据企业ID集合查询
+            List<KwsEnterprise> result1 = kwsEnterpriseRepository.queryByEntIds(entIds, null);
+            assertNotNull(result1, "查询结果不应为null");
+            System.out.println("根据企业ID集合查询结果数: " + result1.size());
+            
+            // 同时根据企业ID集合和名称查询
+            if (!allList.isEmpty() && allList.get(0).getFirmName() != null) {
+                String firmName = allList.get(0).getFirmName();
+                String keyword = firmName.length() > 2 ? firmName.substring(0, 2) : firmName;
+                
+                List<KwsEnterprise> result2 = kwsEnterpriseRepository.queryByEntIds(entIds, keyword);
+                assertNotNull(result2, "查询结果不应为null");
+                System.out.println("根据ID集合和名称查询结果数: " + result2.size());
+                
+                if (!result2.isEmpty()) {
+                    result2.forEach(ent -> 
+                        System.out.println("企业: ID=" + ent.getId() + ", 名称=" + ent.getFirmName())
+                    );
+                }
+            }
+        } else {
+            System.out.println("数据库中企业数据不足,跳过测试");
+        }
+    }
+
+    /**
+     * 测试查询条件:验证只返回未删除、状态正常、审批通过的企业
+     */
+    @Test
+    public void testQueryConditions() {
+        List<KwsEnterprise> result = kwsEnterpriseRepository.queryByEntIdAndName(null, null);
+        
+        assertNotNull(result, "查询结果不应为null");
+        System.out.println("符合条件的企业总数: " + result.size());
+        
+        // 验证所有结果都满足条件
+        result.forEach(ent -> {
+            assertEquals(0, ent.getDelFlag(), "企业应未删除 (del_flag=0)");
+            assertEquals(0, ent.getStatus(), "企业状态应正常 (status=0)");
+            assertEquals(1, ent.getApproval(), "企业应审批通过 (approval=1)");
+        });
+        
+        if (!result.isEmpty()) {
+            System.out.println("验证通过:所有查询结果都满足未删除、状态正常、审批通过条件");
+        }
+    }
+
+    /**
+     * 测试空参数查询
+     */
+    @Test
+    public void testQueryWithNullParams() {
+        // 测试所有参数为null的情况
+        List<KwsEnterprise> result1 = kwsEnterpriseRepository.queryByEntIdAndName(null, null);
+        assertNotNull(result1, "查询结果不应为null");
+        System.out.println("空参数查询结果数: " + result1.size());
+        
+        // 测试空集合查询
+        Set<Long> emptySet = new HashSet<>();
+        List<KwsEnterprise> result2 = kwsEnterpriseRepository.queryByEntIds(emptySet, null);
+        assertNotNull(result2, "查询结果不应为null");
+        System.out.println("空ID集合查询结果数: " + result2.size());
+    }
+
+    /**
+     * 综合测试:完整的查询流程
+     */
+    @Test
+    public void testFullQueryFlow() {
+        System.out.println("\n========== 综合测试:完整的查询流程 ==========");
+        
+        // 1. 查询所有企业
+        List<KwsEnterprise> allList = kwsEnterpriseRepository.list();
+        System.out.println("1. 数据库中企业总数: " + allList.size());
+        
+        if (!allList.isEmpty()) {
+            // 2. 分页查询
+            IPage<KwsEnterprise> page = kwsEnterpriseRepository.pageEnt(1, 5, null);
+            System.out.println("2. 分页查询(第1页,每页5条): 总记录数=" + page.getTotal() + ", 当前页=" + page.getRecords().size() + "条");
+            
+            // 3. 根据企业ID查询
+            Long testEntId = allList.get(0).getId();
+            List<KwsEnterprise> byIdResult = kwsEnterpriseRepository.queryByEntIdAndName(String.valueOf(testEntId), null);
+            System.out.println("3. 根据企业ID查询结果数: " + byIdResult.size());
+            
+            // 4. 根据企业名称模糊查询
+            if (allList.get(0).getFirmName() != null) {
+                String keyword = allList.get(0).getFirmName().length() > 2 
+                    ? allList.get(0).getFirmName().substring(0, 2) 
+                    : allList.get(0).getFirmName();
+                List<KwsEnterprise> byNameResult = kwsEnterpriseRepository.queryByEntIdAndName(null, keyword);
+                System.out.println("4. 根据企业名称模糊查询结果数: " + byNameResult.size());
+            }
+            
+            // 5. 根据企业ID集合查询
+            if (allList.size() >= 2) {
+                Set<Long> entIds = new HashSet<>();
+                entIds.add(allList.get(0).getId());
+                entIds.add(allList.get(1).getId());
+                List<KwsEnterprise> byIdsResult = kwsEnterpriseRepository.queryByEntIds(entIds, null);
+                System.out.println("5. 根据企业ID集合查询结果数: " + byIdsResult.size());
+            }
+        }
+        
+        System.out.println("========== 综合测试完成 ==========\n");
+    }
+}

+ 189 - 0
sckw-modules/sckw-system/src/test/java/com/sckw/system/service/SysDictFlexBusinessServiceTest.java

@@ -0,0 +1,189 @@
+package com.sckw.system.service;
+
+import com.sckw.core.web.response.result.PageDataResult;
+
+import com.sckw.system.model.KwsEnterprise;
+import com.sckw.system.model.vo.req.SysDictReqVo;
+import com.sckw.system.model.vo.res.SysDictResp;
+import com.sckw.system.repository.KwsEnterpriseRepository;
+import com.sckw.system.service.flex.SysDictFlexBusinessService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+/**
+ * SysDictFlexBusinessService 测试类
+ * @author system
+ * @date 2024
+ */
+@SpringBootTest
+public class SysDictFlexBusinessServiceTest {
+
+    @Autowired
+    private SysDictFlexBusinessService sysDictService;
+
+
+    /**
+     * 测试新增字典
+     */
+    @Test
+    public void testInsert() {
+        SysDictReqVo.SysDictInfo entity = new SysDictReqVo.SysDictInfo();
+        entity.setLabel("测试标签");
+        entity.setValue("5");
+        entity.setType("test_type");
+        entity.setDescription("测试描述");
+        entity.setSort(1L);
+        entity.setDictId(1L);
+        entity.setRemark("测试备注");
+        
+        int rows = sysDictService.insert(entity);
+        System.out.println("插入成功,影响行数: " + rows);
+        System.out.println("生成的ID: " + entity.getId());
+    }
+
+
+
+
+    /**
+     * 测试分页查询
+     */
+    @Test
+    public void testSelectPage() {
+        // 不带条件的分页查询
+        SysDictReqVo reqVo1 = new SysDictReqVo();
+        reqVo1.setParentId("");
+        reqVo1.setPageNum(1);
+        reqVo1.setPageSize(10);
+        PageDataResult<SysDictResp> page1 = sysDictService.selectPage(reqVo1);
+        System.out.println("总记录数: " + page1.getTotal());
+        System.out.println("总页数: " + page1.getPages());
+        System.out.println("当前页数据:");
+        page1.getList().forEach(resp -> 
+            System.out.println("ID: " + resp.getId() + ", Label: " + resp.getLabel())
+        );
+        
+        // 带类型筛选的分页查询
+        SysDictReqVo reqVo2 = new SysDictReqVo();
+        reqVo2.setPageNum(1);
+        reqVo2.setPageSize(10);
+        reqVo2.setType("settlement_cycle");
+        PageDataResult<SysDictResp> page2 = sysDictService.selectPage(reqVo2);
+        System.out.println("\n类型筛选结果数: " + page2.getTotal());
+        
+        // 带状态筛选的分页查询
+        SysDictReqVo reqVo3 = new SysDictReqVo();
+        reqVo3.setPageNum(1);
+        reqVo3.setPageSize(10);
+        reqVo3.setLabel("牵引车");
+        PageDataResult<SysDictResp> page3 = sysDictService.selectPage(reqVo3);
+        System.out.println("状态筛选结果数: " + page3.getTotal());
+    }
+
+
+
+
+    /**
+     * 测试统计
+     */
+    @Test
+    public void testCount() {
+        // 统计所有
+        long total = sysDictService.count(null);
+        System.out.println("字典总数: " + total);
+        
+        // 按类型统计
+        long count = sysDictService.count("test_type");
+        System.out.println("类型为'test_type'的字典数: " + count);
+    }
+
+    /**
+     * 综合测试:完整的CRUD流程
+     */
+    @Test
+    public void testFullCrud() {
+        System.out.println("\n========== 综合测试:完整的CRUD流程 ==========");
+        
+        // 1. 新增
+        SysDictReqVo.SysDictInfo entity = new SysDictReqVo.SysDictInfo();
+        entity.setDictId(1L);
+        entity.setLabel("综合测试字典");
+        entity.setValue("full_test_dict");
+        entity.setType("full_test_type");
+        entity.setDescription("综合测试描述");
+        entity.setSort(100L);
+        entity.setRemark("综合测试");
+        
+        sysDictService.insert(entity);
+        Long id = entity.getId();
+        System.out.println("1. 新增成功,ID: " + id);
+        
+
+        
+        // 5. 更新
+        SysDictReqVo.SysDictInfo updateEntity = new SysDictReqVo.SysDictInfo();
+        updateEntity.setId(475983320463708160L);
+        updateEntity.setLabel("更新后的综合测试");
+        updateEntity.setDescription("更新后的描述");
+        sysDictService.update(updateEntity);
+        System.out.println("5. 更新成功");
+        
+        // 6. 分页查询
+        SysDictReqVo reqVo = new SysDictReqVo();
+        reqVo.setPageNum(1);
+        reqVo.setPageSize(10);
+        reqVo.setType("full_test_type");
+        PageDataResult<SysDictResp> page = sysDictService.selectPage(reqVo);
+        System.out.println("6. 分页查询结果数: " + page.getTotal());
+        
+        // 7. 搜索上级字典下拉
+        SysDictReqVo sysDictReqVo = new SysDictReqVo();
+        List<SysDictResp> searchResult = sysDictService.searchParentDictForSelect(sysDictReqVo);
+        System.out.println("7. 搜索结果数: " + searchResult.size());
+
+        
+        System.out.println("\n========== 综合测试完成 ==========");
+    }
+
+    /**
+     * 测试业务校验:重复检查
+     */
+    @Test
+    public void testDuplicateCheck() {
+        System.out.println("\n========== 测试业务校验:重复检查 ==========");
+        
+        // 创建第一条记录
+        SysDictReqVo.SysDictInfo entity1 = new SysDictReqVo.SysDictInfo();
+        entity1.setDictId(1L);
+        entity1.setLabel("重复测试");
+        entity1.setValue("duplicate_test");
+        entity1.setType("duplicate_type");
+        entity1.setSort(1L);
+        
+        int rows1 = sysDictService.insert(entity1);
+        System.out.println("1. 第一次插入成功,影响行数: " + rows1);
+        
+        // 尝试插入重复记录
+        SysDictReqVo.SysDictInfo entity2 = new SysDictReqVo.SysDictInfo();
+        entity2.setDictId(1L);
+        entity2.setLabel("重复测试");
+        entity2.setValue("duplicate_test");
+        entity2.setType("duplicate_type");
+        entity2.setSort(2L);
+        
+        int rows2 = sysDictService.insert(entity2);
+        if (rows2 == 0) {
+            System.out.println("2. 重复检查生效,插入失败");
+        } else {
+            System.out.println("2. 警告:重复检查未生效,插入成功");
+        }
+        
+        // 清理测试数据
+        if (entity1.getId() != null) {
+            sysDictService.logicDeleteById(entity1.getId());
+            System.out.println("3. 清理测试数据完成");
+        }
+    }
+}

+ 136 - 0
sckw-modules/sckw-system/src/test/java/com/sckw/system/service/flex/SysDictTypeServiceTest.java

@@ -0,0 +1,136 @@
+package com.sckw.system.service.flex;
+
+import com.sckw.core.web.response.result.PageDataResult;
+import com.sckw.system.entity.flex.SysDictTypeEntity;
+
+import com.sckw.system.model.SysDictType;
+import com.sckw.system.model.vo.req.SysDictTypeReqVo;
+import com.sckw.system.model.vo.res.SysDictTypeResp;
+import com.sckw.system.repository.flex.SysDictTypeService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * SysDictTypeService 测试类
+ * @author system
+ * @date 2024
+ */
+@SpringBootTest
+public class SysDictTypeServiceTest {
+
+    @Autowired
+    private SysDictTypeService sysDictTypeService;
+
+    /**
+     * 测试新增字典类型
+     */
+    @Test
+    public void testInsert() {
+        SysDictTypeReqVo.SysDictTypeInfo entity = new SysDictTypeReqVo.SysDictTypeInfo();
+        // 不要手动设置 id,让数据库自动生成
+        entity.setName("测试字典类型");
+        entity.setType("test_dict_type1");
+        entity.setRemark("测试备注1");
+        int rows = sysDictTypeService.insert(entity);
+        System.out.println("插入成功,影响行数: " + rows);
+        System.out.println("生成的ID: " + entity.getId());
+    }
+
+
+
+
+
+
+
+    /**
+     * 测试分页查询字典类型
+     */
+    @Test
+    public void testSelectPage() {
+        // 不带条件的分页查询
+        PageDataResult<SysDictTypeResp> page1 = sysDictTypeService.selectPage(new SysDictTypeReqVo());
+        System.out.println("总记录数: " + page1.getTotal());
+        System.out.println("总页数: " + page1.getPages());
+        System.out.println("当前页数据:");
+        page1.getList().forEach(System.out::println);
+        SysDictTypeReqVo sysDictTypeReqVo = new SysDictTypeReqVo();
+        sysDictTypeReqVo.setName("测试字典类型");
+        // 带名称搜索的分页查询
+        PageDataResult<SysDictTypeResp> page2 = sysDictTypeService.selectPage(sysDictTypeReqVo);
+        System.out.println("\n名称搜索结果数: " + page2.getTotal());
+        SysDictTypeReqVo sysDictTypeReqVo1 = new SysDictTypeReqVo();
+        sysDictTypeReqVo.setName("测试字典类型");
+        // 带类型搜索的分页查询
+        PageDataResult<SysDictTypeResp> page3 = sysDictTypeService.selectPage(sysDictTypeReqVo1);
+        System.out.println("类型搜索结果数: " + page3.getTotal());
+        SysDictTypeReqVo sysDictTypeReqVo2 = new SysDictTypeReqVo();
+        sysDictTypeReqVo.setStatus(0);
+        // 带状态筛选的分页查询
+        PageDataResult<SysDictTypeResp> page4 = sysDictTypeService.selectPage(sysDictTypeReqVo2);
+        System.out.println("状态筛选结果数: " + page4.getTotal());
+    }
+
+    /**
+     * 测试搜索下拉列表(支持输入搜索)
+     */
+    @Test
+    public void testSearchForSelect() {
+        // 不带关键词搜索
+        List<SysDictTypeResp> list1 = sysDictTypeService.searchForSelect(null);
+        System.out.println("不带关键词查询结果数: " + list1.size());
+        list1.forEach(entity -> 
+            System.out.println("ID: " + entity.getId() + ", Name: " + entity.getName() + ", Type: " + entity.getType())
+        );
+        
+        // 按名称搜索
+        List<SysDictTypeResp> list2 = sysDictTypeService.searchForSelect("测试字典类型");
+        System.out.println("\n按名称搜索结果数: " + list2.size());
+        list2.forEach(entity -> 
+            System.out.println("ID: " + entity.getId() + ", Name: " + entity.getName() + ", Type: " + entity.getType())
+        );
+        
+        // 按类型搜索
+        List<SysDictTypeResp> list3 = sysDictTypeService.searchForSelect("test");
+        System.out.println("\n按类型搜索结果数: " + list3.size());
+        list3.forEach(entity -> 
+            System.out.println("ID: " + entity.getId() + ", Name: " + entity.getName() + ", Type: " + entity.getType())
+        );
+    }
+
+
+
+    /**
+     * 综合测试:完整的CRUD流程
+     */
+    @Test
+    public void testFullCrud() {
+        // 1. 新增
+        SysDictTypeReqVo.SysDictTypeInfo entity = new SysDictTypeReqVo.SysDictTypeInfo();
+        entity.setName("综合测试字典类型");
+        entity.setType("full_test_type1");
+        entity.setRemark("综合测试");
+        sysDictTypeService.insert(entity);
+        Long id = entity.getId();
+        System.out.println("1. 新增成功,ID: " + id);
+
+
+        
+        // 5. 搜索测试
+        List<SysDictTypeResp> searchResult = sysDictTypeService.searchForSelect("更新后");
+        System.out.println("5. 搜索结果数: " + searchResult.size());
+        
+        // 6. 逻辑删除
+        sysDictTypeService.logicDeleteById(id);
+        System.out.println("6. 逻辑删除成功");
+        
+        // 7. 验证逻辑删除(应查询不到)
+        List<SysDictTypeResp> afterDelete = sysDictTypeService.searchForSelect("更新后");
+        System.out.println("7. 逻辑删除后搜索结果数: " + afterDelete.size());
+        
+
+    }
+}

+ 16 - 1
sckw-modules/sckw-transport/pom.xml

@@ -152,7 +152,22 @@
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
         </dependency>
-
+        <!-- MyBatis-Flex 依赖 (Spring Boot 3.x 兼容版本) -->
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot3-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Spring Boot Test Starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>