Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯佳佳
Automat
Commits
62df6d07
Commit
62df6d07
authored
Jan 20, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
84bc3eca
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
6 deletions
+9
-6
config/app_config.py
+1
-1
myapps/automat/api/machine_portal.py
+1
-0
myapps/automat/api/rent_portal.py
+2
-1
myapps/pc_management/api/machine_portal.py
+3
-2
utils/jwt_util.py
+2
-2
No files found.
config/app_config.py
View file @
62df6d07
...
@@ -24,7 +24,7 @@ class Config:
...
@@ -24,7 +24,7 @@ class Config:
JWT_SECRET
=
SECRET_KEY
JWT_SECRET
=
SECRET_KEY
TENCENT_REDIS_URL
=
os
.
getenv
(
"TENCENT_REDIS_URL"
)
TENCENT_REDIS_URL
=
os
.
getenv
(
"TENCENT_REDIS_URL"
)
MAX_CONTENT_LENGTH
=
16
*
1024
*
1024
MAX_CONTENT_LENGTH
=
16
*
1024
*
1024
#
SQLALCHEMY_ECHO = True
SQLALCHEMY_ECHO
=
True
@staticmethod
@staticmethod
def
init_app
(
app
):
def
init_app
(
app
):
...
...
myapps/automat/api/machine_portal.py
View file @
62df6d07
...
@@ -116,6 +116,7 @@ def run_create_machine_no():
...
@@ -116,6 +116,7 @@ def run_create_machine_no():
machine_model
.
machine_no
=
machine_no
machine_model
.
machine_no
=
machine_no
machine_model
.
mac
=
mac
machine_model
.
mac
=
mac
machine_model
.
hatch_number
=
hatch_number
machine_model
.
hatch_number
=
hatch_number
machine_model
.
status
=
1
db
.
session
.
add
(
machine_model
)
db
.
session
.
add
(
machine_model
)
db
.
session
.
commit
()
db
.
session
.
commit
()
return
BaseResponse
(
data
=
{
"machine_no"
:
machine_no
})
return
BaseResponse
(
data
=
{
"machine_no"
:
machine_no
})
...
...
myapps/automat/api/rent_portal.py
View file @
62df6d07
...
@@ -67,7 +67,8 @@ def create_rent():
...
@@ -67,7 +67,8 @@ def create_rent():
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
if
machine
.
discounts_id
==
1
:
if
machine
.
discounts_id
==
1
:
rent
=
Rent
.
query
.
filter
(
db
.
cast
(
Rent
.
created_at
,
db
.
DATE
)
==
db
.
cast
(
datetime
.
datetime
.
now
(),
db
.
DATE
))
.
first
()
rent
=
Rent
.
query
.
filter
(
db
.
cast
(
Rent
.
created_at
,
db
.
DATE
)
==
db
.
cast
(
datetime
.
datetime
.
now
(),
db
.
DATE
),
Rent
.
user_id
==
g
.
user
.
id
)
.
first
()
if
not
rent
:
if
not
rent
:
if
len
(
productions
)
!=
1
:
if
len
(
productions
)
!=
1
:
return
jsonify
(
HATCH_COUNT_ERROR
)
return
jsonify
(
HATCH_COUNT_ERROR
)
...
...
myapps/pc_management/api/machine_portal.py
View file @
62df6d07
...
@@ -89,11 +89,11 @@ def run_add_machine():
...
@@ -89,11 +89,11 @@ def run_add_machine():
:return:
:return:
"""
"""
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
machine_no
=
json_data
[
"machine_no"
]
machine_no
=
json_data
.
get
(
"machine_no"
,
None
)
address
=
json_data
.
get
(
"address"
,
None
)
address
=
json_data
.
get
(
"address"
,
None
)
device_id
=
json_data
.
get
(
"device_id"
,
None
)
device_id
=
json_data
.
get
(
"device_id"
,
None
)
qrcode_no
=
json_data
.
get
(
"qrcode_no"
,
None
)
qrcode_no
=
json_data
.
get
(
"qrcode_no"
,
None
)
mac
=
json_data
.
get
(
"mac"
,
None
)
mac
=
json_data
[
"mac"
]
power
=
json_data
.
get
(
"power"
,
None
)
power
=
json_data
.
get
(
"power"
,
None
)
hatch_number
=
json_data
.
get
(
"hatch_number"
,
None
)
hatch_number
=
json_data
.
get
(
"hatch_number"
,
None
)
place_id
=
json_data
.
get
(
"place_id"
,
None
)
place_id
=
json_data
.
get
(
"place_id"
,
None
)
...
@@ -112,6 +112,7 @@ def run_add_machine():
...
@@ -112,6 +112,7 @@ def run_add_machine():
machine_model
.
hatch_number
=
hatch_number
machine_model
.
hatch_number
=
hatch_number
machine_model
.
type
=
type
machine_model
.
type
=
type
machine_model
.
discounts_id
=
discounts_id
machine_model
.
discounts_id
=
discounts_id
machine_model
.
status
=
1
db
.
session
.
add
(
machine_model
)
db
.
session
.
add
(
machine_model
)
admin_machine
=
AdminMachine
()
admin_machine
=
AdminMachine
()
...
...
utils/jwt_util.py
View file @
62df6d07
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') # token = generate_jwt({"user_id": 1}, time.time() + 6000, SECRET_KEY) token = generate_jwt({"user_no": 'XXTM000015'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') token = generate_jwt({"user_id": 1}, time.time() + 6000, SECRET_KEY) # token = generate_jwt({"user_no": 'XXTM000015'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
\ No newline at end of file
\ No newline at end of file
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment