1.优化角色

This commit is contained in:
李伟 2022-09-15 10:51:45 +08:00
parent e2efda9bc8
commit bfda4c0e6e
3 changed files with 18 additions and 18 deletions

View File

@ -1023,13 +1023,14 @@ async def name(
res = await crud.user.get_all_users(db, {}) res = await crud.user.get_all_users(db, {})
data = [] data = []
for i in res: for i in res:
data_dict = {} if i.get('name') != 'root':
data_dict['_id'] = i.get('_id') data_dict = {}
data_dict['name'] = i.get('name') data_dict['_id'] = i.get('_id')
data_dict['user_id'] = i.get('user_id') data_dict['name'] = i.get('name')
data_dict['email'] = i.get('email') data_dict['user_id'] = i.get('user_id')
data_dict['rank'] = i.get('rank') # 用于区分是面试官还是hr data_dict['email'] = i.get('email')
data.append(data_dict) data_dict['rank'] = i.get('rank') # 用于区分是面试官还是hr
data.append(data_dict)
return schemas.Msg(code=200, msg='ok', data=data) return schemas.Msg(code=200, msg='ok', data=data)

View File

@ -21,11 +21,11 @@ class Settings(BaseSettings):
DEFAULT_PASSWORD = '123456' DEFAULT_PASSWORD = '123456'
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 # 登录后一天过期 ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 登录后一天过期
SECRET_KEY: str = 'ZaFX6EypK6PtuhGv11q4DLRvAb0csiLx4dbKUwLwCe8' SECRET_KEY: str = 'ZaFX6EypK6PtuhGv11q4DLRvAb0csiLx4dbKUwLwCe8'
REDIS_CONF = { REDIS_CONF = {
'host': '127.0.0.1', 'host': '10.0.0.240',
'port': 6379, 'port': 6379,
'db': 1, 'db': 1,
'decode_responses': 'utf-8', 'decode_responses': 'utf-8',
@ -386,13 +386,12 @@ class Settings(BaseSettings):
# #
# 'online_ts': 'integer' # 'online_ts': 'integer'
} }
class Config:
case_sensitive = True
class Email(Settings):
my_sender = '250213850@qq.com' # 发件人邮箱账号 my_sender = '250213850@qq.com' # 发件人邮箱账号
my_pass = 'whrsugtgkstibjdj' # 发件人邮箱密码 my_pass = 'whrsugtgkstibjdj' # 发件人邮箱密码
subject = '入职通知' # 邮件的主题,也可以说是标题 subject = '入职通知' # 邮件的主题,也可以说是标题
class Config:
case_sensitive = True
# class Debug(Settings): # class Debug(Settings):
# MDB_HOST: str = '10.0.0.9' # MDB_HOST: str = '10.0.0.9'

View File

@ -13,8 +13,8 @@ from email.utils import formataddr
from datetime import timedelta from datetime import timedelta
from datetime import datetime as p1 from datetime import datetime as p1
import calendar import calendar
from core.config import Settings
from core.config import Email
def get_uid(): def get_uid():
@ -229,14 +229,14 @@ def send_str_mail(str_msg, my_user):
:return: bool :return: bool
""" """
msg = MIMEText(str_msg, 'plain', 'utf-8') msg = MIMEText(str_msg, 'plain', 'utf-8')
msg['From'] = formataddr(["乐谷游戏人事", Email.my_sender]) # 括号里的对应发件人邮箱昵称,发件人邮箱账号 msg['From'] = formataddr(["乐谷游戏人事", Settings.my_sender]) # 括号里的对应发件人邮箱昵称,发件人邮箱账号
msg['To'] = formataddr(["FK", my_user]) # 括号里的对应收件人邮箱昵称,收件人邮箱账号 msg['To'] = formataddr(["FK", my_user]) # 括号里的对应收件人邮箱昵称,收件人邮箱账号
msg['Subject'] = Email.subject # 邮件的主题,也可以说是标题 msg['Subject'] = Settings.subject # 邮件的主题,也可以说是标题
server = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人邮箱中的SMTP服务器端口是25 server = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人邮箱中的SMTP服务器端口是25
server.login(Email.my_sender, Email.my_pass) # 括号中对应的是发件人邮箱账号,邮箱密码 server.login(Settings.my_sender, Settings.my_pass) # 括号中对应的是发件人邮箱账号,邮箱密码
# server.sendmail(my_sender, [my_user, ], msg.as_string()) # 括号中对应的是发件人邮箱账号,收件人邮箱账号,发送邮件 # server.sendmail(my_sender, [my_user, ], msg.as_string()) # 括号中对应的是发件人邮箱账号,收件人邮箱账号,发送邮件
server.sendmail(Email.my_sender, [my_user, ], msg.as_string()) # 括号中对应的是发件人邮箱账号,收件人邮箱账号,发送邮件 server.sendmail(Settings.my_sender, [my_user, ], msg.as_string()) # 括号中对应的是发件人邮箱账号,收件人邮箱账号,发送邮件
server.quit() # 关闭连接 server.quit() # 关闭连接