From 41c4c77a2c0d1160aa59c648e3b442ef8028287c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Tue, 18 Oct 2022 14:00:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E8=81=8C=E4=BD=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E8=BF=94=E5=9B=9Eunionid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/interview.py | 21 +++++++++++++++------ crud/crud_user.py | 2 +- schemas/user.py | 19 +++++++++++-------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/api/api_v1/endpoints/interview.py b/api/api_v1/endpoints/interview.py index 9f6d8fe..bf9ef43 100644 --- a/api/api_v1/endpoints/interview.py +++ b/api/api_v1/endpoints/interview.py @@ -422,7 +422,9 @@ async def interview_update( content = f"""【淘汰通知】\n姓名:{interview_id[0]['name']}\n求职岗位:{interview_id[0]['job_names']}\n淘汰原因:{why}\n具体淘汰原因:{interview.data_in.get('pass_text')}\n简历阶段:{interview_stage}\n操作人:{current_user.nickname}""" if current_user.name != 'root': # send_dates(content, userid_list)# 工作通知 - Sample.create_task('淘汰通知', current_user.user_id, content, userid_list) # 待办通知 + res=await crud.user.get_users(db,userid_list) + unionid_list=[i['unionid'] for i in res] + Sample.create_task('淘汰通知', current_user.unionid, content, unionid_list) # 待办通知 return schemas.Msg(code=200, msg='ok', data=data) @@ -1538,7 +1540,9 @@ async def teacher_state( if current_user.name != 'root': content = f"【催促反馈】\n请面试官尽快给{data_in.name}做面试反馈\n提醒时间:{now_time}" #send_dates(content, data_in.user_id)#工作通知 - Sample.create_task('催促反馈',current_user.user_id,content,data_in.user_id) # 待办通知 + res=await crud.user.get_users(db,data_in.user_id) + unionid_list=[i['unionid'] for i in res] + Sample.create_task('催促反馈',current_user.unionid,content,unionid_list) # 待办通知 return schemas.Msg(code=200, msg='发送成功', data='') except Exception: return schemas.Msg(code=-9, msg='发送失败', data='') @@ -1655,6 +1659,7 @@ async def name( data_dict['_id'] = str(i.get('_id')) data_dict['name'] = i.get('name') data_dict['user_id'] = i.get('user_id') + data_dict['unionid'] = i.get('unionid') data_dict['email'] = i.get('email') data_dict['rank'] = i.get('rank') # 用于区分是面试官还是hr data_dict['nickname'] = i.get('nickname') # 显示名 @@ -1946,16 +1951,17 @@ async def login( 'email': user.email, # 邮箱 'tel': user.tel, # 电话 'user_id': user.user_id, # 钉钉id + 'unionid':user.unionid, #钉钉unionid 'id': user.id, # 账号的唯一标识 'rank': user.rank, # 区分hr和面试官 '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), + tel=user.tel, name=user.name, rank=user.rank,unionid=user.unionid), "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 + tel=user.tel, name=user.name, rank=user.rank,unionid=user.unionid ), "token_type": "bearer", 'code': 200, @@ -2386,8 +2392,9 @@ async def send_interviewee( user_list = [i['user_id'] for i in user['hr_name']] if current_user.name != 'root': send = f"""【推荐通知】\n{current_user.nickname}给你推荐了一位面试者\n面试者姓名:{res[0]['name']}\n岗位:{res[0]['job_names']}""" + unionid_list=[i['unionid'] for i in user['hr_name']] # send_dates(send, user_list) #工作通知 - Sample.create_task('推荐通知', current_user.user_id, send, user_list) # 待办通知 + Sample.create_task('推荐通知', current_user.unionid, send, unionid_list) # 待办通知 department = ','.join(user_list) up_sql = f"""ALTER TABLE HR.resumes update department = '{department}' where uid = '{data_in.uid}'""" print(up_sql) @@ -2428,7 +2435,9 @@ async def add_interviewee( hr_user.extend(data_in.user_id) if current_user.name != 'root': # send_dates(send, hr_user)#工作通知 - Sample.create_task('面试通知', current_user.user_id, send, hr_user) # 待办通知 + res=await crud.user.get_users(db,hr_user) + unionid_list=[i['unionid'] for i in res] + Sample.create_task('面试通知', current_user.unionid, send, unionid_list) # 待办通知 find_sql = f""" select uid,name,interview_name,hr_name,star_time,interview_sign,interview_id,job_id,job_names,mail from HR.resumes where uid = '{data_in.uid}' """ diff --git a/crud/crud_user.py b/crud/crud_user.py index 649f1e1..2de5169 100644 --- a/crud/crud_user.py +++ b/crud/crud_user.py @@ -27,7 +27,7 @@ class CRUDUser(CRUDBase): return res #获取用户信息(list) async def get_users(self, db: AsyncIOMotorDatabase, user_id: list): - res = await self.find_many(db,{'user_id':{'$in': user_id}}, {'name': 1,'user_id':1,'nickname':1}) + res = await self.find_many(db,{'user_id':{'$in': user_id}}, {'name': 1,'user_id':1,'nickname':1,'unionid':1}) return res async def edit_profile(self, db: AsyncIOMotorDatabase, data_id: schemas.UserProfileEdit, user_id): diff --git a/schemas/user.py b/schemas/user.py index 6529a2a..8627c09 100644 --- a/schemas/user.py +++ b/schemas/user.py @@ -40,14 +40,15 @@ class UserLogin(BaseModel): class UserRestPassword(BaseModel): user_id: str = ... password: str = ... - nickname:str # 用户名 - tel:str # 电话 + nickname: str # 用户名 + tel: str # 电话 email: str # 邮箱 + class UserRestMyPassword(BaseModel): password: str = ... - nickname:str # 用户名 - tel:str # 电话 + nickname: str # 用户名 + tel: str # 电话 email: str # 邮箱 @@ -58,7 +59,7 @@ class UserCreate(UserBase): rank: int # 判断是hr还是面试官 email: str # 邮箱 tel: str # 手机号 - user_id: str # 钉钉的用户id + user_id: str # 钉钉的用户id # **************************************************************************** @@ -66,16 +67,18 @@ class UserCreate(UserBase): class UserDB(DBBase): - #email: EmailStr = None # 邮箱 + # email: EmailStr = None # 邮箱 is_superuser: bool = False - name: str # 姓名 + name: str # 姓名 nickname: str = '' tel: Any = '' last_login_ts: str = '尚未登录' data_where: dict = dict() user_id: str # 钉钉id + unionid: str # 钉钉unionid rank: int # 区分hr和面试官 + class UserDBRW(DBBase): hashed_password: str # 密码 unionid: str # 通过钉钉扫码获取的unionid @@ -87,4 +90,4 @@ class UserDBRW(DBBase): last_login_ts: str = '尚未登录' # 登录时间 create_date: datetime = datetime.now() # 创建账号的时间 state: int = 0 # 默认刚创账号是不锁定的 - user_id:str # 钉钉里面的用户id + user_id: str # 钉钉里面的用户id