diff --git a/api/api_v1/endpoints/interview.py b/api/api_v1/endpoints/interview.py index 7a7b9ec..7598eae 100644 --- a/api/api_v1/endpoints/interview.py +++ b/api/api_v1/endpoints/interview.py @@ -91,4 +91,15 @@ async def interview_insert( sql = res['sql'] insert_data = res['insert_data'] data = await db.execute_dict(sql, insert_data) - return schemas.Msg(code=200, msg='ok', data=data) \ No newline at end of file + return schemas.Msg(code=200, msg='ok', data=data) + +@router.post("/add_job") +async def event_edit( + request: Request, + data_in: schemas.Ins_Job, + db: AsyncIOMotorDatabase = Depends(get_database), + current_user: schemas.UserDB = Depends(deps.get_current_user) +) -> schemas.Msg: + """新增职位""" + await crud.jobs.insert_job(db, data_in) + return schemas.Msg(code=200, msg='ok', data='') \ No newline at end of file diff --git a/crud/__init__.py b/crud/__init__.py index 8094eaa..5fd6a38 100644 --- a/crud/__init__.py +++ b/crud/__init__.py @@ -20,4 +20,5 @@ from .crud_api_board import api_board from .crud_url_list import url_list from .crud_user_url import user_url from .crud_api_module import api_module -from .crud_event_list import event_list \ No newline at end of file +from .crud_event_list import event_list +from .crud_jobs import jobs \ No newline at end of file diff --git a/crud/crud_jobs.py b/crud/crud_jobs.py new file mode 100644 index 0000000..93de590 --- /dev/null +++ b/crud/crud_jobs.py @@ -0,0 +1,40 @@ +from motor.motor_asyncio import AsyncIOMotorDatabase +import schemas +from crud.base import CRUDBase + +__all__ = 'jobs', + + +class CRUDJobs(CRUDBase): + # 获取所有对应职位字段的数据 + async def all_field(self, db: AsyncIOMotorDatabase): + return await self.find_many(db, {}) + + # 获取所有对应条件职位字段的数据 + async def all_fields(self, db: AsyncIOMotorDatabase, data_in: schemas.Jobs): + if data_in == None: + return await self.find_many(db, {}, {'_id': 0}) + else: + where = {} + data_dict = data_in.dict() + for k, v in data_dict.items(): + if v != None: + where[k] = v + return await self.find_many(db, where, {'_id': 0}) + + # 修改职位的数据 + async def update_job(self, db: AsyncIOMotorDatabase, data_in: schemas.Jobs): + update = {} + data_dict = data_in.dict() + for k, v in data_dict.items(): + if v != None and k != 'job_id': + update[k] = v + await self.update_one(db, {'job_id': int(data_in.job_id)}, {'$set': update}) + + # 插入一条新的职位数据 + async def insert_job(self, db: AsyncIOMotorDatabase, data_in: schemas.Ins_Job): + + await self.insert_one(db, data_in.dict()) + + +jobs = CRUDJobs('jobs') diff --git a/schemas/__init__.py b/schemas/__init__.py index 3987dc0..5048c36 100644 --- a/schemas/__init__.py +++ b/schemas/__init__.py @@ -26,4 +26,5 @@ from .user_url import * from .api_module import * from .event_list import * from .interview import * -from .interview_plan import * \ No newline at end of file +from .interview_plan import * +from .jobs import * \ No newline at end of file diff --git a/schemas/jobs.py b/schemas/jobs.py new file mode 100644 index 0000000..e7091e9 --- /dev/null +++ b/schemas/jobs.py @@ -0,0 +1,84 @@ +import time +from datetime import datetime + +from pydantic import BaseModel + + +class Job(BaseModel): + job_id: str = None # 职位的唯一id + job_name: str # 职位名称 + job_sector: str # 职位部门 + job_nature: str # 职位性质 + job_priority: str # 职位优先级 + owner_name: str # 渠道 + principal: str # 负责人 + patronn: str # 协助人 + start_time: datetime = datetime.now() # 开始招聘时间 + end_time: datetime = None # 结束招聘时间 + function_type: str # 职能类型 + filtering_rules: bool # 是否使用筛选规则 + hiring_needs: bool # 是否关联招聘需求 + auto_repeater: bool # 是否自动转发 + cacsi_count: int = None # 面试满意度反馈次数 + state: bool = None # 职位招聘状态 + job_num: int = None # 招聘人数 + education: str # 学历要求 + job_rank: str # 职位级别 + work_exp: str # 工作经验 + report_obj: str # 汇报对象 + min_money: int # 薪资范围min + max_money: int # 薪资范围max + requirement: str # 需求描述 + + +class Jobs(BaseModel): + job_id: str = None # 职位的唯一id + job_name: str = None # 职位名称 + job_sector: str = None # 职位部门 + job_nature: str = None # 职位性质 + job_priority: str = None # 职位优先级 + owner_name: str = None # 渠道 + principal: str = None # 负责人 + patronn: str = None # 协助人 + start_time: datetime = None # 开始招聘时间 + end_time: datetime = None # 结束招聘时间 + function_type: str = None # 职能类型 + filtering_rules: bool = None # 是否使用筛选规则 + hiring_needs: bool = None # 是否关联招聘需求 + auto_repeater: bool = None # 是否自动转发 + cacsi_count: int = None # 面试满意度反馈次数 + state: bool = None # 职位招聘状态 + job_num: int = None # 招聘人数 + education: str = None # 学历要求 + job_rank: str = None # 职位级别 + work_exp: str = None # 工作经验 + report_obj: str = None # 汇报对象 + min_money: int = None # 薪资范围min + max_money: int = None # 薪资范围max + requirement: str = None # 需求描述 + + +class Ins_Job(BaseModel): + job_id: str = int(time.time()) # 职位的唯一id + job_name: str # 职位名称 + job_sector: str # 职位部门 + job_nature: str # 职位性质 + job_priority: str # 职位优先级 + owner_name: str # 渠道 + principal: str # 负责人 + patronn: str # 协助人 + start_time: datetime = datetime.now() # 开始招聘时间 + function_type: str # 职能类型 + filtering_rules: bool # 是否使用筛选规则 + hiring_needs: bool # 是否关联招聘需求 + auto_repeater: bool # 是否自动转发 + cacsi_count: int = 0 # 面试满意度反馈次数 + state: bool = True # 职位招聘状态 + job_num: int # 招聘人数 + education: str # 学历要求 + job_rank: str # 职位级别 + work_exp: str # 工作经验 + report_obj: str # 汇报对象 + min_money: int # 薪资范围min + max_money: int # 薪资范围max + requirement: str # 需求描述