From 38b012beeddae4b0cf80fbef464c5741d5575735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Thu, 27 Oct 2022 10:35:13 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BA=BA=E6=89=8D=E5=BA=93=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/interview.py | 79 ++++++++++++++++++++++++++++++- core/configuration.py | 2 +- crud/__init__.py | 1 + crud/crud_jobs.py | 14 ++++-- crud/crud_talentpool_filtrate.py | 26 ++++++++++ schemas/__init__.py | 1 + schemas/talentpool_filtrate.py | 14 ++++++ 7 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 crud/crud_talentpool_filtrate.py create mode 100644 schemas/talentpool_filtrate.py diff --git a/api/api_v1/endpoints/interview.py b/api/api_v1/endpoints/interview.py index 20f7e03..6d3b17e 100644 --- a/api/api_v1/endpoints/interview.py +++ b/api/api_v1/endpoints/interview.py @@ -2014,11 +2014,11 @@ async def login( 'nickname': user.nickname, # 显示名 'token': security.create_access_token( expires_delta=access_token_expires, user_id=user.user_id, email=user.email, - tel=user.tel, name=user.name, rank=user.rank, unionid=user.unionid), + tel=user.tel, name=user.name, rank=user.rank, unionid=user.unionid, _id=str(user.id)), "token_type": "bearer"}, 'access_token': security.create_access_token( expires_delta=access_token_expires, user_id=user.user_id, email=user.email, - tel=user.tel, name=user.name, rank=user.rank, unionid=user.unionid + tel=user.tel, name=user.name, rank=user.rank, unionid=user.unionid, _id=str(user.id) ), "token_type": "bearer", 'code': 200, @@ -2943,3 +2943,78 @@ async def talent_pool_nu( return schemas.Msg(code=-9, msg='无数据', data='') res = data['nu'][0] return schemas.Msg(code=200, msg='ok', data=res) + + +@router.get("/option") +async def option( + request: Request, + ckdb: CKDrive = Depends(get_ck_db), + db: AsyncIOMotorDatabase = Depends(get_database), + current_user: schemas.UserDB = Depends(deps.get_current_user) +) -> schemas.Msg: + """获取人才库筛选项""" + res = await crud.talentpool_filtrate.where_filtrate(db, ['default', current_user.id]) + if len(res) > 1: # 自定义筛选项 + for i in res: + if i['user_id'] != 'default': + data = i['where'] + break + else: # 默认筛选项 + data = res[0]['where'] + return schemas.Msg(code=200, msg='ok', data=data) + + +@router.post("/up_option") +async def up_option( + request: Request, + data_in: schemas.Where, + ckdb: CKDrive = Depends(get_ck_db), + db: AsyncIOMotorDatabase = Depends(get_database), + current_user: schemas.UserDB = Depends(deps.get_current_user) +) -> schemas.Msg: + """修改/新增人才库筛选项""" + res = await crud.talentpool_filtrate.where_filtrate(db, ['default', current_user.id]) + if len(res) > 1: # 修改自定义筛选项 + for i in res: + if i['user_id'] != 'default': + await crud.talentpool_filtrate.update_filtrate(db, current_user.id, data_in.dict()) + break + else: # 新增自定义筛选项 + await crud.talentpool_filtrate.ins_filtrate(db, schemas.Filtrate(**data_in.dict(), user_id=current_user.id)) + return schemas.Msg(code=200, msg='ok', data='') + + +@router.post("/option_data") +async def option_data( + request: Request, + data_in: schemas.Where_list, + ckdb: CKDrive = Depends(get_ck_db), + db: AsyncIOMotorDatabase = Depends(get_database), + current_user: schemas.UserDB = Depends(deps.get_current_user) +) -> schemas.Msg: + """获取才库筛选项数据""" + data = {} + for i in data_in.where: + if i == 'job': # 应聘职位 + res = await crud.jobs.where_field(db) + job = {} + for i in res: + job[i['job_id']] = i['job_name'] + data['job_id'] = job + elif i == 'pass_why': # 归档原因 + data['pass_why'] = pass_why_dict + elif i == 'owner_name': # 渠道 + data['owner_name'] = owner_name_dict + elif i == 'education': # 学历 + data['education'] = education_dict + elif i == 'gender': # 性别 + data['gender'] = ['男', '女'] + elif i == 'department': # 职位负责人 + res1 = await crud.user.get_all_users(db, {'rank': 2}) + data['department'] = [{i['_id']: i['nickname']} for i in res1] + elif i == 'hr_name': # 候选人所有者 + res2 = await crud.user.get_all_users(db, {}) + data['hr_name'] = [{i['_id']: i['nickname']} for i in res2] + elif i == 'ago': # 归档前的阶段 + data['ago'] = interview_stage_dict + return schemas.Msg(code=200, msg='ok', data=data) diff --git a/core/configuration.py b/core/configuration.py index 60cf5f7..04beceb 100644 --- a/core/configuration.py +++ b/core/configuration.py @@ -12,7 +12,7 @@ interview_round_dict = {1: '初试', 2: '复试', 3: '终试'} interview_stage_dict = {1: '初筛', 2: '用人部门复筛', 3: '面试', 4: '沟通offer', 5: '待入职', 6: '放弃入职', 7: '已入职', 8: '转正', 9: '主动离职', 10: '被动离职', 11: '淘汰'} # 简历来源 -owner_name_dict = {1: '前程无忧', 2: '人才库', 3: '智联招聘', 4: 'Boss直聘', 5: '58同城'} +owner_name_dict = {1: '前程无忧', 2: '内推', 3: '智联招聘', 4: 'Boss直聘', 5: '58同城'} # 学历 education_dict = {1: '大专', 2: '本科', 3: '研究生', 4: '博士', 5: '硕士'} # 推荐状态 diff --git a/crud/__init__.py b/crud/__init__.py index d4f7202..10fc248 100644 --- a/crud/__init__.py +++ b/crud/__init__.py @@ -37,3 +37,4 @@ from .crud_section import section from .crud_feedback import feedback from .crud_find_column import api_find_column from .crud_department import department +from .crud_talentpool_filtrate import talentpool_filtrate diff --git a/crud/crud_jobs.py b/crud/crud_jobs.py index 530dd60..5ead186 100644 --- a/crud/crud_jobs.py +++ b/crud/crud_jobs.py @@ -17,6 +17,10 @@ class CRUDJobs(CRUDBase): return await self.find_many(db, {}, {'_id': 0, 'job_id': 1, 'job_sector': 1, 'principal': 1, 'job_num': 1, 'start_time': 1, 'now_job_num': 1, 'job_name': 1}) + # 获取所有对应职位指定字段的数据 + async def where_field(self, db: AsyncIOMotorDatabase): + return await self.find_many(db, {}, {'_id': 0, 'job_id': 1,'job_name': 1}) + # 获取所有对应条件职位字段的数据 async def all_fields(self, db: AsyncIOMotorDatabase, data_in: schemas.Jobs): if data_in == None: @@ -26,15 +30,15 @@ class CRUDJobs(CRUDBase): data_dict = data_in.dict() for k, v in data_dict.items(): if v != None and v != '' and v != []: - if not isinstance(v,list): + if not isinstance(v, list): if k != 'job_name': where[k] = v else: - where[k]=re.compile(v) + where[k] = re.compile(v) else: for i in v: - for kk,vv in i.items(): - where[k+'.'+kk]=vv + for kk, vv in i.items(): + where[k + '.' + kk] = vv return await self.find_many(db, where, {'_id': 0}) # 修改职位的数据 @@ -52,7 +56,7 @@ class CRUDJobs(CRUDBase): # 获取对应jobid的信息 async def find_job(self, db: AsyncIOMotorDatabase, job_id): - return await self.find_one(db, {'job_id': job_id},{'_id':0}) + return await self.find_one(db, {'job_id': job_id}, {'_id': 0}) # 获取对应job_id的部门和名称 async def find_job_name(self, db: AsyncIOMotorDatabase, job_id): diff --git a/crud/crud_talentpool_filtrate.py b/crud/crud_talentpool_filtrate.py new file mode 100644 index 0000000..32d4b8b --- /dev/null +++ b/crud/crud_talentpool_filtrate.py @@ -0,0 +1,26 @@ +from motor.motor_asyncio import AsyncIOMotorDatabase +import schemas +from crud.base import CRUDBase + +__all__ = 'talentpool_filtrate', + + +class Talentpool_filtrate(CRUDBase): + # 获取所有数据 + async def all_filtrate(self, db: AsyncIOMotorDatabase): + return await self.find_many(db, {}) + + # 获取对应条件数据 + async def where_filtrate(self, db: AsyncIOMotorDatabase, where: list): + return await self.find_many(db, {'user_id': {'$in': where}},{'_id':0}) + + # 修改数据 + async def update_filtrate(self, db: AsyncIOMotorDatabase, user_id: str, up: dict): + await self.update_one(db, {'user_id': user_id}, {'$set':up}) + + # 插入数据 + async def ins_filtrate(self, db: AsyncIOMotorDatabase, data_in: schemas.Filtrate): + await self.insert_one(db, data_in.dict()) + + +talentpool_filtrate = Talentpool_filtrate('talentpool_filtrate') diff --git a/schemas/__init__.py b/schemas/__init__.py index 0b0eba0..6a27987 100644 --- a/schemas/__init__.py +++ b/schemas/__init__.py @@ -42,3 +42,4 @@ from .basic_data import * from .section import * from .feedback import * from .department import * +from .talentpool_filtrate import * diff --git a/schemas/talentpool_filtrate.py b/schemas/talentpool_filtrate.py new file mode 100644 index 0000000..fc343bf --- /dev/null +++ b/schemas/talentpool_filtrate.py @@ -0,0 +1,14 @@ +from pydantic import BaseModel + + +class Filtrate(BaseModel): + user_id: str # 账号id + where: dict # 筛选项 + + +class Where(BaseModel): + where: dict # 筛选项 + + +class Where_list(BaseModel): + where: list # 筛选项