|
@@ -7,7 +7,9 @@ from sqlalchemy import case
|
|
|
from sqlalchemy import text
|
|
|
from utils import *
|
|
|
from utils.ry_system_util import *
|
|
|
+from utils.video_util import *
|
|
|
from common.security import valid_access_token
|
|
|
+from fastapi.responses import JSONResponse
|
|
|
import traceback
|
|
|
|
|
|
router = APIRouter()
|
|
@@ -133,3 +135,77 @@ async def get_waterlogged_all_video_info(
|
|
|
except Exception as e:
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@router.get('/get_video_tag_info')
|
|
|
+async def get_video_tag_info(
|
|
|
+ video_code:str = Query(None),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ body=Depends(remove_xss_json),
|
|
|
+ # page: int = Query(1, gt=0, description='页码'),
|
|
|
+ # pageSize: int = Query(10, gt=0, description='每页条目数量'),
|
|
|
+ user_id=Depends(valid_access_token)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ tag = []
|
|
|
+ for info in get_video_tag_list(db,video_code):
|
|
|
+ tag_info = get_dict_data_info(db,info.dict_type,info.dict_value)
|
|
|
+ tag.append({"id":info.id,
|
|
|
+ "video_code":video_code,
|
|
|
+ "dict_type":info.dict_type,
|
|
|
+ "dict_value":info.dict_value,
|
|
|
+ "dict_label":tag_info.dict_label,
|
|
|
+ "dict_code":tag_info.dict_code})
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "成功",
|
|
|
+ "data": tag
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
+@router.post("/add_video_tag")
|
|
|
+async def add_video_tag(
|
|
|
+ user_id=Depends(valid_access_token),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ new_video_tag = TpVideoTag(
|
|
|
+ id = new_guid(),
|
|
|
+ video_code=body['video_code'],
|
|
|
+ dict_value=body['dict_value'],
|
|
|
+ dict_type=body['dict_type'],
|
|
|
+ create_dept = user_id
|
|
|
+ )
|
|
|
+ db.add(new_video_tag)
|
|
|
+ db.commit()
|
|
|
+ return {"code": 200, "msg": "新增成功", "data": None}
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
+@router.delete("/delete_video_tag/{video_tag_id}")
|
|
|
+async def delete_video_tag(
|
|
|
+ video_tag_id: str,
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ # 检查图案是否存在
|
|
|
+ query = db.query(TpVideoTag)
|
|
|
+ query = query.filter(TpVideoTag.id == video_tag_id)
|
|
|
+ query = query.filter(TpVideoTag.del_flag != '2')
|
|
|
+ video_tag = query.first()
|
|
|
+ if not video_tag:
|
|
|
+ return JSONResponse(status_code=404,content={"code":404,"msg":"标签不存在"})
|
|
|
+
|
|
|
+ # 执行删除操作
|
|
|
+ video_tag.del_flag='2'
|
|
|
+ db.commit()
|
|
|
+ return {"code": 200, "msg": "删除成功"}
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|