Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xianyang
financial-system
Commits
acd77a5f
Commit
acd77a5f
authored
Mar 31, 2023
by
xupeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token刷新提交
parent
8cae1eeb
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
35 deletions
+60
-35
views.py
app/api/account/views.py
+1
-1
crud.py
app/api/role/crud.py
+0
-1
crud.py
app/api/statement/crud.py
+22
-27
views.py
app/api/statement/views.py
+4
-4
functions.py
libs/functions.py
+7
-1
main.py
main.py
+26
-1
No files found.
app/api/account/views.py
View file @
acd77a5f
...
...
@@ -11,7 +11,7 @@ router = APIRouter()
@
router
.
post
(
"/create"
)
def
create_account
(
data
:
schemas
.
AccountCreate
,
token
=
Depends
(
login_required
)):
def
create_account
(
data
:
schemas
.
AccountCreate
,
token
=
Depends
(
login_required
)):
"""添加账户"""
db_info
=
crud
.
get_account
(
data
.
name
)
if
db_info
:
...
...
app/api/role/crud.py
View file @
acd77a5f
...
...
@@ -3,7 +3,6 @@ from fastapi import HTTPException, status
from
sqlalchemy.orm
import
Session
from
sqlalchemy
import
func
from
app.api.role
import
schemas
from
libs.functions
import
wrapper_out
from
models
import
roles
as
models
...
...
app/api/statement/crud.py
View file @
acd77a5f
This diff is collapsed.
Click to expand it.
app/api/statement/views.py
View file @
acd77a5f
...
...
@@ -21,9 +21,9 @@ router = APIRouter()
@
router
.
get
(
"/recharge/list"
)
def
statement_recharge_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
order_number
:
Optional
[
str
]
=
""
,
u
ser_
id
:
Optional
[
int
]
=
""
,
sid
:
Optional
[
str
]
=
""
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
types
:
Optional
[
str
]
=
""
,
reference_type
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
def
statement_recharge_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
order_number
:
Optional
[
str
]
=
""
,
u
u
id
:
Optional
[
int
]
=
""
,
sid
:
Optional
[
str
]
=
""
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
types
:
Optional
[
str
]
=
""
,
reference_type
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
"""充值报表列表"""
total
,
statement_list
,
money
=
RechargeStatement
()
.
query_data
(
page
,
size
,
order_number
,
u
ser_
id
,
sid
,
start_time
,
end_time
,
types
,
reference_type
,
month_type
)
total
,
statement_list
,
money
=
RechargeStatement
()
.
query_data
(
page
,
size
,
order_number
,
u
u
id
,
sid
,
start_time
,
end_time
,
types
,
reference_type
,
month_type
)
return
HttpResultResponse
(
total
=
total
,
count
=
float
(
money
),
data
=
statement_list
)
...
...
@@ -36,9 +36,9 @@ def statement_derive_excel(data: schemas.StatementList, request: Request, db: Se
@
router
.
get
(
"/userWithdrawal/list"
)
def
user_withdrawal_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
name
:
Optional
[
str
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
def
user_withdrawal_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
uuid
:
Optional
[
int
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
"""用户提现列表"""
total
,
statement_list
,
money
=
WithdrawStatement
()
.
get_user_withdraw_cash
(
page
,
size
,
name
,
status
,
start_time
,
end_time
,
month_type
)
total
,
statement_list
,
money
=
WithdrawStatement
()
.
get_user_withdraw_cash
(
page
,
size
,
uuid
,
status
,
start_time
,
end_time
,
month_type
)
return
HttpResultResponse
(
total
=
total
,
count
=
float
(
money
),
data
=
statement_list
)
...
...
libs/functions.py
View file @
acd77a5f
...
...
@@ -115,4 +115,10 @@ def get_month_last_month(month_type):
month_date
=
datetime
.
now
()
.
date
()
-
relativedelta
(
months
=
1
)
last_month
=
month_date
.
strftime
(
"
%
Y
%
m"
)
now_month
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m"
)
return
last_month
,
now_month
\ No newline at end of file
return
last_month
,
now_month
def
time_format
(
utc_timestamp
:
int
):
days
=
(
utc_timestamp
+
3600
*
8
)
%
86400
hours
=
int
(
days
/
3600
)
time_str
=
hours
return
time_str
\ No newline at end of file
main.py
View file @
acd77a5f
import
time
from
datetime
import
timedelta
,
datetime
import
uvicorn
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
,
Depends
from
jose
import
jwt
from
app.api.api_v1
import
api_router
from
starlette.middleware.cors
import
CORSMiddleware
from
fastapi
import
Request
from
core.config.env
import
env
from
core.dependencies.auth_dependen
import
create_access_token
from
libs.functions
import
time_format
from
libs.token_verify
import
oauth2_scheme
app
=
FastAPI
()
...
...
@@ -15,6 +25,21 @@ app.add_middleware(
allow_methods
=
[
'*'
],
# 设置允许跨域的http方法,比如 get、post、put等。
allow_headers
=
[
'*'
])
# 允许跨域的headers,可以用来鉴别来源等作用。
@
app
.
middleware
(
"http"
)
async
def
add_process_time_header
(
request
:
Request
,
call_next
):
hs
=
request
.
headers
token
=
hs
.
get
(
"authorization"
)
.
replace
(
'Bearer'
,
''
)
.
replace
(
' '
,
''
)
start_time
=
time
.
time
()
response
=
await
call_next
(
request
)
process_time
=
time
.
time
()
-
start_time
response
.
headers
[
"X-Process-Time"
]
=
str
(
process_time
)
if
token
:
payload
=
jwt
.
decode
(
token
,
env
.
SECRET_KEY
,
algorithms
=
[
env
.
ALGORITHM
])
timestamp
=
payload
.
get
(
"exp"
)
access_token_expires
=
timedelta
(
hours
=
time_format
(
timestamp
))
create_access_token
({
'username'
:
payload
.
get
(
"xup"
),
'password'
:
payload
.
get
(
"password"
)},
expires_delta
=
access_token_expires
)
#更新token时间
return
response
app
.
include_router
(
api_router
,
prefix
=
"/api"
)
# 路由
...
...
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