Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
db_gpt
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
linyangyang
db_gpt
Commits
8b0030b8
Commit
8b0030b8
authored
Aug 12, 2024
by
林洋洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字典表添加 接口路由地址修改
parent
7d2c55f2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
443 additions
and
403 deletions
+443
-403
crud.py
dbgpt/app/apps/system/crud.py
+185
-185
views.py
dbgpt/app/apps/system/views.py
+177
-177
login.py
dbgpt/app/apps/vadmin/auth/utils/login.py
+41
-3
views.py
dbgpt/app/apps/vadmin/auth/views.py
+36
-36
dbgpt_server.py
dbgpt/app/dbgpt_server.py
+4
-2
No files found.
dbgpt/app/apps/system/crud.py
View file @
8b0030b8
This diff is collapsed.
Click to expand it.
dbgpt/app/apps/system/views.py
View file @
8b0030b8
This diff is collapsed.
Click to expand it.
dbgpt/app/apps/vadmin/auth/utils/login.py
View file @
8b0030b8
...
@@ -40,7 +40,7 @@ import jwt
...
@@ -40,7 +40,7 @@ import jwt
router
=
APIRouter
()
router
=
APIRouter
()
@
router
.
post
(
"/
v2
/login"
,
summary
=
"API 手机号密码登录"
,
description
=
"Swagger API 文档登录认证"
)
@
router
.
post
(
"/
api
/login"
,
summary
=
"API 手机号密码登录"
,
description
=
"Swagger API 文档登录认证"
)
async
def
api_login_for_access_token
(
async
def
api_login_for_access_token
(
request
:
Request
,
request
:
Request
,
data
:
OAuth2PasswordRequestForm
=
Depends
(),
data
:
OAuth2PasswordRequestForm
=
Depends
(),
...
@@ -63,14 +63,52 @@ async def api_login_for_access_token(
...
@@ -63,14 +63,52 @@ async def api_login_for_access_token(
# await VadminLoginRecord.create_login_record(db, record, True, request, resp)
# await VadminLoginRecord.create_login_record(db, record, True, request, resp)
return
resp
return
resp
@
router
.
post
(
"/login"
,
summary
=
"手机号密码登录"
,
description
=
"员工登录通道,限制最多输错次数,达到最大值后将is_active=False"
)
async
def
login_for_access_token
(
request
:
Request
,
data
:
LoginForm
,
manage
:
LoginManage
=
Depends
(),
db
:
AsyncSession
=
Depends
(
db_getter
)
):
try
:
if
data
.
method
==
"0"
:
result
=
await
manage
.
password_login
(
data
,
db
,
request
)
# elif data.method == "1":
# result = await manage.sms_login(data, db, request)
else
:
raise
ValueError
(
"无效参数"
)
if
not
result
.
status
:
raise
ValueError
(
result
.
msg
)
access_token
=
LoginManage
.
create_token
(
{
"sub"
:
result
.
user
.
telephone
,
"is_refresh"
:
False
,
"password"
:
result
.
user
.
password
}
)
expires
=
timedelta
(
minutes
=
settings
.
REFRESH_TOKEN_EXPIRE_MINUTES
)
refresh_token
=
LoginManage
.
create_token
(
payload
=
{
"sub"
:
result
.
user
.
telephone
,
"is_refresh"
:
True
,
"password"
:
result
.
user
.
password
},
expires
=
expires
)
resp
=
{
"access_token"
:
access_token
,
"refresh_token"
:
refresh_token
,
"token_type"
:
"bearer"
,
"is_reset_password"
:
result
.
user
.
is_reset_password
,
"is_wx_server_openid"
:
result
.
user
.
is_wx_server_openid
}
# await VadminLoginRecord.create_login_record(db, data, True, request, resp)
return
SuccessResponse
(
resp
)
except
ValueError
as
e
:
# await VadminLoginRecord.create_login_record(db, data, False, request, {"message": str(e)})
return
ErrorResponse
(
msg
=
str
(
e
))
@
router
.
get
(
"/
v2/
getMenuList"
,
summary
=
"获取当前用户菜单树"
)
@
router
.
get
(
"/getMenuList"
,
summary
=
"获取当前用户菜单树"
)
async
def
get_menu_list
(
auth
:
Auth
=
Depends
(
FullAdminAuth
())):
async
def
get_menu_list
(
auth
:
Auth
=
Depends
(
FullAdminAuth
())):
return
SuccessResponse
(
await
MenuDal
(
auth
.
db
)
.
get_routers
(
auth
.
user
))
return
SuccessResponse
(
await
MenuDal
(
auth
.
db
)
.
get_routers
(
auth
.
user
))
@
router
.
post
(
"/
v2/
token/refresh"
,
summary
=
"刷新Token"
)
@
router
.
post
(
"/token/refresh"
,
summary
=
"刷新Token"
)
async
def
token_refresh
(
refresh
:
str
=
Body
(
...
,
title
=
"刷新Token"
)):
async
def
token_refresh
(
refresh
:
str
=
Body
(
...
,
title
=
"刷新Token"
)):
error_code
=
status
.
HTTP_401_UNAUTHORIZED
error_code
=
status
.
HTTP_401_UNAUTHORIZED
try
:
try
:
...
...
dbgpt/app/apps/vadmin/auth/views.py
View file @
8b0030b8
This diff is collapsed.
Click to expand it.
dbgpt/app/dbgpt_server.py
View file @
8b0030b8
...
@@ -96,6 +96,7 @@ def mount_routers(app: FastAPI):
...
@@ -96,6 +96,7 @@ def mount_routers(app: FastAPI):
from
dbgpt.serve.agent.app.endpoints
import
router
as
app_v2
from
dbgpt.serve.agent.app.endpoints
import
router
as
app_v2
from
dbgpt.app.apps.vadmin.auth.utils.login
import
router
as
login
from
dbgpt.app.apps.vadmin.auth.utils.login
import
router
as
login
from
dbgpt.app.apps.vadmin.auth.views
import
router
as
views
from
dbgpt.app.apps.vadmin.auth.views
import
router
as
views
from
dbgpt.app.apps.system.views
import
router
as
system_views
app
.
include_router
(
api_v1
,
prefix
=
"/api"
,
tags
=
[
"Chat"
])
app
.
include_router
(
api_v1
,
prefix
=
"/api"
,
tags
=
[
"Chat"
])
app
.
include_router
(
api_v2
,
prefix
=
"/api"
,
tags
=
[
"ChatV2"
])
app
.
include_router
(
api_v2
,
prefix
=
"/api"
,
tags
=
[
"ChatV2"
])
...
@@ -105,8 +106,9 @@ def mount_routers(app: FastAPI):
...
@@ -105,8 +106,9 @@ def mount_routers(app: FastAPI):
app
.
include_router
(
gpts_v1
,
prefix
=
"/api"
,
tags
=
[
"GptsApp"
])
app
.
include_router
(
gpts_v1
,
prefix
=
"/api"
,
tags
=
[
"GptsApp"
])
app
.
include_router
(
app_v2
,
prefix
=
"/api"
,
tags
=
[
"App"
])
app
.
include_router
(
app_v2
,
prefix
=
"/api"
,
tags
=
[
"App"
])
app
.
include_router
(
knowledge_router
,
tags
=
[
"Knowledge"
])
app
.
include_router
(
knowledge_router
,
tags
=
[
"Knowledge"
])
app
.
include_router
(
login
,
prefix
=
"/api"
,
tags
=
[
"System"
])
app
.
include_router
(
login
,
prefix
=
"/api/v2/auth"
,
tags
=
[
"System"
])
app
.
include_router
(
views
,
prefix
=
"/api"
,
tags
=
[
"System"
])
app
.
include_router
(
views
,
prefix
=
"/api/v2/vadmin/auth"
,
tags
=
[
"System"
])
app
.
include_router
(
system_views
,
prefix
=
"/api/v2/vadmin/system"
,
tags
=
[
"System"
])
def
mount_static_files
(
app
:
FastAPI
):
def
mount_static_files
(
app
:
FastAPI
):
...
...
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