Commit f5ed040943695389e559087661bae25d9fcbe074

Authored by YunaiV
1 parent 87c6c90a

【代码优化】全局:数据库 findInSet 兼容

yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/enums/DbTypeEnum.java
... ... @@ -11,10 +11,13 @@ import java.util.Optional;
11 11 import java.util.function.Function;
12 12 import java.util.stream.Collectors;
13 13  
14   -
  14 +/**
  15 + * 针对 MyBatis Plus 的 {@link DbType} 增强,补充更多信息
  16 + */
15 17 @Getter
16 18 @AllArgsConstructor
17 19 public enum DbTypeEnum {
  20 +
18 21 /**
19 22 * MySQL
20 23 */
... ... @@ -27,6 +30,8 @@ public enum DbTypeEnum {
27 30  
28 31 /**
29 32 * PostgreSQL
  33 + *
  34 + * 华为 openGauss 使用 ProductName 与 PostgreSQL 相同
30 35 */
31 36 POSTGRE_SQL(DbType.POSTGRE_SQL,"PostgreSQL", "POSITION('#{value}' IN #{column}) <> 0"),
32 37  
... ... @@ -44,8 +49,6 @@ public enum DbTypeEnum {
44 49 * 人大金仓
45 50 */
46 51 KINGBASE_ES(DbType.KINGBASE_ES, "KingbaseES", "POSITION('#{value}' IN #{column}) <> 0"),
47   -
48   - // 华为openGauss 使用ProductName 与 PostgreSQL相同
49 52 ;
50 53  
51 54 public static final Map<String, DbTypeEnum> MAP_BY_NAME = Arrays.stream(values())
... ... @@ -54,9 +57,17 @@ public enum DbTypeEnum {
54 57 public static final Map<DbType, DbTypeEnum> MAP_BY_MP = Arrays.stream(values())
55 58 .collect(Collectors.toMap(DbTypeEnum::getMpDbType, Function.identity()));
56 59  
57   -
  60 + /**
  61 + * MyBatis Plus 类型
  62 + */
58 63 private final DbType mpDbType;
  64 + /**
  65 + * 数据库产品名
  66 + */
59 67 private final String productName;
  68 + /**
  69 + * SQL FIND_IN_SET 模板
  70 + */
60 71 private final String findInSetTemplate;
61 72  
62 73 public static DbType find(String databaseProductName) {
... ...
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java
... ... @@ -102,4 +102,5 @@ public class MyBatisUtils {
102 102 .replace("#{column}", column)
103 103 .replace("#{value}", StrUtil.toString(value));
104 104 }
  105 +
105 106 }
... ...