feat: 迁移奶龙风控业务模块与演示文档
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""风控 Agent 只读工具的输入契约。"""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
RISK_LEVEL = Literal["低", "中", "高"]
|
||||
|
||||
|
||||
class RiskAlertQuery(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", frozen=True)
|
||||
|
||||
customer_no: str | None = Field(default=None, max_length=64)
|
||||
product_code: str | None = Field(default=None, max_length=64)
|
||||
product_name: str | None = Field(default=None, max_length=128)
|
||||
risk_level: RISK_LEVEL | None = None
|
||||
rule_code: str | None = Field(default=None, pattern=r"^RW-[0-9]{3}$")
|
||||
start_time: datetime | None = None
|
||||
end_time: datetime | None = None
|
||||
|
||||
@field_validator("customer_no", "product_code", "product_name", "rule_code")
|
||||
@classmethod
|
||||
def text_must_not_be_blank(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
value = value.strip()
|
||||
if not value:
|
||||
raise ValueError("查询条件不能为空")
|
||||
return value
|
||||
|
||||
|
||||
class RiskAlertEvidenceQuery(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", frozen=True)
|
||||
|
||||
alert_no: str = Field(min_length=1, max_length=64, pattern=r"^[A-Za-z0-9_-]+$")
|
||||
|
||||
@field_validator("alert_no")
|
||||
@classmethod
|
||||
def alert_no_must_not_be_blank(cls, value: str) -> str:
|
||||
value = value.strip()
|
||||
if not value:
|
||||
raise ValueError("预警编号不能为空")
|
||||
return value
|
||||
Reference in New Issue
Block a user