|
@@ -349,3 +349,36 @@ async def delete_dict_data(
|
|
|
# # 处理异常
|
|
|
# traceback.print_exc()
|
|
|
# raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@router.post("/labeling_video_tag")
|
|
|
+async def add_video_tag(
|
|
|
+ user_id=Depends(valid_access_token),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+
|
|
|
+ old_video_tag_list = get_video_tag_list(db,body['video_code'])
|
|
|
+ addlist = []
|
|
|
+ for tag in body['dict_value_list']:
|
|
|
+ tag_info = get_dict_data_info(db, 'video_type', tag)
|
|
|
+ if tag_info is None:
|
|
|
+ return JSONResponse(status_code=404, content={"code": 404, "msg": f"{tag}标签不存在"})
|
|
|
+ new_video_tag = TpVideoTag(
|
|
|
+ id = new_guid(),
|
|
|
+ video_code=body['video_code'],
|
|
|
+ dict_value=tag,
|
|
|
+ dict_type='video_type',
|
|
|
+ create_by = user_id
|
|
|
+ )
|
|
|
+ addlist.append(new_video_tag)
|
|
|
+ db.add_all(addlist)
|
|
|
+ for info in old_video_tag_list:
|
|
|
+ info.del_flag='2'
|
|
|
+ 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)}")
|