From b0e65dc77d440376be55a85c6d8e39836f969241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Mon, 8 Aug 2022 13:43:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E9=83=A8=E9=97=A8=E5=8F=8A=E8=81=8C=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/interview.py | 30 ++++++++++++++------- crud/__init__.py | 1 + crud/crud_section.py | 43 +++++++++++++++++++++++++++++++ liwei_接口文档.md | 6 ++++- schemas/__init__.py | 1 + schemas/section.py | 18 +++++++++++++ 6 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 crud/crud_section.py create mode 100644 schemas/section.py diff --git a/api/api_v1/endpoints/interview.py b/api/api_v1/endpoints/interview.py index efb27c7..1d4278d 100644 --- a/api/api_v1/endpoints/interview.py +++ b/api/api_v1/endpoints/interview.py @@ -317,31 +317,31 @@ async def get_job( # 获取对应条件的职位 res = await crud.jobs.all_fields(db, data_in) # 获取职位数量 - num = len(res) + nums = len(res) job = [] for i in res: # 获取职位名称 job_list = {} - job_list['job_id'] = i['job_id'] # 职位id + job_list['key'] = i['job_id'] # 职位id # 查询对应职位id入职多少人 sql = f""" - select count(job_id) from HR.resumes where job_id = '{i['job_id']}' and interview_stage = 7 + select count(job_id) as nu from HR.resumes where job_id = '{i['job_id']}' and interview_stage = 7 """ + num = await ckdb.execute(sql) # 候选人总数 sql1 = f""" - select count(job_id) from HR.resumes where job_id = '{i['job_id']}' and interview_stage < 6 + select count(job_id) as nu from HR.resumes where job_id = '{i['job_id']}' and interview_stage < 6 """ hou_num = await ckdb.execute(sql1) - num = await ckdb.execute(sql) job_list['job_name'] = i['job_name'] # 职位名 job_list['principal'] = i['principal'] # 招聘负责人 job_list['job_sector'] = i['job_sector'] # 部门 job_list['job_num'] = i['job_num'] # 目标招聘人数 - job_list['now_job_num'] = num # 对应职位的入职人数 - job_list['hou_num'] = hou_num # 候选人总数 + job_list['now_job_num'] = num[0]['nu'] # 对应职位的入职人数 + job_list['hou_num'] = hou_num[0]['nu'] # 候选人总数 job.append(job_list) data = { - 'num': num, + 'num': nums, 'job': job } return schemas.Msg(code=200, msg='ok', data=data) @@ -476,7 +476,7 @@ async def get_str_mail( @router.post("/send_str_mail") -async def send_str_mail( +async def send_mail( request: Request, data_in: schemas.send_str_mail, db: AsyncIOMotorDatabase = Depends(get_database) @@ -982,3 +982,15 @@ async def owner_edit( """新增,删除基本信息""" await crud.basic_data.update(db, data_in) return schemas.Msg(code=200, msg='ok', data='') + + +@router.get("/get_section") +async def get_section( + request: Request, + db: AsyncIOMotorDatabase = Depends(get_database), + # current_user: schemas.UserDB = Depends(deps.get_current_user) +) -> schemas.Msg: + """获取对应部门及职位""" + res=await crud.section.get_all(db) + return schemas.Msg(code=200, msg='ok', data=res) + diff --git a/crud/__init__.py b/crud/__init__.py index 99dd674..f74cdda 100644 --- a/crud/__init__.py +++ b/crud/__init__.py @@ -31,3 +31,4 @@ from .crud_worker_info import worker_info from .crud_owner_info import owner_info from .crud_count_in_worker import count_in_worker from .crud_basic_data import basic_data +from .crud_section import section diff --git a/crud/crud_section.py b/crud/crud_section.py new file mode 100644 index 0000000..3336f42 --- /dev/null +++ b/crud/crud_section.py @@ -0,0 +1,43 @@ +from motor.motor_asyncio import AsyncIOMotorDatabase +import schemas +from crud.base import CRUDBase + +__all__ = 'section', + + +class Section(CRUDBase): + # 获取所有部门及职位 + async def get_all(self, db: AsyncIOMotorDatabase): + return await self.find_many(db,{},{'_id':0}) + # # 获取对应级别权限的所有路由和路由状体 + # async def get_url(self, db: AsyncIOMotorDatabase, data_in: schemas.Url_list): + # return await self.find_many(db, {'name': data_in.name}) + # + # # 插入单条对应级别权限的路由和状态 + # async def insert_url(self, db: AsyncIOMotorDatabase, data_in: schemas.Url_list): + # return await self.insert_one(db, data_in.dict()) + # + # async def insert_urls(self, db: AsyncIOMotorDatabase, data_in: schemas.Url_lists): + # return await self.insert_one(db, data_in.dict()) + # + # # 更新单条对应级别权限的路由和状态 + # async def update_url_url(self, db: AsyncIOMotorDatabase, res): + # return await self.update_one(db, {'_id': res['_id']}, { + # '$set': {'state': res['state']}}) + # + # async def find_one_url(self, db: AsyncIOMotorDatabase, data_in: schemas.Datalist): + # return await self.find_one(db, {'auth_id': data_in.role_id, 'path_name': data_in.path_name}) + # + # # 修改权限用户名字 + # async def edit_name(self, db: AsyncIOMotorDatabase, data_in: schemas.Editname): + # where = {'auth_id': data_in.role_id} + # up_data = {'$set': {'name': data_in.name}} + # + # return await self.update_many(db, where, up_data) + # + # # 删除一个权限用户 + # async def delete_name(self, db: AsyncIOMotorDatabase, data_in: schemas.Del_roles): + # return await self.delete(db, {'auth_id': data_in.role_id}) + + +section = Section('section') diff --git a/liwei_接口文档.md b/liwei_接口文档.md index 94a140d..db01e39 100644 --- a/liwei_接口文档.md +++ b/liwei_接口文档.md @@ -302,4 +302,8 @@ api:/api/v1/itr/owner_edit 参数: date: List[str] # 各种基本资料 name: str # 基本资料的名称 现有渠道owner_name,工作经验job_exp, - 职能类别function_type,职位级别job_rank,学历要求education,部门sector \ No newline at end of file + 职能类别function_type,职位级别job_rank,学历要求education,部门sector + +#获取对应部门及职位 +api:/api/v1/itr/owner_list +请求方式:get diff --git a/schemas/__init__.py b/schemas/__init__.py index 3521ada..1177dce 100644 --- a/schemas/__init__.py +++ b/schemas/__init__.py @@ -37,3 +37,4 @@ from .worker import * from .owner_info import * from .count_in_worker import * from .basic_data import * +from .section import * diff --git a/schemas/section.py b/schemas/section.py new file mode 100644 index 0000000..2aee95e --- /dev/null +++ b/schemas/section.py @@ -0,0 +1,18 @@ +from typing import Any, List, Union + +from pydantic import BaseModel, Field + +from schemas import DBBase +from typing import Optional + + +class Url_module(BaseModel): + auth_id: str = None + path_name: str = None + api_list: List[str] = None + api_name: List[str] = None + state: List[bool] = None + +class Add_module(BaseModel): + auth_id: str + url:str \ No newline at end of file