fix(data): 移除 SQL 函数接口中的 SQL 拼接

This commit is contained in:
2024-08-12 23:55:34 +08:00
parent b9f106572a
commit 6693cd49b9
2 changed files with 5 additions and 11 deletions

View File

@@ -18,8 +18,6 @@ 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;
/** /**
* 数据库类型枚举 * 数据库类型枚举
* *
@@ -33,8 +31,8 @@ public enum DatabaseType implements ISqlFunction {
*/ */
MYSQL("MySQL") { MYSQL("MySQL") {
@Override @Override
public String findInSet(Serializable value, String set) { public String findInSet() {
return "find_in_set('%s', %s) <> 0".formatted(value, set); return "find_in_set({0}, {1}) <> 0";
} }
}, },
@@ -43,8 +41,8 @@ public enum DatabaseType implements ISqlFunction {
*/ */
POSTGRE_SQL("PostgreSQL") { POSTGRE_SQL("PostgreSQL") {
@Override @Override
public String findInSet(Serializable value, String set) { public String findInSet() {
return "(select position(',%s,' in ','||%s||',')) <> 0".formatted(value, set); return "(select position(',{0},' in ','||{1}||',')) <> 0";
} }
},; },;

View File

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