修复
This commit is contained in:
@@ -247,6 +247,16 @@ async def list_domains(db: AsyncSession = Depends(get_db), _: bool = Depends(req
|
||||
select(Domain).options(selectinload(Domain.server), selectinload(Domain.acme_config)).order_by(Domain.id)
|
||||
)
|
||||
domains = result.scalars().all()
|
||||
|
||||
# 查询每个域名的最新部署日志
|
||||
deploy_status = {}
|
||||
log_result = await db.execute(
|
||||
select(DeployLog).order_by(DeployLog.id.desc())
|
||||
)
|
||||
for log in log_result.scalars().all():
|
||||
if log.domain_id not in deploy_status:
|
||||
deploy_status[log.domain_id] = log.status == "success"
|
||||
|
||||
return [
|
||||
{
|
||||
"id": d.id,
|
||||
@@ -260,6 +270,7 @@ async def list_domains(db: AsyncSession = Depends(get_db), _: bool = Depends(req
|
||||
"reload_cmd": d.reload_cmd,
|
||||
"version": d.version,
|
||||
"cert_not_after": d.cert_not_after.isoformat() if d.cert_not_after else None,
|
||||
"deploy_success": deploy_status.get(d.id),
|
||||
}
|
||||
for d in domains
|
||||
]
|
||||
@@ -486,6 +497,10 @@ async def issue_cert(domain_id: int, db: AsyncSession = Depends(get_db), _: bool
|
||||
if info:
|
||||
domain.cert_not_after = datetime.fromisoformat(info["not_after"])
|
||||
domain.version = str(int(domain.version or "0") + 1)
|
||||
logger.info(f"证书信息已更新: {domain.domain}, 过期时间: {info['not_after']}")
|
||||
else:
|
||||
logger.warning(f"无法获取证书信息: {domain.domain}")
|
||||
domain.version = str(int(domain.version or "0") + 1)
|
||||
|
||||
await db.flush()
|
||||
return {"success": success, "message": msg}
|
||||
|
||||
Reference in New Issue
Block a user