jerry 3 тижнів тому
батько
коміт
34ec63fa34

+ 11 - 24
app/api/router.py

@@ -30,7 +30,7 @@ from app.schemas.emails import VasEmailCreate, VasEmailOut
 from app.schemas.card import CardCreate, CardOut
 from app.schemas.task import TaskCreate, TaskOut, TaskUpdate
 from app.schemas.short_url import ShortUrlCreate, ShortUrlOut
-from app.schemas.http_session import HttpSessionCreate, HttpSessionUpdate,HttpSessionOut
+from app.schemas.http_session import HttpSessionCreate,HttpSessionOut
 from app.schemas.auth import SendBindCodeRequest, SendResetCodeRequest, BindEmailRequest, ResetPasswordRequest, LoginRequest, LoginData, AutoRegisterRequest, AutoRegisterData
 from app.schemas.user import VasUserCreate, VasUserUpdate, VasUserSetProfiles, VasUserOut
 from app.schemas.product import VasProductCreate, VasProductUpdate, VasProductOut
@@ -405,27 +405,6 @@ async def http_session_create(
     obj = await HttpSessionService.create(db, data)
     return success(data=obj)
 
-
-@admin_required_router.delete("/http-session", summary="删除http session", tags=["会话管理"], response_model=ApiResponse)
-async def http_session_delete_by_sid(
-    session_id: str = Query(...),
-    db: AsyncSession = Depends(get_db)
-):
-    logger.info(f"[Delete HttpSession] sid={session_id}")
-    await HttpSessionService.delete_by_sid(db, session_id)
-    return success()
-
-
-@admin_required_router.put("/http-session", summary="更新http session", tags=["会话管理"], response_model=ApiResponse[HttpSessionOut])
-async def http_session_update_by_sid(
-    session_id: str = Query(...),
-    data: HttpSessionUpdate = Body(...),
-    db: AsyncSession = Depends(get_db)
-):
-    logger.info(f"[Update HttpSession] sid={session_id}")
-    obj = await HttpSessionService.update_by_sid(db, session_id, data)
-    return success(data=obj)
-
 @admin_required_router.get("/http-session", summary="读取http session", tags=["会话管理"],response_model=ApiResponse[HttpSessionOut])
 async def http_session_get_by_sid(
     session_id: str = Query(...),
@@ -1458,12 +1437,12 @@ async def vas_task_update(
     return success(data=task)
 
 @admin_required_router.get("/vas/task/get_by_order", summary="根据订单查找任务", tags=["Visafly签证系统"], response_model=ApiResponse[List[VasTaskOut]])
-async def vas_task_pending(
+async def vas_task_query_by_order(
     order_id: str = Query(..., description="订单编号"),
     script_version: str = Query("", description="脚本版本, 用来向后兼容"),
     db: AsyncSession = Depends(get_db)
 ):
-    tasks = await VasTaskService.get_active_task_by_order_id(db, order_id)
+    tasks = await VasTaskService.get_task_by_order_id(db, order_id)
     return success(data=tasks)
 
 @admin_required_router.post("/vas/task/pause", summary="暂停任务", tags=["Visafly签证系统"], response_model=ApiResponse[VasTaskOut])
@@ -1471,6 +1450,14 @@ async def vas_task_pause(task_id:int, db: AsyncSession = Depends(get_db)):
     obj = await VasTaskService.pause(db, task_id)
     return success(data=obj)
 
+@admin_required_router.get("/vas/task/detail", summary="根据taskid查找任务", tags=["Visafly签证系统"], response_model=ApiResponse[VasTaskOut])
+async def vas_task_query_by_id(
+    task_id: int = Query(..., description="任务Id"),
+    db: AsyncSession = Depends(get_db)
+):
+    task = await VasTaskService.get_task_by_id(db, task_id)
+    return success(data=task)
+
 @admin_required_router.post("/vas/task/return_to_queue", summary="重新进入等候状态", tags=["Visafly签证系统"], response_model=ApiResponse[VasTaskOut])
 async def vas_task_return_to_queue(task_id:int, db: AsyncSession = Depends(get_db)):
     obj = await VasTaskService.return_to_queue(db, task_id)

+ 1 - 0
app/models/http_session.py

@@ -7,6 +7,7 @@ class HttpSession(Base):
 
     session_id = Column(String(128), primary_key=True)
     local_storage = Column(Text)
+    session_storage = Column(Text)
     cookies = Column(Text)
     user_agent = Column(String(512))
     proxy = Column(String(256))

+ 1 - 3
app/schemas/http_session.py

@@ -4,6 +4,7 @@ from datetime import datetime
 
 class HttpSessionBase(BaseModel):
     local_storage: Optional[str] = None
+    session_storage: Optional[str] = None
     cookies: Optional[str] = None
     user_agent: Optional[str] = None
     proxy: Optional[str] = None
@@ -12,9 +13,6 @@ class HttpSessionBase(BaseModel):
 class HttpSessionCreate(HttpSessionBase):
     session_id: str
 
-class HttpSessionUpdate(HttpSessionBase):
-    pass
-
 class HttpSessionOut(HttpSessionBase):
     session_id: str
     create_at: datetime

+ 1 - 1
app/services/email_authorizations_service.py

@@ -30,7 +30,7 @@ _PROXY_LOCK = threading.Lock()
 class EmailAuthorizationService:
     
     DEFAULT_READ_TOP_N_EMAIL = 10       
-    RETRY_DELAY_SECONDS = 5             
+    RETRY_DELAY_SECONDS = 3             
     
     # =================================================================
     # 数据库操作 (DB CRUD) - 使用 AsyncSession

+ 1 - 41
app/services/http_session_service.py

@@ -5,7 +5,7 @@ from sqlalchemy import select, delete
 
 from app.core.biz_exception import NotFoundError
 from app.models.http_session import HttpSession
-from app.schemas.http_session import HttpSessionCreate, HttpSessionUpdate
+from app.schemas.http_session import HttpSessionCreate
 
 
 class HttpSessionService:
@@ -37,43 +37,3 @@ class HttpSessionService:
             raise NotFoundError("Session not found")
 
         return obj
-
-    # ============================
-    # 根据 session_id 删除
-    # ============================
-    @staticmethod
-    async def delete_by_sid(
-        db: AsyncSession,
-        session_id: str
-    ) -> bool:
-        stmt = delete(HttpSession).where(HttpSession.session_id == session_id)
-        result = await db.execute(stmt)
-
-        if result.rowcount == 0:
-            raise NotFoundError("Session not found")
-
-        await db.commit()
-        return True
-
-    # ============================
-    # 根据 session_id 更新
-    # ============================
-    @staticmethod
-    async def update_by_sid(
-        db: AsyncSession,
-        session_id: str,
-        data: HttpSessionUpdate
-    ) -> HttpSession:
-        stmt = select(HttpSession).where(HttpSession.session_id == session_id)
-        result = await db.execute(stmt)
-        obj = result.scalar_one_or_none()
-
-        if not obj:
-            raise NotFoundError("Session not found")
-
-        for field, value in data.dict(exclude_unset=True).items():
-            setattr(obj, field, value)
-
-        await db.commit()
-        await db.refresh(obj)
-        return obj

+ 1 - 1
app/services/troov_session_service.py

@@ -91,7 +91,7 @@ class TroovSessionService:
                 stmt=stmt,
                 model=TroovSession,
                 keyword=keyword,
-                fields=["session_id", "source"] # 根据业务需求定义支持模糊搜索的字段
+                fields=["session_id", "slot_date", "slot_time", "source"] # 根据业务需求定义支持模糊搜索的字段
             )
 
         stmt = stmt.order_by(TroovSession.created_at.asc())

+ 15 - 2
app/services/vas_task_service.py

@@ -204,16 +204,29 @@ class VasTaskService:
         return obj
 
     @staticmethod
-    async def get_active_task_by_order_id(
+    async def get_task_by_order_id(
         db: AsyncSession,
         order_id: str,
     ) -> List[VasTask]:
         stmt = select(VasTask).where(
-            VasTask.status == "pending",
             VasTask.order_id == order_id,
         )
         result = await db.execute(stmt)
         return result.scalars().all()
+    
+    @staticmethod
+    async def get_task_by_id(
+        db: AsyncSession,
+        task_id: int,
+    ) -> VasTask:
+        stmt = select(VasTask).where(
+            VasTask.id == task_id,
+        )
+        result = await db.execute(stmt)
+        rec = result.scalar_one_or_none()
+        if not rec:
+            raise NotFoundError("Task not exist")
+        return rec
 
     @staticmethod
     async def return_to_queue(db: AsyncSession, id: int) -> VasTask: