Skip to content

Commit 6f1c83d

Browse files
authored
feat: The judge supports startsWith and endsWith (#4217)
1 parent c0c15d8 commit 6f1c83d

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

apps/application/flow/compare/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
from .contain_compare import *
11+
from .end_with import EndWithCompare
1112
from .equal_compare import *
1213
from .ge_compare import *
1314
from .gt_compare import *
@@ -23,8 +24,10 @@
2324
from .len_lt_compare import *
2425
from .lt_compare import *
2526
from .not_contain_compare import *
27+
from .start_with import StartWithCompare
2628

2729
compare_handle_list = [GECompare(), GTCompare(), ContainCompare(), EqualCompare(), LTCompare(), LECompare(),
2830
LenLECompare(), LenGECompare(), LenEqualCompare(), LenGTCompare(), LenLTCompare(),
2931
IsNullCompare(),
30-
IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare()]
32+
IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare(), StartWithCompare(),
33+
EndWithCompare()]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# coding=utf-8
2+
"""
3+
@project: MaxKB
4+
@Author:虎虎
5+
@file: start_with.py
6+
@date:2025/10/20 10:37
7+
@desc:
8+
"""
9+
from typing import List
10+
11+
from application.flow.compare import Compare
12+
13+
14+
class EndWithCompare(Compare):
15+
16+
def support(self, node_id, fields: List[str], source_value, compare, target_value):
17+
if compare == 'end_with':
18+
return True
19+
20+
def compare(self, source_value, compare, target_value):
21+
source_value = str(source_value)
22+
return source_value.endswith(str(target_value))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# coding=utf-8
2+
"""
3+
@project: MaxKB
4+
@Author:虎虎
5+
@file: start_with.py
6+
@date:2025/10/20 10:37
7+
@desc:
8+
"""
9+
from typing import List
10+
11+
from application.flow.compare import Compare
12+
13+
14+
class StartWithCompare(Compare):
15+
16+
def support(self, node_id, fields: List[str], source_value, compare, target_value):
17+
if compare == 'start_with':
18+
return True
19+
20+
def compare(self, source_value, compare, target_value):
21+
source_value = str(source_value)
22+
return source_value.startswith(str(target_value))

ui/src/workflow/common/data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ export const variableAggregationNode = {
344344
},
345345
}
346346

347-
348347
export const variableAssignNode = {
349348
type: WorkflowType.VariableAssignNode,
350349
text: t('views.applicationWorkflow.nodes.variableAssignNode.text'),
@@ -744,6 +743,8 @@ export const compareList = [
744743
{ value: 'len_lt', label: t('views.applicationWorkflow.compare.len_lt') },
745744
{ value: 'is_true', label: t('views.applicationWorkflow.compare.is_true') },
746745
{ value: 'is_not_true', label: t('views.applicationWorkflow.compare.is_not_true') },
746+
{ value: 'start_with', label: 'startWith' },
747+
{ value: 'end_with', label: 'endWith' },
747748
]
748749

749750
export const nodeDict: any = {

0 commit comments

Comments
 (0)