feat(oa): expose GET /instances/history for start-page history
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
32824fdbf5
commit
37e8ce52a7
1 file changed
+44
@@ -18,6 +18,8 @@ from app.services.oa_receive_account import normalize_account_fields
|
||||
|
||||
router = APIRouter(prefix="/web/admin/oa-approval", tags=["OA审批"])
|
||||
|
||||
OA_START_HISTORY_ALL_PERM = "oa:start:history:all"
|
||||
|
||||
|
||||
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
tenant = (user.get("tenant_no") or "").strip()
|
||||
@@ -893,6 +895,48 @@ async def start_oa_instance(
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.get("/instances/history")
|
||||
async def list_oa_instance_history(
|
||||
appId: str = Query(..., description="流程应用 ID"),
|
||||
instanceId: str = Query(""),
|
||||
instanceStatus: str = Query(""),
|
||||
initiatorName: str = Query(""),
|
||||
applyTimeFrom: str = Query(""),
|
||||
applyTimeTo: str = Query(""),
|
||||
finishTimeFrom: str = Query(""),
|
||||
finishTimeTo: str = Query(""),
|
||||
page: int = Query(1),
|
||||
pageSize: int = Query(20, alias="pageSize"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
from app.core.menu_guard import user_has_menu_perm
|
||||
from app.services.oa_engine import OaEngineError, list_instance_history
|
||||
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
can_view_all = user_has_menu_perm(db, user, OA_START_HISTORY_ALL_PERM)
|
||||
data = list_instance_history(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id") or "",
|
||||
can_view_all=can_view_all,
|
||||
app_id=appId,
|
||||
instance_id=instanceId or None,
|
||||
initiator_name=initiatorName or None,
|
||||
apply_time_from=applyTimeFrom or None,
|
||||
apply_time_to=applyTimeTo or None,
|
||||
finish_time_from=finishTimeFrom or None,
|
||||
finish_time_to=finishTimeTo or None,
|
||||
instance_status=instanceStatus or None,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
)
|
||||
return success_response(data)
|
||||
except OaEngineError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.get("/instances/{instance_id}")
|
||||
async def get_oa_instance(
|
||||
instance_id: str,
|
||||
|
||||
Reference in new issue
Block a user