fix(routes): 优化路由导入错误处理并调整职位需求转换
- 优化 job 路由导入时的异常捕获,添加错误信息和堆栈打印 - 修改职位接口中 requirements 字段的转换逻辑,支持多种对象转换为字典 - 修正 job 模块中 CandidateSource 引用路径 - 移除职位管理页面中“创建职位”按钮相关代码
This commit is contained in:
@@ -32,7 +32,10 @@ except ImportError:
|
||||
|
||||
try:
|
||||
from .job import router as job_router
|
||||
except ImportError:
|
||||
except ImportError as e:
|
||||
import traceback
|
||||
print(f"[ERROR] Failed to import job router: {e}")
|
||||
traceback.print_exc()
|
||||
from fastapi import APIRouter
|
||||
job_router = APIRouter()
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from ..schemas import (
|
||||
EvaluationSchemaResponse, EvaluationSchemaListResponse
|
||||
)
|
||||
from ...domain.job import Job
|
||||
from ...domain.enums import CandidateSource
|
||||
from ...domain.candidate import CandidateSource
|
||||
from ...mapper.job_mapper import JobMapper
|
||||
from ...mapper.evaluation_mapper import EvaluationMapper
|
||||
|
||||
@@ -24,6 +24,16 @@ router = APIRouter(prefix="/api/jobs", tags=["职位管理"])
|
||||
|
||||
def _job_to_response(job: Job) -> JobPositionResponse:
|
||||
"""将领域实体转换为响应模型"""
|
||||
# 将 JobRequirement 对象转换为字典
|
||||
requirements_dict = None
|
||||
if job.requirements is not None:
|
||||
if hasattr(job.requirements, 'to_dict'):
|
||||
requirements_dict = job.requirements.to_dict()
|
||||
elif hasattr(job.requirements, '__dict__'):
|
||||
requirements_dict = job.requirements.__dict__
|
||||
else:
|
||||
requirements_dict = job.requirements
|
||||
|
||||
return JobPositionResponse(
|
||||
id=job.id,
|
||||
title=job.title,
|
||||
@@ -35,7 +45,7 @@ def _job_to_response(job: Job) -> JobPositionResponse:
|
||||
location=job.location,
|
||||
salary_min=job.salary_min,
|
||||
salary_max=job.salary_max,
|
||||
requirements=job.requirements,
|
||||
requirements=requirements_dict,
|
||||
description=job.description,
|
||||
candidate_count=job.candidate_count,
|
||||
new_candidate_count=job.new_candidate_count,
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
<div class="jobs-page">
|
||||
<div class="page-header">
|
||||
<h2 class="page-title">职位管理</h2>
|
||||
<t-button theme="primary" @click="showAddDialog">
|
||||
<template #icon><t-icon name="add" /></template>
|
||||
创建职位
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
|
||||
Reference in New Issue
Block a user