revert(data): 还原 SQL 函数接口

This commit is contained in:
2024-09-04 20:21:07 +08:00
parent 260f484af9
commit 9e5f33b2c9
2 changed files with 11 additions and 5 deletions

View File

@@ -18,6 +18,8 @@ package top.continew.starter.data.core.enums;
import top.continew.starter.data.core.function.ISqlFunction; import top.continew.starter.data.core.function.ISqlFunction;
import java.io.Serializable;
/** /**
* 数据库类型枚举 * 数据库类型枚举
* *
@@ -31,8 +33,8 @@ public enum DatabaseType implements ISqlFunction {
*/ */
MYSQL("MySQL") { MYSQL("MySQL") {
@Override @Override
public String findInSet() { public String findInSet(Serializable value, String set) {
return "find_in_set({0}, {1}) <> 0"; return "find_in_set('%s', %s) <> 0".formatted(value, set);
} }
}, },
@@ -41,8 +43,8 @@ public enum DatabaseType implements ISqlFunction {
*/ */
POSTGRE_SQL("PostgreSQL") { POSTGRE_SQL("PostgreSQL") {
@Override @Override
public String findInSet() { public String findInSet(Serializable value, String set) {
return "(select position(',{0},' in ','||{1}||',')) <> 0"; return "(select position(',%s,' in ','||%s||',')) <> 0".formatted(value, set);
} }
},; },;

View File

@@ -16,6 +16,8 @@
package top.continew.starter.data.core.function; package top.continew.starter.data.core.function;
import java.io.Serializable;
/** /**
* SQL 函数接口 * SQL 函数接口
* *
@@ -27,7 +29,9 @@ public interface ISqlFunction {
/** /**
* find_in_set 函数 * find_in_set 函数
* *
* @param value 值
* @param set 集合
* @return 函数实现 * @return 函数实现
*/ */
String findInSet(); String findInSet(Serializable value, String set);
} }