Commit e6f925b0 authored by 张会鑫's avatar 张会鑫

飞哥提交

parent 90f4c8a8
...@@ -21,6 +21,7 @@ class SensitiveSchemas(BaseModel): ...@@ -21,6 +21,7 @@ class SensitiveSchemas(BaseModel):
class SensitiveInDic(SensitiveSchemas): class SensitiveInDic(SensitiveSchemas):
model_config = ConfigDict(from_attributes=True) model_config = ConfigDict(from_attributes=True)
id :int
word_name: str | None = "" word_name: str | None = ""
class SensitiveIn(SensitiveSchemas): class SensitiveIn(SensitiveSchemas):
......
...@@ -24,6 +24,7 @@ class SimilarInDic(SimilarSchemas): ...@@ -24,6 +24,7 @@ class SimilarInDic(SimilarSchemas):
""" """
创建近义词 创建近义词
""" """
id :int
word_name: str word_name: str
similar_name: str | None = "" similar_name: str | None = ""
......
...@@ -24,7 +24,7 @@ router = APIRouter() ...@@ -24,7 +24,7 @@ router = APIRouter()
# 同义词管理 # 同义词管理
########################################################### ###########################################################
@router.get("/get_similars", summary="获取同义词列表") @router.get("/get_similars", summary="获取同义词列表")
async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(OpenAuth())): async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(FullAdminAuth())):
v_schema = schemas.similar.SimilarInDic v_schema = schemas.similar.SimilarInDic
datas, count = await crud.SimilarDal(auth.db).get_datas( datas, count = await crud.SimilarDal(auth.db).get_datas(
**para.dict(), **para.dict(),
...@@ -34,7 +34,7 @@ async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(Ope ...@@ -34,7 +34,7 @@ async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(Ope
return SuccessResponse(datas, count=count) return SuccessResponse(datas, count=count)
@router.post("/create_similar", summary="创建同义词") @router.post("/create_similar", summary="创建同义词")
async def create_similar(qdata: Request, auth: Auth = Depends(OpenAuth())): async def create_similar(qdata: Request, auth: Auth = Depends(FullAdminAuth())):
if qdata is None: if qdata is None:
print('create_similar is None') print('create_similar is None')
else: else:
...@@ -46,19 +46,19 @@ async def create_similar(qdata: Request, auth: Auth = Depends(OpenAuth())): ...@@ -46,19 +46,19 @@ async def create_similar(qdata: Request, auth: Auth = Depends(OpenAuth())):
return SuccessResponse(await crud.SimilarDal(auth.db).create_data(data=simi_data)) return SuccessResponse(await crud.SimilarDal(auth.db).create_data(data=simi_data))
@router.post("/delete_similars", summary="根据id删除同义词") @router.post("/delete_similars", summary="根据id删除同义词")
async def delete_similars(ids: IdList = Depends(), auth: Auth = Depends(OpenAuth())): async def delete_similars(ids: IdList = Depends(), auth: Auth = Depends(FullAdminAuth())):
await crud.SimilarDal(auth.db).delete_datas(ids=ids.ids, v_soft=True) await crud.SimilarDal(auth.db).delete_datas(ids=ids.ids, v_soft=True)
return SuccessResponse("删除成功") return SuccessResponse("删除成功")
@router.post("/update_similar_byid", summary="根据id修改同义词") @router.post("/update_similar_byid", summary="根据id修改同义词")
async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())): async def update_similar_byid(data: Request, auth: Auth = Depends(FullAdminAuth())):
if data is None: if data is None:
print('SimilarIn is None') print('SimilarIn is None')
return ErrorResponse("不能修改当前近义词") return ErrorResponse("不能修改当前近义词")
else: else:
print(f"word_id:{data.query_params['word_id']} req词条:{data.query_params['word_name']} req近义词:{data.query_params['similar_name']} ") print(f"word_id:{data.query_params['id']} req词条:{data.query_params['word_name']} req近义词:{data.query_params['similar_name']} ")
data_id = data.query_params['word_id'] data_id = data.query_params['id']
sdata = SimilarUpdate sdata = SimilarUpdate
sdata.word_name = data.query_params['word_name'] sdata.word_name = data.query_params['word_name']
...@@ -74,7 +74,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())): ...@@ -74,7 +74,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())):
# 敏感词管理 # 敏感词管理
########################################################### ###########################################################
@router.post("/create_sensitive", summary="创建敏感词") @router.post("/create_sensitive", summary="创建敏感词")
async def create_sensitive(qdata: Request, auth: Auth = Depends(OpenAuth())): async def create_sensitive(qdata: Request, auth: Auth = Depends(FullAdminAuth())):
if qdata is None: if qdata is None:
print('create_sensitive is None') print('create_sensitive is None')
else: else:
...@@ -85,7 +85,7 @@ async def create_sensitive(qdata: Request, auth: Auth = Depends(OpenAuth())): ...@@ -85,7 +85,7 @@ async def create_sensitive(qdata: Request, auth: Auth = Depends(OpenAuth())):
return SuccessResponse(await crud.SensitiveDal(auth.db).create_data(data=Sensit_data)) return SuccessResponse(await crud.SensitiveDal(auth.db).create_data(data=Sensit_data))
@router.get("/get_sensitives", summary="获取敏感词列表") @router.get("/get_sensitives", summary="获取敏感词列表")
async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends(OpenAuth())): async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends(FullAdminAuth())):
v_schema = schemas.sensitive.SensitiveInDic v_schema = schemas.sensitive.SensitiveInDic
datas, count = await crud.SensitiveDal(auth.db).get_datas( datas, count = await crud.SensitiveDal(auth.db).get_datas(
**para.dict(), **para.dict(),
...@@ -95,14 +95,14 @@ async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends ...@@ -95,14 +95,14 @@ async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends
return SuccessResponse(datas, count=count) 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(FullAdminAuth())):
if data is None: if data is None:
print('SimilarIn is None') print('SimilarIn is None')
return ErrorResponse("不能修改当前敏感词") return ErrorResponse("不能修改当前敏感词")
else: else:
print(f"word_id:{data.query_params['word_id']} req词条:{data.query_params['word_name']} ") print(f"word_id:{data.query_params['id']} req词条:{data.query_params['word_name']} ")
data_id = data.query_params['word_id'] data_id = data.query_params['id']
sdata = SensitiveUpdate sdata = SensitiveUpdate
sdata.word_name = data.query_params['word_name'] sdata.word_name = data.query_params['word_name']
...@@ -114,6 +114,6 @@ async def update_sensitive_byid(data: Request, auth: Auth = Depends(OpenAuth())) ...@@ -114,6 +114,6 @@ async def update_sensitive_byid(data: Request, auth: Auth = Depends(OpenAuth()))
return SuccessResponse("修改成功") return SuccessResponse("修改成功")
@router.post("/delete_sensitives", summary="根据id删除敏感词") @router.post("/delete_sensitives", summary="根据id删除敏感词")
async def delete_sensitives(ids: IdList = Depends(), auth: Auth = Depends(OpenAuth())): async def delete_sensitives(ids: IdList = Depends(), auth: Auth = Depends(FullAdminAuth())):
await crud.SensitiveDal(auth.db).delete_datas(ids=ids.ids, v_soft=True) await crud.SensitiveDal(auth.db).delete_datas(ids=ids.ids, v_soft=True)
return SuccessResponse("删除成功") return SuccessResponse("删除成功")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment