Skip to content

Commit

Permalink
feat: 通知组内新增变量 --story=119072639
Browse files Browse the repository at this point in the history
1. 优化解析器处理逻辑
  • Loading branch information
0RAJA committed Sep 12, 2024
1 parent bd29f57 commit c94089c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/backend/apps/notice/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MemberVariable(TextChoices):
"""

OPERATOR = "$OPERATOR", gettext_lazy("责任人")
OPERATOR_SUPERIOR = "$OPERATOR_SUPERIOR", gettext_lazy("责任人上级")
OPERATOR_LEADER = "$OPERATOR_LEADER", gettext_lazy("责任人上级")

@classmethod
def match(cls, key: str) -> Optional["MemberVariable"]:
Expand Down
9 changes: 3 additions & 6 deletions src/backend/apps/notice/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

class MemberVariableParserBase(abc.ABC):
def is_skip(self, member: str) -> bool:
return False
"""默认跳过变量"""
return MemberVariable.match(member) is not None

@abc.abstractmethod
def parse_member(self, member: Union[str, MemberVariable]) -> str:
Expand Down Expand Up @@ -55,7 +56,7 @@ def parse_member(self, member: Union[str, MemberVariable]) -> str:
match member:
case MemberVariable.OPERATOR:
return self.operator
case MemberVariable.OPERATOR_SUPERIOR:
case MemberVariable.OPERATOR_LEADER:
return resource.user_manage.retrieve_leader(id=self.operator)
return member

Expand All @@ -65,9 +66,5 @@ class IgnoreMemberVariableParser(MemberVariableParserBase):
忽略成员变量解析器
"""

def is_skip(self, member: str) -> bool:
"""成员变量跳过"""
return MemberVariable.match(member) is not None

def parse_member(self, member: Union[str, MemberVariable]) -> str:
return member
4 changes: 4 additions & 0 deletions src/backend/services/web/risk/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@


class RiskNoticeParser(MemberVariableParser):
def is_skip(self, member: str) -> bool:
"""对所有变量进行处理"""
return False

def __init__(self, risk: Risk):
super().__init__(operator=risk.operator)

0 comments on commit c94089c

Please sign in to comment.