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
7dd82c26
Commit
7dd82c26
authored
Aug 14, 2024
by
于飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询分页修改
parent
553232c0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
0 deletions
+44
-0
sensitive.py
dbgpt/app/apps/vadmin/word/params/sensitive.py
+2
-0
similar.py
dbgpt/app/apps/vadmin/word/params/similar.py
+2
-0
sensitive.py
dbgpt/app/apps/vadmin/word/schemas/sensitive.py
+6
-0
similar.py
dbgpt/app/apps/vadmin/word/schemas/similar.py
+7
-0
views.py
dbgpt/app/apps/vadmin/word/views.py
+27
-0
No files found.
dbgpt/app/apps/vadmin/word/params/sensitive.py
View file @
7dd82c26
...
@@ -21,6 +21,8 @@ class SensitiveParams(QueryParams):
...
@@ -21,6 +21,8 @@ class SensitiveParams(QueryParams):
def
__init__
(
def
__init__
(
self
,
self
,
word_name
:
str
|
None
=
Query
(
None
,
title
=
"词条"
),
word_name
:
str
|
None
=
Query
(
None
,
title
=
"词条"
),
params
:
Paging
=
Depends
()
):
):
super
()
.
__init__
(
params
)
self
.
word_name
=
(
"like"
,
word_name
)
self
.
word_name
=
(
"like"
,
word_name
)
dbgpt/app/apps/vadmin/word/params/similar.py
View file @
7dd82c26
...
@@ -22,7 +22,9 @@ class SimilarParams(QueryParams):
...
@@ -22,7 +22,9 @@ class SimilarParams(QueryParams):
self
,
self
,
word_name
:
str
|
None
=
Query
(
None
,
title
=
"词条"
),
word_name
:
str
|
None
=
Query
(
None
,
title
=
"词条"
),
similar_name
:
str
|
None
=
Query
(
None
,
title
=
"近义词"
),
similar_name
:
str
|
None
=
Query
(
None
,
title
=
"近义词"
),
params
:
Paging
=
Depends
()
):
):
super
()
.
__init__
(
params
)
self
.
word_name
=
(
"like"
,
word_name
)
self
.
word_name
=
(
"like"
,
word_name
)
self
.
similar_name
=
(
"like"
,
similar_name
)
self
.
similar_name
=
(
"like"
,
similar_name
)
dbgpt/app/apps/vadmin/word/schemas/sensitive.py
View file @
7dd82c26
...
@@ -18,6 +18,12 @@ class SensitiveSchemas(BaseModel):
...
@@ -18,6 +18,12 @@ class SensitiveSchemas(BaseModel):
update_datetime
:
datetime
|
None
=
None
update_datetime
:
datetime
|
None
=
None
delete_datetime
:
datetime
|
None
=
None
delete_datetime
:
datetime
|
None
=
None
class
SensitiveInDic
(
SensitiveSchemas
):
model_config
=
ConfigDict
(
from_attributes
=
True
)
"""
创建近义词
"""
word_name
:
str
|
None
=
""
class
SensitiveIn
(
SensitiveSchemas
):
class
SensitiveIn
(
SensitiveSchemas
):
"""
"""
...
...
dbgpt/app/apps/vadmin/word/schemas/similar.py
View file @
7dd82c26
...
@@ -19,6 +19,13 @@ class SimilarSchemas(BaseModel):
...
@@ -19,6 +19,13 @@ class SimilarSchemas(BaseModel):
update_datetime
:
datetime
|
None
=
None
update_datetime
:
datetime
|
None
=
None
delete_datetime
:
datetime
|
None
=
None
delete_datetime
:
datetime
|
None
=
None
class
SimilarInDic
(
SimilarSchemas
):
model_config
=
ConfigDict
(
from_attributes
=
True
)
"""
创建近义词
"""
word_name
:
str
similar_name
:
str
|
None
=
""
class
SimilarIn
(
SimilarSchemas
):
class
SimilarIn
(
SimilarSchemas
):
"""
"""
...
...
dbgpt/app/apps/vadmin/word/views.py
View file @
7dd82c26
...
@@ -11,6 +11,7 @@ from dbgpt.app.apps.vadmin.word.models.similar import VadminWordSimilar
...
@@ -11,6 +11,7 @@ from dbgpt.app.apps.vadmin.word.models.similar import VadminWordSimilar
from
dbgpt.app.apps.vadmin.word.params.similar
import
SimilarParams
from
dbgpt.app.apps.vadmin.word.params.similar
import
SimilarParams
from
dbgpt.app.apps.vadmin.word.schemas.similar
import
SimilarSchemas
,
SimilarIn
,
SimilarUpdate
from
dbgpt.app.apps.vadmin.word.schemas.similar
import
SimilarSchemas
,
SimilarIn
,
SimilarUpdate
from
dbgpt.app.apps.vadmin.word.schemas.sensitive
import
SensitiveSchemas
,
SensitiveIn
,
SensitiveUpdate
from
dbgpt.app.apps.vadmin.word.schemas.sensitive
import
SensitiveSchemas
,
SensitiveIn
,
SensitiveUpdate
from
dbgpt.app.apps.vadmin.word.params.sensitive
import
SensitiveParams
from
dbgpt.app.apps.vadmin.word
import
crud
from
dbgpt.app.apps.vadmin.word
import
crud
from
fastapi.encoders
import
jsonable_encoder
from
fastapi.encoders
import
jsonable_encoder
...
@@ -20,6 +21,20 @@ router = APIRouter()
...
@@ -20,6 +21,20 @@ router = APIRouter()
###########################################################
###########################################################
# 同义词管理
# 同义词管理
###########################################################
###########################################################
@
router
.
get
(
"/get_test"
,
summary
=
"获取测试列表"
)
async
def
get_test
(
para
:
SimilarParams
=
Depends
(),
auth
:
Auth
=
Depends
(
OpenAuth
())):
#datas = await crud.SimilarDal(auth.db).get_data(para)
#model = models.similar.VadminWordSimilar #不需要关联查询
#v_schema = schemas.similar.SimilarSchemas
v_schema
=
schemas
.
similar
.
SimilarInDic
datas
,
count
=
await
crud
.
SimilarDal
(
auth
.
db
)
.
get_datas
(
**
para
.
dict
(),
v_schema
=
v_schema
,
v_return_count
=
True
)
return
SuccessResponse
(
datas
,
count
=
count
)
@
router
.
get
(
"/get_similars"
,
summary
=
"获取同义词列表"
)
@
router
.
get
(
"/get_similars"
,
summary
=
"获取同义词列表"
)
async
def
get_similars
(
auth
:
Auth
=
Depends
(
OpenAuth
())):
async
def
get_similars
(
auth
:
Auth
=
Depends
(
OpenAuth
())):
model
=
VadminWordSimilar
model
=
VadminWordSimilar
...
@@ -115,6 +130,7 @@ async def create_sensitive(req: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -115,6 +130,7 @@ async def create_sensitive(req: Request, auth: Auth = Depends(OpenAuth())):
return
SuccessResponse
(
"请求成功!"
)
return
SuccessResponse
(
"请求成功!"
)
"""
@router.get("/get_sensitives", summary="获取敏感词列表")
@router.get("/get_sensitives", summary="获取敏感词列表")
async def get_sensitives(auth: Auth = Depends(OpenAuth())):
async def get_sensitives(auth: Auth = Depends(OpenAuth())):
...
@@ -124,6 +140,17 @@ async def get_sensitives(auth: Auth = Depends(OpenAuth())):
...
@@ -124,6 +140,17 @@ async def get_sensitives(auth: Auth = Depends(OpenAuth())):
for row in datas:
for row in datas:
print(f"编号:{row.id} 词条:{row.word_name} ")
print(f"编号:{row.id} 词条:{row.word_name} ")
return SuccessResponse(jsondatas, count=1)
return SuccessResponse(jsondatas, count=1)
"""
@
router
.
get
(
"/get_sensitives"
,
summary
=
"获取敏感词列表"
)
async
def
get_sensitives
(
para
:
SensitiveParams
=
Depends
(),
auth
:
Auth
=
Depends
(
OpenAuth
())):
v_schema
=
schemas
.
sensitive
.
SensitiveInDic
datas
,
count
=
await
crud
.
SensitiveDal
(
auth
.
db
)
.
get_datas
(
**
para
.
dict
(),
v_schema
=
v_schema
,
v_return_count
=
True
)
return
SuccessResponse
(
datas
,
count
=
count
)
@
router
.
post
(
"/update_sensitive_byid"
,
summary
=
"根据id修改敏感词"
)
@
router
.
post
(
"/update_sensitive_byid"
,
summary
=
"根据id修改敏感词"
)
async
def
update_sensitive_byid
(
data
:
Request
,
auth
:
Auth
=
Depends
(
OpenAuth
())):
async
def
update_sensitive_byid
(
data
:
Request
,
auth
:
Auth
=
Depends
(
OpenAuth
())):
...
...
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