Skip to content

Commit

Permalink
revert(data): 还原 SQL 函数接口
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 4, 2024
1 parent 260f484 commit 9e5f33b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import top.continew.starter.data.core.function.ISqlFunction;

import java.io.Serializable;

/**
* 数据库类型枚举
*
Expand All @@ -31,8 +33,8 @@ public enum DatabaseType implements ISqlFunction {
*/
MYSQL("MySQL") {
@Override
public String findInSet() {
return "find_in_set({0}, {1}) <> 0";
public String findInSet(Serializable value, String set) {
return "find_in_set('%s', %s) <> 0".formatted(value, set);
}
},

Expand All @@ -41,8 +43,8 @@ public String findInSet() {
*/
POSTGRE_SQL("PostgreSQL") {
@Override
public String findInSet() {
return "(select position(',{0},' in ','||{1}||',')) <> 0";
public String findInSet(Serializable value, String set) {
return "(select position(',%s,' in ','||%s||',')) <> 0".formatted(value, set);
}
},;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package top.continew.starter.data.core.function;

import java.io.Serializable;

/**
* SQL 函数接口
*
Expand All @@ -27,7 +29,9 @@ public interface ISqlFunction {
/**
* find_in_set 函数
*
* @param value 值
* @param set 集合
* @return 函数实现
*/
String findInSet();
String findInSet(Serializable value, String set);
}

0 comments on commit 9e5f33b

Please sign in to comment.