master
parent
bedff6d160
commit
7875121b51
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
def handleEmpty(count, msg):
|
||||
if count > 0:
|
||||
return {"code": 2000, "msg": msg + "成功"}
|
||||
else:
|
||||
return {"code": 1000, "msg": msg + "失败,数据不存在"}
|
@ -0,0 +1,9 @@
|
||||
|
||||
def handleErrorMethod(reqMethod, method):
|
||||
if reqMethod == method:
|
||||
return [True]
|
||||
else:
|
||||
return [False, {
|
||||
'msg': '请求方式应为:' + method,
|
||||
'code': 1000
|
||||
}]
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
import jwt
|
||||
|
||||
|
||||
def decode_jwt_token(encoded_jwt):
|
||||
# 关闭过期时间检验
|
||||
de_code = jwt.decode(encoded_jwt, "JWT_SECRET_KEY", algorithms=['HS256'])
|
||||
return de_code
|
@ -0,0 +1,14 @@
|
||||
def get_jwt_token(user_name, role_data='default'):
|
||||
"""
|
||||
生成jwt-token
|
||||
:param unit_name:
|
||||
:param role_data:
|
||||
:return:
|
||||
"""
|
||||
payload = {
|
||||
'exp': datetime.utcnow() + timedelta(seconds=3600), # 单位秒
|
||||
'iat': datetime.utcnow(),
|
||||
'data': {'username': user_name, 'role_data': role_data}
|
||||
}
|
||||
encoded_jwt = jwt.encode(payload, "JWT_SECRET_KEY", algorithm='HS256')
|
||||
return str(encoded_jwt, encoding='utf8')
|
@ -1,17 +0,0 @@
|
||||
from pymongo import MongoClient
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
def test():
|
||||
# 连接到 MongoDB 数据库
|
||||
client = MongoClient('mongodb://localhost:27017/')
|
||||
db = client['employee-information-management-system']
|
||||
collection = db['user_model']
|
||||
|
||||
# 获取文档的 _id 字段的值
|
||||
document_id = '660195d50d5cb377410134f7' # 替换为你要查找的文档的 _id
|
||||
document = collection.find_one({'_id': ObjectId(document_id)})
|
||||
if document:
|
||||
document_id = document['_id']
|
||||
print(document)
|
||||
else:
|
||||
print("Document not found.")
|
Binary file not shown.
Loading…
Reference in new issue