```
feat(ai_agent): 完善AI适配器和服务功能 - 添加OpenClaw和Hermes健康检查接口 - 实现OpenClaw工具调用功能 - 重构AI适配器使用常量定义 - 增加AI技能系统支持 - 更新配置文件中的默认模型提供者设置 refactor(scheduler): 使用常量替换硬编码值 - 将硬编码的actor值替换为ActorValue常量 - 将receive_id_type替换为FeishuReceiveIdType枚举 refactor(audit): 统一审计日志常量使用 - 将硬编码的actor、source、risk_level等值替换为对应常量 - 更新审核服务中的状态和操作常量引用 refactor(approvals): 标准化审批模块常量使用 - 将applicant默认值替换为ActorValue.API常量 - 使用ApprovalStatus常量替代硬编码状态值 - 更新审核操作常量引用 ```
This commit is contained in:
@@ -2,6 +2,8 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.core.constants import ActorValue
|
||||
|
||||
|
||||
class ReadonlyQueryRequest(BaseModel):
|
||||
"""Readonly SQL query request for the legacy MySQL connection."""
|
||||
@@ -41,7 +43,7 @@ class LegacyProjectSyncRequest(BaseModel):
|
||||
)
|
||||
limit: int = Field(default=100, ge=1, le=500)
|
||||
dry_run: bool = True
|
||||
actor: str = "api"
|
||||
actor: str = ActorValue.API
|
||||
|
||||
|
||||
class LegacyProjectSyncResult(BaseModel):
|
||||
|
||||
@@ -9,10 +9,13 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.constants import ActorValue
|
||||
from app.core.config import get_settings
|
||||
from app.core.database import legacy_engine
|
||||
from app.modules.audit.constants import AuditAction, AuditRiskLevel, AuditSource, AuditStatus
|
||||
from app.modules.audit.schemas import AuditLogCreate
|
||||
from app.modules.audit.service import AuditService
|
||||
from app.modules.business.constants import BusinessDomain, SourceSystem, StatusValue
|
||||
from app.modules.business.models import LegacySyncRun, Project
|
||||
from app.modules.business.service import serialize_model
|
||||
|
||||
@@ -152,10 +155,10 @@ class LegacyMySQLService:
|
||||
return {
|
||||
"code": code,
|
||||
"external_id": str(external_id) if external_id is not None else code,
|
||||
"source_system": "legacy_mysql",
|
||||
"source_system": SourceSystem.LEGACY_MYSQL,
|
||||
"name": self._value(row, field_map, "name", "未命名项目"),
|
||||
"owner": self._value(row, field_map, "owner", None),
|
||||
"status": self._value(row, field_map, "status", "未知"),
|
||||
"status": self._value(row, field_map, "status", StatusValue.UNKNOWN),
|
||||
"progress_percent": int(
|
||||
self._value(
|
||||
row,
|
||||
@@ -182,7 +185,7 @@ class LegacyMySQLService:
|
||||
field_map: dict[str, str] | None = None,
|
||||
limit: int = 100,
|
||||
dry_run: bool = True,
|
||||
actor: str = "api",
|
||||
actor: str = ActorValue.API,
|
||||
) -> dict[str, Any]:
|
||||
if self.db is None:
|
||||
raise HTTPException(
|
||||
@@ -216,7 +219,7 @@ class LegacyMySQLService:
|
||||
continue
|
||||
|
||||
stmt = select(Project).where(
|
||||
Project.source_system == "legacy_mysql",
|
||||
Project.source_system == SourceSystem.LEGACY_MYSQL,
|
||||
Project.external_id == payload["external_id"],
|
||||
)
|
||||
record = self.db.execute(stmt).scalar_one_or_none()
|
||||
@@ -258,9 +261,9 @@ class LegacyMySQLService:
|
||||
}
|
||||
sync_run = LegacySyncRun(
|
||||
code=f"SYNC-PROJECTS-{datetime.utcnow():%Y%m%d%H%M%S%f}",
|
||||
domain="projects",
|
||||
domain=BusinessDomain.PROJECTS,
|
||||
source_table="LEGACY_PROJECT_QUERY",
|
||||
status="dry_run" if dry_run else "success",
|
||||
status=StatusValue.DRY_RUN if dry_run else AuditStatus.SUCCESS,
|
||||
finished_at=datetime.utcnow(),
|
||||
created_count=created,
|
||||
updated_count=updated,
|
||||
@@ -275,10 +278,10 @@ class LegacyMySQLService:
|
||||
AuditService(self.db).log(
|
||||
AuditLogCreate(
|
||||
actor=actor,
|
||||
source="legacy_mysql",
|
||||
action="sync_projects",
|
||||
target_type="projects",
|
||||
risk_level="medium",
|
||||
source=AuditSource.LEGACY_MYSQL,
|
||||
action=AuditAction.LEGACY_SYNC_PROJECTS,
|
||||
target_type=BusinessDomain.PROJECTS,
|
||||
risk_level=AuditRiskLevel.MEDIUM,
|
||||
request_payload={
|
||||
"source_query": source_query or "LEGACY_PROJECT_QUERY",
|
||||
"field_map": field_map,
|
||||
|
||||
Reference in New Issue
Block a user